Ejemplo n.º 1
0
        protected override void OnEnd()
        {
            Started = false;
            if (Main.netMode == NetmodeID.MultiplayerClient)
            {
                return;
            }

            if (rand.elements.Count == 0)
            {
                //TwitchChat.Send("No one was selected to become chat boss");
                //TwitchBoss.Boss = string.Empty;
                //TwitchChat.Post("No one...", Color.White);
                return;
            }


            var t = rand.Get();

            TwitchBoss.Boss = t;

            assignTime = DateTimeOffset.Now;
            TwitchChat.Post($"New boss is @[c/{TwitchChat.TwitchColor}:{TwitchBoss.Boss}]", Color.White);

            if (Main.netMode != NetmodeID.MultiplayerClient)
            {
                TwitchChat.Send(EndString + $" @{TwitchBoss.Boss} you can use " +
                                $"{string.Join(" ", (from s in TwitchBoss.Commands select s.Key))}");
            }

            TwitchChat.Instance.Irc.ChannelMessage -= Handle;
        }
Ejemplo n.º 2
0
        protected override void OnEnd()
        {
            TwitchChat.Instance.Irc.ChannelMessage -= CountVote;

            if (VoteMode != VoteMode.EndAction || Main.netMode == NetmodeID.MultiplayerClient)
            {
                return;
            }

            var votesCount = new SortedDictionary <string, int>();

            foreach (KeyValuePair <string, string> it in Votes)
            {
                if (votesCount.ContainsKey(it.Value))
                {
                    votesCount[it.Value]++;
                }
                else
                {
                    votesCount.Add(it.Value, 1);
                }
            }

            var    bigger = 0;
            string index = "", draftIndex = "";

            foreach (KeyValuePair <string, int> it in votesCount)
            {
                if (it.Value > bigger)
                {
                    bigger     = it.Value;
                    index      = it.Key;
                    draftIndex = "";
                }
                else if (it.Value == bigger)
                {
                    draftIndex = it.Key;
                }
            }


            if (index == draftIndex && index != "")
            {
                var rand = new WeightedRandom <string>();
                rand.Add(index);
                rand.Add(draftIndex);

                index = rand.Get();
            }

            if (index != string.Empty)
            {
                VoteSuggestion[index].Invoke(null);
            }
            else
            {
                TwitchChat.Send("No votes...");
            }
        }
Ejemplo n.º 3
0
        protected override void OnStart()
        {
            Votes.Clear();

            if (Main.netMode != NetmodeID.MultiplayerClient)
            {
                TwitchChat.Instance.Irc.ChannelMessage += CountVote;

                var commands = "";
                foreach (KeyValuePair <string, Action <ChannelMessageEventArgs> > it in VoteSuggestion)
                {
                    commands += it.Key + ", ";
                }
                commands = commands.Substring(0, commands.Length - 2);
                TwitchChat.Send($"{Description}. Available commands: {commands}");
            }
        }
Ejemplo n.º 4
0
        protected override void OnStart()
        {
            if (Main.netMode == NetmodeID.MultiplayerClient)
            {
                return;
            }

            rand.Clear();

            Part.Clear();

            Started = true;

            TwitchChat.Instance.Irc.ChannelMessage += Handle;

            TwitchChat.Send(StartString + " Quick write \"boss\" in chat!");
            TwitchChat.Post(StartString, Color.White);
        }
Ejemplo n.º 5
0
        public override void Action(CommandCaller caller, string input, string[] args)
        {
            if (args.Length > 0)
            {
                switch (args[0].ToLower())
                {
                case "c":
                case "connect":
                    if (Mod.OldConfig.Get <string>(TwitchCfg.OAToken) != "https://twitchapps.com/tmi/" &&
                        Mod.OldConfig.Get <string>(TwitchCfg.Username) != "missingno")
                    {
                        Mod.Irc.Username  = Mod.OldConfig.Get <string>(TwitchCfg.Username);
                        Mod.Irc.AuthToken = Mod.OldConfig.Get <string>(TwitchCfg.OAToken);
                        Mod.Irc.Connect();
                    }
                    else
                    {
                        caller.Reply("You missed username or token in settings. Type /t s to open settings file and /t r to reload mod");
                    }

                    break;

                case "dc":
                case "disconnect":
                    Mod.Irc.Disconnect();
                    break;

                case "r":
                case "reload":
                    Mod.Unload();
                    Mod.Load();
                    caller.Reply("Reloading mod....");
                    break;

                case "s":
                case "settings":
                    Mod.Storage.OpenFileExternally(Mod.Storage.GetFullPath("Twitch.ini"));
                    break;

                case "o":
                case "open":
                    Mod.Storage.OpenInNativeExplorer();
                    break;

                case "m":
                case "message":
                    var a = new List <string>();
                    for (var i = 1; i < args.Length; i++)
                    {
                        a.Add(args[i]);
                    }
                    var text = string.Join(" ", a);

                    TwitchChat.Send(text);

                    caller.Reply($"[c/{TwitchChat.TwitchColor}:<-- To Twitch:] {text}");
                    break;

                default:
                    caller.Reply(Usage);
                    return;
                }
            }
            else
            {
                caller.Reply(Usage);
            }
        }