Пример #1
0
        private static void OnCommandReload(CommandArguments command)
        {
            if (command.IsChatRoomCommand)
            {
                ReplyToCommand(command, "{0}: This command can only be used in IRC", command.Nickname);

                return;
            }

            if (IRC.IsSenderOp(command.Channel, command.Nickname))
            {
                SteamProxy.Instance.ReloadImportant(command);
            }
        }
Пример #2
0
        public static void OnChannelMessage(object sender, IrcEventArgs e)
        {
            if (e.Data.Message[0] != '!')
            {
                return;
            }

            if (e.Data.Message == "!relogin" && IRC.IsSenderOp(e.Data.Channel, e.Data.Nick))
            {
                if (Steam.Instance.Client.IsConnected)
                {
                    Steam.Instance.Client.Disconnect();
                }

                foreach (var idler in Program.GCIdlers)
                {
                    if (idler.Client.IsConnected)
                    {
                        idler.Client.Disconnect();
                    }
                }

                Log.WriteInfo("IRC", "Relogin forced by user {0} in channel {1}", e.Data.Nick, e.Data.Channel);

                ReplyToCommand(new CommandArguments {
                    Channel = e.Data.Channel
                }, "{0} is responsible for death of everything and everyone now.", e.Data.Nick);
            }

            Action <CommandArguments> callbackFunction;

            if (Commands.TryGetValue(e.Data.MessageArray[0], out callbackFunction))
            {
                var input = e.Data.Message.Substring(e.Data.MessageArray[0].Length).Trim();

                var command = new CommandArguments
                {
                    Channel  = e.Data.Channel,
                    Nickname = e.Data.Nick,
                    Message  = input
                };

                if (!Steam.Instance.Client.IsConnected)
                {
                    ReplyToCommand(command, "{0}{1}{2}: Not connected to Steam.", Colors.OLIVE, command.Nickname, Colors.NORMAL);

                    return;
                }

                if (SteamDB.IsBusy())
                {
                    ReplyToCommand(command, "{0}{1}{2}: The bot is currently busy.", Colors.OLIVE, command.Nickname, Colors.NORMAL);

                    return;
                }

                Log.WriteInfo("IRC", "Handling command {0} for user {1} in channel {2}", e.Data.MessageArray[0], e.Data.Nick, e.Data.Channel);

                callbackFunction(command);
            }
        }