Exemplo n.º 1
0
        protected override void Init()
        {
            if (TwitchEmotes == null)
            {
                TwitchEmotes = new TwitchEmoteBatch();
            }

            if (TwitchEmotes.HasEmotes)
            {
                TwitchEmotes.Sort();
            }
        }
Exemplo n.º 2
0
 public void AddEmoteBatch(TwitchEmoteBatch Teb)
 {
     TwitchEmotes.Fusion(Teb);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Fires when any message is received.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Tcb_MessageReceived(object sender, MessageReceivedEventArgs e)
        {
            if (e.Type == MessageType.Ping)
            {
                //Tcb.SendIrcMessage("PONG {0}", Tcb.HOST);
                SaveTwitchConfig();
                LogDebugWriteLine("Send 'PONG {0}'", Tcb.HOST);
            }
            else if (e.Type == MessageType.Server)
            {
                Console.WriteLine("{0}", e.RawMessage);
                return;
            }
            else if (e.Type == MessageType.Roomstate || e.Type == MessageType.Userstate)
            {
                return;
            }
            else if (e.Type == MessageType.Usernotice)
            {
                //Console.WriteLine("{0}", e.RawMessage);
                LogDebugWriteLine("{0} just resubbed for {1} months! {2}", e.Nick, e.GetSafeTag("msg-param-months"), (++BotFile.Resubs) + BotFile.NewSubs);

                UpdateStats();

                if (!BotFile.EnableSubMessage)
                {
                    return;
                }

                String Msg = this.BotFile.SubMessageResub + " ";
                // TODO: Replace this.
                Msg = Msg.Replace("%name%", e.Nick);
                Msg = Msg.Replace("%months%", e.GetSafeTag("msg-param-months"));

                Tcb.SendChatMessage(Msg);
            }
            else if (e.Type == MessageType.Chat)
            {
                if (e.IsSubMessage)
                {
                    LogDebugWriteLine("{0} just subscribed! {1}", e.Nick, (++BotFile.NewSubs) + BotFile.Resubs);

                    UpdateStats();

                    if (!BotFile.EnableSubMessage)
                    {
                        return;
                    }

                    String Msg = this.BotFile.SubMessageNew + " ";
                    Msg = Msg.Replace("%name%", e.Nick);

                    Tcb.SendChatMessage(Msg);
                }
                else
                {
                    String Types = CreatePermissionString(e);
                    String k     = String.Empty;
                    foreach (byte s in Encoding.Unicode.GetBytes(e.Message))
                    {
                        k += String.Format("{0} ", s);
                    }
                    LogWriteLine("[{0}] {1}: {2}", Types ?? "DUMMY", e.Nick, e.Message);

                    if (!String.IsNullOrEmpty(e.GetSafeTag("emotes")) && EnableEmoteCollection)
                    {
                        Task.Run(new Action(() =>
                        {
                            TwitchEmoteBatch TemporaryTeb = new TwitchEmoteBatch(e.GetSafeTag("emotes"), e.Message);
                            EmoteDatabase.TwitchEmotes.Fusion(TemporaryTeb);
                        }));
                    }

                    if (e.IsCheer)
                    {
                        Console.WriteLine("Cheered bits: {0,6} -> {1}", e.Bits, BotFile.CheeredBits += e.Bits);
                        LogDebugWriteLine("{0} cheered {1} bits!", e.Nick, e.Bits);
                    }


                    if (!ActiveUsers.Contains(e.Nick) && EnableCoinSystem)
                    {
                        ActiveUsers.Add(e.Nick);
                    }

                    // finish
                    //Console.WriteLine(BotFile.ChatLines);
                    BotFile.ChatLines++;
                    UpdateStats();
                }
            }
            else if (e.Type == MessageType.Whisper)
            {
                String Types = CreatePermissionString(e);
                LogWriteLine("[{0}] *{1}*: {2}", Types ?? "DUMMY", e.Nick, e.Message);
            }
        }