Пример #1
0
        public LedgerRecord GetLedgerRecord(string username, Service service)
        {
            Viewer viewer;

            if (ViewerController.ViewerExists(service, username))
            {
                viewer = ViewerController.GetViewer(service, username);
            }
            else
            {
                viewer = ViewerController.CreateViewer(service, username, 0);
            }

            LedgerRecord ledgerRecord;

            ledgerRecord = LedgerRecords.Find((lr) => lr.Username == username && lr.Service == service);

            if (ledgerRecord == null)
            {
                ledgerRecord = new LedgerRecord()
                {
                    Username     = username,
                    Service      = service,
                    PointBalance = 0
                };
            }

            return(ledgerRecord);
        }
Пример #2
0
        public static List <Viewer> FindViewersInChatterWrapper()
        {
            ChatterWrapper chatterWrapper = JsonConvert.DeserializeObject <ChatterWrapper>(TwitchAPI.lastChatterDownload);

            List <Viewer> chatterNames = new List <Viewer>();

            List <string[]> chatterGroups = new List <string[]>()
            {
                chatterWrapper.chatters.admins,
                chatterWrapper.chatters.broadcaster,
                chatterWrapper.chatters.global_mods,
                chatterWrapper.chatters.moderators,
                chatterWrapper.chatters.staff,
                chatterWrapper.chatters.viewers,
                chatterWrapper.chatters.vips
            };

            foreach (string[] list in chatterGroups)
            {
                foreach (string username in list)
                {
                    if (ViewerController.ViewerExists(Service.Twitch, username))
                    {
                        chatterNames.Add(ViewerController.GetViewer(Service.Twitch, username));
                    }
                    else
                    {
                        chatterNames.Add(ViewerController.CreateViewer(Service.Twitch, username, 0));
                    }
                }
            }

            return(chatterNames);
        }
Пример #3
0
        public override void ParseMessage(ITwitchMessage twitchCommand)
        {
            if (twitchCommand == null)
            {
                return;
            }

            Viewer viewer;

            if (ViewerController.ViewerExists(twitchCommand.Username))
            {
                viewer = ViewerController.GetViewer(twitchCommand.Username);
            }
            else
            {
                viewer = ViewerController.CreateViewer(twitchCommand.Username);
            }

            if (viewer != null && twitchCommand.ChatMessage != null)
            {
                viewer.UpdateViewerFromMessage(twitchCommand.ChatMessage);
            }
        }