From 7ad0b94ed77f526cf697856ad6d8ad5d6311813a Mon Sep 17 00:00:00 2001 From: dank074 Date: Sun, 14 Nov 2021 03:33:40 -0600 Subject: [PATCH] added incoming poll packets --- src/nitro/communication/NitroMessages.ts | 10 +- .../messages/incoming/IncomingHeader.ts | 6 + .../communication/messages/incoming/index.ts | 1 + .../incoming/poll/PollContentsEvent.ts | 16 +++ .../messages/incoming/poll/PollErrorEvent.ts | 16 +++ .../messages/incoming/poll/PollOfferEvent.ts | 16 +++ .../incoming/poll/QuestionAnsweredEvent.ts | 16 +++ .../messages/incoming/poll/QuestionEvent.ts | 16 +++ .../incoming/poll/QuestionFinishedEvent.ts | 16 +++ .../messages/incoming/poll/index.ts | 6 + .../communication/messages/parser/index.ts | 1 + .../messages/parser/poll/PollChoice.ts | 43 +++++++ .../parser/poll/PollContentsParser.ts | 99 ++++++++++++++++ .../messages/parser/poll/PollErrorParser.ts | 15 +++ .../messages/parser/poll/PollOfferParser.ts | 47 ++++++++ .../messages/parser/poll/PollQuestion.ts | 110 ++++++++++++++++++ .../parser/poll/QuestionAnsweredParser.ts | 50 ++++++++ .../parser/poll/QuestionFinishedParser.ts | 40 +++++++ .../messages/parser/poll/QuestionParser.ts | 91 +++++++++++++++ .../messages/parser/poll/index.ts | 8 ++ 20 files changed, 622 insertions(+), 1 deletion(-) create mode 100644 src/nitro/communication/messages/incoming/poll/PollContentsEvent.ts create mode 100644 src/nitro/communication/messages/incoming/poll/PollErrorEvent.ts create mode 100644 src/nitro/communication/messages/incoming/poll/PollOfferEvent.ts create mode 100644 src/nitro/communication/messages/incoming/poll/QuestionAnsweredEvent.ts create mode 100644 src/nitro/communication/messages/incoming/poll/QuestionEvent.ts create mode 100644 src/nitro/communication/messages/incoming/poll/QuestionFinishedEvent.ts create mode 100644 src/nitro/communication/messages/incoming/poll/index.ts create mode 100644 src/nitro/communication/messages/parser/poll/PollChoice.ts create mode 100644 src/nitro/communication/messages/parser/poll/PollContentsParser.ts create mode 100644 src/nitro/communication/messages/parser/poll/PollErrorParser.ts create mode 100644 src/nitro/communication/messages/parser/poll/PollOfferParser.ts create mode 100644 src/nitro/communication/messages/parser/poll/PollQuestion.ts create mode 100644 src/nitro/communication/messages/parser/poll/QuestionAnsweredParser.ts create mode 100644 src/nitro/communication/messages/parser/poll/QuestionFinishedParser.ts create mode 100644 src/nitro/communication/messages/parser/poll/QuestionParser.ts create mode 100644 src/nitro/communication/messages/parser/poll/index.ts diff --git a/src/nitro/communication/NitroMessages.ts b/src/nitro/communication/NitroMessages.ts index 76cf1357..f79dac9b 100644 --- a/src/nitro/communication/NitroMessages.ts +++ b/src/nitro/communication/NitroMessages.ts @@ -1,5 +1,5 @@ import { IMessageConfiguration } from '../../core/communication/messages/IMessageConfiguration'; -import { AchievementNotificationMessageEvent, ActivityPointNotificationMessageEvent, AddJukeboxDiskComposer, ApproveNameMessageComposer, ApproveNameMessageEvent, AvailabilityTimeMessageEvent, BadgePointLimitsEvent, BadgeReceivedEvent, BonusRareInfoMessageEvent, BuildersClubFurniCountMessageEvent, BuildersClubSubscriptionStatusMessageEvent, BundleDiscountRulesetMessageEvent, CallForHelpFromForumMessageMessageComposer, CallForHelpFromForumThreadMessageComposer, CallForHelpFromIMMessageComposer, CallForHelpFromPhotoMessageComposer, CallForHelpFromSelfieMessageComposer, CallForHelpMessageComposer, ChangeUserNameMessageComposer, ChangeUserNameResultMessageEvent, ChatReviewGuideDecidesOnOfferMessageComposer, ChatReviewGuideDetachedMessageComposer, ChatReviewGuideVoteMessageComposer, ChatReviewSessionCreateMessageComposer, CheckUserNameMessageComposer, CheckUserNameResultMessageEvent, CloseIssueDefaultActionMessageComposer, CloseIssuesMessageComposer, ClubGiftNotificationEvent, ControlYoutubeDisplayPlaybackMessageComposer, DeletePendingCallsForHelpMessageComposer, DirectSMSClubBuyAvailableMessageEvent, FigureUpdateEvent, ForwardToASubmittableRoomMessageComposer, ForwardToRandomCompetitionRoomMessageComposer, FurnitureGroupInfoComposer, GetBonusRareInfoMessageComposer, GetCatalogPageExpirationComposer, GetCatalogPageWithEarliestExpiryComposer, GetCfhChatlogMessageComposer, GetCfhStatusMessageComposer, GetCurrentTimingCodeMessageComposer, GetDirectClubBuyAvailableComposer, GetFaqCategoryMessageComposer, GetFaqTextMessageComposer, GetForumsListMessageComposer, GetForumStatsMessageComposer, GetGiftMessageComposer, GetGuideReportingStatusMessageComposer, GetHabboBasicMembershipExtendOfferComposer, GetHabboClubExtendOfferMessageComposer, GetInterstitialMessageComposer, GetJukeboxPlayListMessageComposer, GetLimitedOfferAppearingNextComposer, GetMessagesMessageComposer, GetNextTargetedOfferComposer, GetNowPlayingMessageComposer, GetOfficialSongIdMessageComposer, GetPendingCallsForHelpMessageComposer, GetQuizQuestionsComposer, GetRoomAdPurchaseInfoComposer, GetSeasonalCalendarDailyOfferComposer, GetSecondsUntilMessageComposer, GetSongInfoMessageComposer, GetSoundMachinePlayListMessageComposer, GetThreadMessageComposer, GetThreadsMessageComposer, GetUnreadForumsCountMessageComposer, GetUserSongDisksMessageComposer, GetYoutubeDisplayStatusMessageComposer, GoToFlatMessageComposer, GroupBadgesComposer, GroupBadgesEvent, GuideSessionCreateMessageComposer, GuideSessionFeedbackMessageComposer, GuideSessionGetRequesterRoomMessageComposer, GuideSessionGuideDecidesMessageComposer, GuideSessionInviteRequesterMessageComposer, GuideSessionIsTypingMessageComposer, GuideSessionMessageMessageComposer, GuideSessionOnDutyUpdateMessageComposer, GuideSessionReportMessageComposer, GuideSessionRequesterCancelsMessageComposer, GuideSessionResolvedMessageComposer, HabboClubExtendOfferMessageEvent, HotelClosedAndOpensEvent, HotelClosesAndWillOpenAtEvent, HotelWillCloseInMinutesEvent, InfoFeedEnableMessageEvent, InterstitialMessageEvent, InterstitialShownMessageComposer, IsBadgeRequestFulfilledEvent, IsOfferGiftableMessageEvent, JukeboxPlayListFullMessageEvent, JukeboxSongDisksMessageEvent, LimitedOfferAppearingNextMessageEvent, MaintenanceStatusMessageEvent, MarkCatalogNewAdditionsPageOpenedComposer, MarketplaceBuyOfferComposer, MarketplaceRedeemCreditsComposer, MarketplaceRequesstItemStatsComposer, MarketplaceRequestComposer, MarketplaceRequestOffersComposer, MarketplaceRequestOwnItemsComposer, MarketplaceTakeItemBackComposer, ModerateMessageMessageComposer, ModerateThreadMessageComposer, ModToolPreferencesComposer, ModToolSanctionComposer, MysteryBoxKeysEvent, NotEnoughBalanceMessageEvent, NowPlayingMessageEvent, OfficialSongIdMessageEvent, OpenCampaignCalendarDoorAsStaffComposer, OpenCampaignCalendarDoorComposer, PetExperienceEvent, PetMountComposer, PetSupplementComposer, PickIssuesMessageComposer, PlayListMessageEvent, PlayListSongAddedMessageEvent, PostMessageMessageComposer, PostQuizAnswersComposer, PurchaseBasicMembershipExtensionComposer, PurchaseRoomAdMessageComposer, PurchaseTargetedOfferComposer, PurchaseVipMembershipExtensionComposer, ReleaseIssuesMessageComposer, RemoveAllRightsMessageComposer, RemoveJukeboxDiskComposer, RemoveOwnRoomRightsRoomMessageComposer, RemovePetSaddleComposer, ResetPhoneNumberStateMessageComposer, RoomAdErrorEvent, RoomAdPurchaseInfoEvent, RoomCompetitionInitMessageComposer, RoomUnitGiveHandItemPetComposer, SearchFaqsMessageComposer, SeasonalCalendarDailyOfferMessageEvent, SellablePetPalettesMessageEvent, SetPhoneNumberVerificationStatusMessageComposer, SetTargetedOfferStateComposer, SetYoutubeDisplayPlaylistMessageComposer, ShopTargetedOfferViewedComposer, SubmitRoomToCompetitionMessageComposer, TalentTrackMessageEvent, TargetedOfferEvent, TargetedOfferNotFoundEvent, TogglePetBreedingComposer, TogglePetRidingComposer, TraxSongInfoMessageEvent, TryPhoneNumberMessageComposer, UnseenResetCategoryComposer, UnseenResetItemsComposer, UpdateForumReadMarkerMessageComposer, UpdateForumSettingsMessageComposer, UpdateThreadMessageComposer, UsePetProductComposer, UserSongDisksInventoryMessageEvent, VerifyCodeMessageComposer, VoteForRoomMessageComposer, WardrobeMessageEvent } from './messages'; +import { AchievementNotificationMessageEvent, ActivityPointNotificationMessageEvent, AddJukeboxDiskComposer, ApproveNameMessageComposer, ApproveNameMessageEvent, AvailabilityTimeMessageEvent, BadgePointLimitsEvent, BadgeReceivedEvent, BonusRareInfoMessageEvent, BuildersClubFurniCountMessageEvent, BuildersClubSubscriptionStatusMessageEvent, BundleDiscountRulesetMessageEvent, CallForHelpFromForumMessageMessageComposer, CallForHelpFromForumThreadMessageComposer, CallForHelpFromIMMessageComposer, CallForHelpFromPhotoMessageComposer, CallForHelpFromSelfieMessageComposer, CallForHelpMessageComposer, ChangeUserNameMessageComposer, ChangeUserNameResultMessageEvent, ChatReviewGuideDecidesOnOfferMessageComposer, ChatReviewGuideDetachedMessageComposer, ChatReviewGuideVoteMessageComposer, ChatReviewSessionCreateMessageComposer, CheckUserNameMessageComposer, CheckUserNameResultMessageEvent, CloseIssueDefaultActionMessageComposer, CloseIssuesMessageComposer, ClubGiftNotificationEvent, ControlYoutubeDisplayPlaybackMessageComposer, DeletePendingCallsForHelpMessageComposer, DirectSMSClubBuyAvailableMessageEvent, FigureUpdateEvent, ForwardToASubmittableRoomMessageComposer, ForwardToRandomCompetitionRoomMessageComposer, FurnitureGroupInfoComposer, GetBonusRareInfoMessageComposer, GetCatalogPageExpirationComposer, GetCatalogPageWithEarliestExpiryComposer, GetCfhChatlogMessageComposer, GetCfhStatusMessageComposer, GetCurrentTimingCodeMessageComposer, GetDirectClubBuyAvailableComposer, GetFaqCategoryMessageComposer, GetFaqTextMessageComposer, GetForumsListMessageComposer, GetForumStatsMessageComposer, GetGiftMessageComposer, GetGuideReportingStatusMessageComposer, GetHabboBasicMembershipExtendOfferComposer, GetHabboClubExtendOfferMessageComposer, GetInterstitialMessageComposer, GetJukeboxPlayListMessageComposer, GetLimitedOfferAppearingNextComposer, GetMessagesMessageComposer, GetNextTargetedOfferComposer, GetNowPlayingMessageComposer, GetOfficialSongIdMessageComposer, GetPendingCallsForHelpMessageComposer, GetQuizQuestionsComposer, GetRoomAdPurchaseInfoComposer, GetSeasonalCalendarDailyOfferComposer, GetSecondsUntilMessageComposer, GetSongInfoMessageComposer, GetSoundMachinePlayListMessageComposer, GetThreadMessageComposer, GetThreadsMessageComposer, GetUnreadForumsCountMessageComposer, GetUserSongDisksMessageComposer, GetYoutubeDisplayStatusMessageComposer, GoToFlatMessageComposer, GroupBadgesComposer, GroupBadgesEvent, GuideSessionCreateMessageComposer, GuideSessionFeedbackMessageComposer, GuideSessionGetRequesterRoomMessageComposer, GuideSessionGuideDecidesMessageComposer, GuideSessionInviteRequesterMessageComposer, GuideSessionIsTypingMessageComposer, GuideSessionMessageMessageComposer, GuideSessionOnDutyUpdateMessageComposer, GuideSessionReportMessageComposer, GuideSessionRequesterCancelsMessageComposer, GuideSessionResolvedMessageComposer, HabboClubExtendOfferMessageEvent, HotelClosedAndOpensEvent, HotelClosesAndWillOpenAtEvent, HotelWillCloseInMinutesEvent, InfoFeedEnableMessageEvent, InterstitialMessageEvent, InterstitialShownMessageComposer, IsBadgeRequestFulfilledEvent, IsOfferGiftableMessageEvent, JukeboxPlayListFullMessageEvent, JukeboxSongDisksMessageEvent, LimitedOfferAppearingNextMessageEvent, MaintenanceStatusMessageEvent, MarkCatalogNewAdditionsPageOpenedComposer, MarketplaceBuyOfferComposer, MarketplaceRedeemCreditsComposer, MarketplaceRequesstItemStatsComposer, MarketplaceRequestComposer, MarketplaceRequestOffersComposer, MarketplaceRequestOwnItemsComposer, MarketplaceTakeItemBackComposer, ModerateMessageMessageComposer, ModerateThreadMessageComposer, ModToolPreferencesComposer, ModToolSanctionComposer, MysteryBoxKeysEvent, NotEnoughBalanceMessageEvent, NowPlayingMessageEvent, OfficialSongIdMessageEvent, OpenCampaignCalendarDoorAsStaffComposer, OpenCampaignCalendarDoorComposer, PetExperienceEvent, PetMountComposer, PetSupplementComposer, PickIssuesMessageComposer, PlayListMessageEvent, PlayListSongAddedMessageEvent, PollContentsEvent, PollErrorEvent, PollOfferEvent, PostMessageMessageComposer, PostQuizAnswersComposer, PurchaseBasicMembershipExtensionComposer, PurchaseRoomAdMessageComposer, PurchaseTargetedOfferComposer, PurchaseVipMembershipExtensionComposer, QuestionAnsweredEvent, QuestionEvent, QuestionFinishedEvent, ReleaseIssuesMessageComposer, RemoveAllRightsMessageComposer, RemoveJukeboxDiskComposer, RemoveOwnRoomRightsRoomMessageComposer, RemovePetSaddleComposer, ResetPhoneNumberStateMessageComposer, RoomAdErrorEvent, RoomAdPurchaseInfoEvent, RoomCompetitionInitMessageComposer, RoomUnitGiveHandItemPetComposer, SearchFaqsMessageComposer, SeasonalCalendarDailyOfferMessageEvent, SellablePetPalettesMessageEvent, SetPhoneNumberVerificationStatusMessageComposer, SetTargetedOfferStateComposer, SetYoutubeDisplayPlaylistMessageComposer, ShopTargetedOfferViewedComposer, SubmitRoomToCompetitionMessageComposer, TalentTrackMessageEvent, TargetedOfferEvent, TargetedOfferNotFoundEvent, TogglePetBreedingComposer, TogglePetRidingComposer, TraxSongInfoMessageEvent, TryPhoneNumberMessageComposer, UnseenResetCategoryComposer, UnseenResetItemsComposer, UpdateForumReadMarkerMessageComposer, UpdateForumSettingsMessageComposer, UpdateThreadMessageComposer, UsePetProductComposer, UserSongDisksInventoryMessageEvent, VerifyCodeMessageComposer, VoteForRoomMessageComposer, WardrobeMessageEvent } from './messages'; import { AvailabilityStatusMessageEvent } from './messages/incoming/availability/AvailabilityStatusMessageEvent'; import { BotAddedToInventoryEvent, BotInventoryMessageEvent, BotReceivedMessageEvent, BotRemovedFromInventoryEvent } from './messages/incoming/bots'; import { CfhSanctionMessageEvent, CfhTopicsInitEvent, SanctionStatusEvent } from './messages/incoming/callforhelp'; @@ -699,6 +699,14 @@ export class NitroMessages implements IMessageConfiguration this._events.set(IncomingHeader.BOT_ERROR, BotErrorEvent); this._events.set(IncomingHeader.PET_LEVEL_NOTIFICATION, PetLevelNotificationEvent); + // POLL + this._events.set(IncomingHeader.QUESTION, QuestionEvent); + this._events.set(IncomingHeader.POLL_CONTENTS, PollContentsEvent); + this._events.set(IncomingHeader.POLL_ERROR, PollErrorEvent); + this._events.set(IncomingHeader.POLL_OFFER, PollOfferEvent); + this._events.set(IncomingHeader.QUESTION_ANSWERED, QuestionAnsweredEvent); + this._events.set(IncomingHeader.QUESTION_FINISHED, QuestionFinishedEvent); + // QUEST this._events.set(IncomingHeader.COMMUNITY_GOAL_EARNED_PRIZES, CommunityGoalEarnedPrizesMessageEvent); this._events.set(IncomingHeader.COMMUNITY_GOAL_PROGRESS, CommunityGoalProgressMessageEvent); diff --git a/src/nitro/communication/messages/incoming/IncomingHeader.ts b/src/nitro/communication/messages/incoming/IncomingHeader.ts index 762d9e8b..4393bb58 100644 --- a/src/nitro/communication/messages/incoming/IncomingHeader.ts +++ b/src/nitro/communication/messages/incoming/IncomingHeader.ts @@ -331,4 +331,10 @@ export class IncomingHeader public static YOUTUBE_DISPLAY_PLAYLISTS = 1112; public static YOUTUBE_DISPLAY_VIDEO = 1411; public static CFH_DISABLED_NOTIFY = 1651; + public static QUESTION = 2665; + public static POLL_CONTENTS = 2997; + public static POLL_ERROR = 662; + public static POLL_OFFER = 3785; + public static QUESTION_ANSWERED = 2589; + public static QUESTION_FINISHED = 1066; } diff --git a/src/nitro/communication/messages/incoming/index.ts b/src/nitro/communication/messages/incoming/index.ts index b9e74ff9..4cbde107 100644 --- a/src/nitro/communication/messages/incoming/index.ts +++ b/src/nitro/communication/messages/incoming/index.ts @@ -28,6 +28,7 @@ export * from './moderation'; export * from './mysterybox'; export * from './navigator'; export * from './notifications'; +export * from './poll'; export * from './quest'; export * from './room'; export * from './room/access'; diff --git a/src/nitro/communication/messages/incoming/poll/PollContentsEvent.ts b/src/nitro/communication/messages/incoming/poll/PollContentsEvent.ts new file mode 100644 index 00000000..b8e70ad9 --- /dev/null +++ b/src/nitro/communication/messages/incoming/poll/PollContentsEvent.ts @@ -0,0 +1,16 @@ +import { IMessageEvent } from '../../../../../core/communication/messages/IMessageEvent'; +import { MessageEvent } from '../../../../../core/communication/messages/MessageEvent'; +import { PollContentsParser } from '../../parser/poll/PollContentsParser'; + +export class PollContentsEvent extends MessageEvent implements IMessageEvent +{ + constructor(callBack: Function) + { + super(callBack, PollContentsParser); + } + + public getParser(): PollContentsParser + { + return this.parser as PollContentsParser; + } +} diff --git a/src/nitro/communication/messages/incoming/poll/PollErrorEvent.ts b/src/nitro/communication/messages/incoming/poll/PollErrorEvent.ts new file mode 100644 index 00000000..b70d82bd --- /dev/null +++ b/src/nitro/communication/messages/incoming/poll/PollErrorEvent.ts @@ -0,0 +1,16 @@ +import { IMessageEvent } from '../../../../../core/communication/messages/IMessageEvent'; +import { MessageEvent } from '../../../../../core/communication/messages/MessageEvent'; +import { PollErrorParser } from '../../parser/poll/PollErrorParser'; + +export class PollErrorEvent extends MessageEvent implements IMessageEvent +{ + constructor(callBack: Function) + { + super(callBack, PollErrorParser); + } + + public getParser(): PollErrorParser + { + return this.parser as PollErrorParser; + } +} diff --git a/src/nitro/communication/messages/incoming/poll/PollOfferEvent.ts b/src/nitro/communication/messages/incoming/poll/PollOfferEvent.ts new file mode 100644 index 00000000..e7bdf1b1 --- /dev/null +++ b/src/nitro/communication/messages/incoming/poll/PollOfferEvent.ts @@ -0,0 +1,16 @@ +import { IMessageEvent } from '../../../../../core/communication/messages/IMessageEvent'; +import { MessageEvent } from '../../../../../core/communication/messages/MessageEvent'; +import { PollOfferParser } from '../../parser/poll/PollOfferParser'; + +export class PollOfferEvent extends MessageEvent implements IMessageEvent +{ + constructor(callBack: Function) + { + super(callBack, PollOfferParser); + } + + public getParser(): PollOfferParser + { + return this.parser as PollOfferParser; + } +} diff --git a/src/nitro/communication/messages/incoming/poll/QuestionAnsweredEvent.ts b/src/nitro/communication/messages/incoming/poll/QuestionAnsweredEvent.ts new file mode 100644 index 00000000..1a298384 --- /dev/null +++ b/src/nitro/communication/messages/incoming/poll/QuestionAnsweredEvent.ts @@ -0,0 +1,16 @@ +import { IMessageEvent } from '../../../../../core/communication/messages/IMessageEvent'; +import { MessageEvent } from '../../../../../core/communication/messages/MessageEvent'; +import { QuestionAnsweredParser } from '../../parser/poll/QuestionAnsweredParser'; + +export class QuestionAnsweredEvent extends MessageEvent implements IMessageEvent +{ + constructor(callBack: Function) + { + super(callBack, QuestionAnsweredParser); + } + + public getParser(): QuestionAnsweredParser + { + return this.parser as QuestionAnsweredParser; + } +} diff --git a/src/nitro/communication/messages/incoming/poll/QuestionEvent.ts b/src/nitro/communication/messages/incoming/poll/QuestionEvent.ts new file mode 100644 index 00000000..19cedd68 --- /dev/null +++ b/src/nitro/communication/messages/incoming/poll/QuestionEvent.ts @@ -0,0 +1,16 @@ +import { IMessageEvent } from '../../../../../core/communication/messages/IMessageEvent'; +import { MessageEvent } from '../../../../../core/communication/messages/MessageEvent'; +import { QuestionParser } from '../../parser/poll/QuestionParser'; + +export class QuestionEvent extends MessageEvent implements IMessageEvent +{ + constructor(callBack: Function) + { + super(callBack, QuestionParser); + } + + public getParser(): QuestionParser + { + return this.parser as QuestionParser; + } +} diff --git a/src/nitro/communication/messages/incoming/poll/QuestionFinishedEvent.ts b/src/nitro/communication/messages/incoming/poll/QuestionFinishedEvent.ts new file mode 100644 index 00000000..4ccf9c6a --- /dev/null +++ b/src/nitro/communication/messages/incoming/poll/QuestionFinishedEvent.ts @@ -0,0 +1,16 @@ +import { IMessageEvent } from '../../../../../core/communication/messages/IMessageEvent'; +import { MessageEvent } from '../../../../../core/communication/messages/MessageEvent'; +import { QuestionFinishedParser } from '../../parser/poll/QuestionFinishedParser'; + +export class QuestionFinishedEvent extends MessageEvent implements IMessageEvent +{ + constructor(callBack: Function) + { + super(callBack, QuestionFinishedParser); + } + + public getParser(): QuestionFinishedParser + { + return this.parser as QuestionFinishedParser; + } +} diff --git a/src/nitro/communication/messages/incoming/poll/index.ts b/src/nitro/communication/messages/incoming/poll/index.ts new file mode 100644 index 00000000..ef4863f6 --- /dev/null +++ b/src/nitro/communication/messages/incoming/poll/index.ts @@ -0,0 +1,6 @@ +export * from './PollContentsEvent'; +export * from './PollErrorEvent'; +export * from './PollOfferEvent'; +export * from './QuestionAnsweredEvent'; +export * from './QuestionEvent'; +export * from './QuestionFinishedEvent'; diff --git a/src/nitro/communication/messages/parser/index.ts b/src/nitro/communication/messages/parser/index.ts index 19864764..19f2d081 100644 --- a/src/nitro/communication/messages/parser/index.ts +++ b/src/nitro/communication/messages/parser/index.ts @@ -20,6 +20,7 @@ export * from './moderation'; export * from './mysterybox'; export * from './navigator'; export * from './notifications'; +export * from './poll'; export * from './quest'; export * from './room'; export * from './roomevents'; diff --git a/src/nitro/communication/messages/parser/poll/PollChoice.ts b/src/nitro/communication/messages/parser/poll/PollChoice.ts new file mode 100644 index 00000000..5895b3ef --- /dev/null +++ b/src/nitro/communication/messages/parser/poll/PollChoice.ts @@ -0,0 +1,43 @@ +export class PollChoice +{ + private _value:string; + private _choiceText:string; + private _choiceType:number; + + constructor(k:string, _arg_2:string, _arg_3:number) + { + this._value = k; + this._choiceText = _arg_2; + this._choiceType = _arg_3; + } + + public get value():string + { + return this._value; + } + + public set value(value:string) + { + this._value = value; + } + + public get choiceText():string + { + return this._choiceText; + } + + public set choiceText(choiceText:string) + { + this._choiceText = choiceText; + } + + public get choiceType():number + { + return this._choiceType; + } + + public set choiceType(k:number) + { + this._choiceType = k; + } +} diff --git a/src/nitro/communication/messages/parser/poll/PollContentsParser.ts b/src/nitro/communication/messages/parser/poll/PollContentsParser.ts new file mode 100644 index 00000000..383494d6 --- /dev/null +++ b/src/nitro/communication/messages/parser/poll/PollContentsParser.ts @@ -0,0 +1,99 @@ +import { IMessageDataWrapper } from '../../../../../core/communication/messages/IMessageDataWrapper'; +import { IMessageParser } from '../../../../../core/communication/messages/IMessageParser'; +import { PollChoice } from './PollChoice'; +import { PollQuestion } from './PollQuestion'; + +export class PollContentsParser implements IMessageParser +{ + private _id = -1; + private _startMessage = ''; + private _endMessage = ''; + private _numQuestions = 0; + private _questionArray:PollQuestion[] = []; + private _npsPoll = false + + flush(): boolean + { + this._id = -1; + this._startMessage = ''; + this._endMessage = ''; + this._numQuestions = 0; + this._questionArray = []; + return true; + } + + parse(wrapper: IMessageDataWrapper): boolean + { + this._id = wrapper.readInt(); + this._startMessage = wrapper.readString(); + this._endMessage = wrapper.readString(); + this._numQuestions = wrapper.readInt(); + + for(let i = 0; i < this._numQuestions; i++) + { + const question = this.parsePollQuestion(wrapper); + const childrenCount = wrapper.readInt(); + + for(let j = 0; j < childrenCount; j++) + { + question.children.push(this.parsePollQuestion(wrapper)); + } + + this._questionArray.push(question); + } + + this._npsPoll = wrapper.readBoolean(); + return true; + } + + private parsePollQuestion(k:IMessageDataWrapper):PollQuestion + { + const pollQuestion = new PollQuestion(); + pollQuestion.questionId = k.readInt(); + pollQuestion.sortOrder = k.readInt(); + pollQuestion.questionType = k.readInt(); + pollQuestion.questionText = k.readString(); + pollQuestion.questionCategory = k.readInt(); + pollQuestion.questionAnswerType = k.readInt(); + pollQuestion.questionAnswerCount = k.readInt(); + if(((pollQuestion.questionType == 1) || (pollQuestion.questionType == 2))) + { + for(let i = 0; i < pollQuestion.questionAnswerCount; i++) + { + pollQuestion.questionChoices.push(new PollChoice(k.readString(), k.readString(), k.readInt())); + } + } + return pollQuestion; + } + + public get id():number + { + return this._id; + } + + public get startMessage():string + { + return this._startMessage; + } + + public get endMessage():string + { + return this._endMessage; + } + + public get numQuestions():number + { + return this._numQuestions; + } + + public get questionArray():PollQuestion[] + { + return this._questionArray; + } + + public get npsPoll():boolean + { + return this._npsPoll; + } + +} diff --git a/src/nitro/communication/messages/parser/poll/PollErrorParser.ts b/src/nitro/communication/messages/parser/poll/PollErrorParser.ts new file mode 100644 index 00000000..132187a4 --- /dev/null +++ b/src/nitro/communication/messages/parser/poll/PollErrorParser.ts @@ -0,0 +1,15 @@ +import { IMessageDataWrapper } from '../../../../../core/communication/messages/IMessageDataWrapper'; +import { IMessageParser } from '../../../../../core/communication/messages/IMessageParser'; + +export class PollErrorParser implements IMessageParser +{ + flush(): boolean + { + throw true; + } + + parse(wrapper: IMessageDataWrapper): boolean + { + return true; + } +} diff --git a/src/nitro/communication/messages/parser/poll/PollOfferParser.ts b/src/nitro/communication/messages/parser/poll/PollOfferParser.ts new file mode 100644 index 00000000..6f27805d --- /dev/null +++ b/src/nitro/communication/messages/parser/poll/PollOfferParser.ts @@ -0,0 +1,47 @@ +import { IMessageDataWrapper } from '../../../../../core/communication/messages/IMessageDataWrapper'; +import { IMessageParser } from '../../../../../core/communication/messages/IMessageParser'; + +export class PollOfferParser implements IMessageParser +{ + private _id = -1; + private _type = ''; + private _headline = ''; + private _summary = ''; + + flush(): boolean + { + this._id = -1; + this._type = ''; + this._summary = ''; + return true; + } + + parse(wrapper: IMessageDataWrapper): boolean + { + this._id = wrapper.readInt(); + this._type = wrapper.readString(); + this._headline = wrapper.readString(); + this._summary = wrapper.readString(); + return true; + } + + public get id():number + { + return this._id; + } + + public get type():string + { + return this._type; + } + + public get headline():string + { + return this._headline; + } + + public get summary():string + { + return this._summary; + } +} diff --git a/src/nitro/communication/messages/parser/poll/PollQuestion.ts b/src/nitro/communication/messages/parser/poll/PollQuestion.ts new file mode 100644 index 00000000..35fdb802 --- /dev/null +++ b/src/nitro/communication/messages/parser/poll/PollQuestion.ts @@ -0,0 +1,110 @@ +import { PollChoice } from './PollChoice'; + +export class PollQuestion +{ + private _questionId:number; + private _questionType:number; + private _sortOrder:number; + private _questionCategory:number; + private _questionText:string; + private _questionAnswerType:number; + private _questionAnswerCount:number; + private _children:PollQuestion[]; + private _questionChoices:PollChoice[]; + + constructor() + { + this._children = []; + this._questionChoices = []; + } + + public get questionId():number + { + return this._questionId; + } + + public set questionId(k:number) + { + this._questionId = k; + } + + public get questionType():number + { + return this._questionType; + } + + public set questionType(k:number) + { + this._questionType = k; + } + + public get sortOrder():number + { + return this._sortOrder; + } + + public set sortOrder(sortOrder:number) + { + this._sortOrder = sortOrder; + } + + public get questionText():string + { + return this._questionText; + } + + public set questionText(k:string) + { + this._questionText = k; + } + + public get questionCategory():number + { + return this._questionCategory; + } + + public set questionCategory(k:number) + { + this._questionCategory = k; + } + + public get questionAnswerType():number + { + return this._questionAnswerType; + } + + public set questionAnswerType(k:number) + { + this._questionAnswerType = k; + } + + public get questionAnswerCount():number + { + return this._questionAnswerCount; + } + + public set questionAnswerCount(k:number) + { + this._questionAnswerCount = k; + } + + public get children():PollQuestion[] + { + return this._children; + } + + public set children(children:PollQuestion[]) + { + this._children = children; + } + + public get questionChoices():PollChoice[] + { + return this._questionChoices; + } + + public set questionChoices(k:PollChoice[]) + { + this._questionChoices = k; + } +} diff --git a/src/nitro/communication/messages/parser/poll/QuestionAnsweredParser.ts b/src/nitro/communication/messages/parser/poll/QuestionAnsweredParser.ts new file mode 100644 index 00000000..8902a42a --- /dev/null +++ b/src/nitro/communication/messages/parser/poll/QuestionAnsweredParser.ts @@ -0,0 +1,50 @@ +import { IMessageDataWrapper } from '../../../../../core/communication/messages/IMessageDataWrapper'; +import { IMessageParser } from '../../../../../core/communication/messages/IMessageParser'; + +export class QuestionAnsweredParser implements IMessageParser +{ + private _userId:number; + private _value:string; + private _answerCounts:Map; + + flush(): boolean + { + this._userId = -1; + this._value = ''; + this._answerCounts = null; + return false; + } + + parse(wrapper: IMessageDataWrapper): boolean + { + this._userId = wrapper.readInt(); + this._value = wrapper.readString(); + this._answerCounts = new Map(); + + const count = wrapper.readInt(); + + for(let i = 0; i < count; i++) + { + const key = wrapper.readString(); + const value = wrapper.readInt(); + this._answerCounts.set(key, value); + } + return true; + } + + public get userId():number + { + return this._userId; + } + + public get value():string + { + return this._value; + } + + public get answerCounts():Map + { + return this._answerCounts; + } + +} diff --git a/src/nitro/communication/messages/parser/poll/QuestionFinishedParser.ts b/src/nitro/communication/messages/parser/poll/QuestionFinishedParser.ts new file mode 100644 index 00000000..c3d7aea4 --- /dev/null +++ b/src/nitro/communication/messages/parser/poll/QuestionFinishedParser.ts @@ -0,0 +1,40 @@ +import { IMessageDataWrapper } from '../../../../../core/communication/messages/IMessageDataWrapper'; +import { IMessageParser } from '../../../../../core/communication/messages/IMessageParser'; + +export class QuestionFinishedParser implements IMessageParser +{ + private _questionId:number; + private _answerCounts:Map; + + flush(): boolean + { + this._questionId = -1; + this._answerCounts = null; + return false; + } + + parse(wrapper: IMessageDataWrapper): boolean + { + this._questionId = wrapper.readInt(); + this._answerCounts = new Map(); + const count = wrapper.readInt(); + + for(let i = 0; i < count; i++) + { + const key = wrapper.readString(); + const value = wrapper.readInt(); + this._answerCounts.set(key, value); + } + return true; + } + + public get questionId():number + { + return this._questionId; + } + + public get answerCounts():Map + { + return this._answerCounts; + } +} diff --git a/src/nitro/communication/messages/parser/poll/QuestionParser.ts b/src/nitro/communication/messages/parser/poll/QuestionParser.ts new file mode 100644 index 00000000..735768dd --- /dev/null +++ b/src/nitro/communication/messages/parser/poll/QuestionParser.ts @@ -0,0 +1,91 @@ +import { IMessageDataWrapper } from '../../../../../core'; +import { IMessageParser } from '../../../../../core/communication/messages/IMessageParser'; + +export class QuestionParser implements IMessageParser +{ + private _pollType:string = null; + private _pollId= -1; + private _questionId = -1; + private _duration = -1; + private _question:IQuestion = null; + + flush(): boolean + { + this._pollType = null; + this._pollId = -1; + this._questionId = -1; + this._duration = -1; + this._question = null; + return true; + } + + parse(wrapper: IMessageDataWrapper): boolean + { + this._pollType = wrapper.readString(); + this._pollId = wrapper.readInt(); + this._questionId = wrapper.readInt(); + this._duration = wrapper.readInt(); + + const questionId = wrapper.readInt(); + const questionNumber = wrapper.readInt(); + const questionType = wrapper.readInt(); + const questionContent = wrapper.readString(); + + this._question = { id: questionId, number: questionNumber, type: questionType, content: questionContent }; + + if(((this._question.type == 1) || (this._question.type == 2))) + { + this._question.selection_min = wrapper.readInt(); + const count = wrapper.readInt(); + this._question.selections = []; + this._question.selection_values = []; + this._question.selection_count = count; + this._question.selection_max = count; + + for(let i = 0; i < count; i++) + { + this._question.selection_values.push(wrapper.readString()); + this._question.selections.push(wrapper.readString()); + } + } + return true; + } + + public get pollType():string + { + return this._pollType; + } + + public get pollId():number + { + return this._pollId; + } + + public get questionId():number + { + return this._questionId; + } + + public get duration():number + { + return this._duration; + } + + public get question():IQuestion + { + return this._question; + } +} + +interface IQuestion +{ + id: number; + number: number; + type: number; + content: string; + selection_min?: number; + selections?: string[]; + selection_values?: string[]; + selection_count?: number; + selection_max?: number; +} diff --git a/src/nitro/communication/messages/parser/poll/index.ts b/src/nitro/communication/messages/parser/poll/index.ts new file mode 100644 index 00000000..b82d2b0a --- /dev/null +++ b/src/nitro/communication/messages/parser/poll/index.ts @@ -0,0 +1,8 @@ +export * from './PollChoice'; +export * from './PollContentsParser'; +export * from './PollErrorParser'; +export * from './PollOfferParser'; +export * from './PollQuestion'; +export * from './QuestionAnsweredParser'; +export * from './QuestionFinishedParser'; +export * from './QuestionParser';