Exemplo n.º 1
0
        public override void Use(Player p, string message, CommandData data)
        {
            RelayBot bot = Bot;

            if (message.CaselessEq("reset") || message.CaselessEq("reconnect"))
            {
                if (!bot.Enabled)
                {
                    p.Message("{0} is not enabled", bot.RelayName);
                }
                bot.Reset();
            }
            else if (message.CaselessEq("connect"))
            {
                string err = bot.Connect();
                if (err != null)
                {
                    p.Message("{0} bot {1}", bot.RelayName, err);
                }
            }
            else if (message.CaselessEq("disconnect"))
            {
                bot.Disconnect("Disconnecting IRC bot");
            }
            else
            {
                Help(p);
            }
        }
Exemplo n.º 2
0
 protected void Use(Player p, string message, RelayBot bot)
 {
     if (message.CaselessEq("reset") || message.CaselessEq("reconnect"))
     {
         if (!bot.Enabled)
         {
             p.Message("{0} is not enabled", bot.RelayName);
         }
         bot.Reset();
     }
     else if (message.CaselessEq("connect"))
     {
         if (!bot.Enabled)
         {
             p.Message("{0} is not enabled", bot.RelayName);
         }
         bot.Connect();
     }
     else if (message.CaselessEq("disconnect"))
     {
         bot.Disconnect("Disconnecting IRC bot");
     }
     else
     {
         Help(p);
     }
 }
Exemplo n.º 3
0
 public static void Call(RelayBot bot, string channel, RelayUser user, string message, ref bool cancel)
 {
     IEvent <OnChannelMessage>[] items = handlers.Items;
     for (int i = 0; i < items.Length; i++)
     {
         try {
             items[i].method(bot, channel, user, message, ref cancel);
         } catch (Exception ex) {
             LogHandlerException(ex, items[i]);
         }
     }
 }
Exemplo n.º 4
0
        protected void Help(Player p, RelayBot bot)
        {
            string cmd   = name;
            string relay = bot.RelayName;

            p.Message("&T/{0} connect", cmd);
            p.Message("&HCauses the {0} bot to connect to {0}.", relay);
            p.Message("&T/{0} disconnect", cmd);
            p.Message("&HCauses the {0} bot to disconnect from {0}.", relay);
            p.Message("&T/{0} reset", cmd);
            p.Message("&HCauses the {0} bot to disconnect then reconnect.", relay);
        }
Exemplo n.º 5
0
            public RelayPlayer(string channel, RelayUser user, RelayBot bot) : base(bot.RelayName)
            {
                group = bot.GetControllerRank();

                ChannelID = channel;
                User      = user;
                color     = "&a";
                Bot       = bot;

                if (user != null)
                {
                    string nick = "(" + bot.RelayName + " " + user.Nick + ")";
                    DatabaseID = NameConverter.InvalidNameID(nick);
                }
                SuperName = bot.RelayName;
            }
Exemplo n.º 6
0
            public RelayPlayer(string channel, RelayUser user, RelayBot bot) : base(bot.RelayName)
            {
                group = Group.Find(Server.Config.IRCControllerRank);
                if (group == null)
                {
                    group = Group.NobodyRank;
                }

                ChannelID = channel;
                User      = user;
                color     = "&a";
                Bot       = bot;

                if (user != null)
                {
                    string nick = "(" + bot.RelayName + user.Nick + ")";
                    DatabaseID = NameConverter.InvalidNameID(nick);
                }
                SuperName = bot.RelayName;
            }
Exemplo n.º 7
0
        public override void Use(Player p, string message, CommandData data)
        {
            if (message.Length == 0)
            {
                Help(p); return;
            }
            string[] parts = message.SplitSpaces();
            RelayBot bot   = Bot;

            string cmd = parts[0].ToLower();
            string arg = parts.Length > 1 ? parts[1] : "";

            switch (cmd)
            {
            case "reload":
                bot.LoadControllers();
                p.Message("{0} controllers reloaded!", bot.RelayName);
                break;

            case "add":
                if (arg.Length == 0)
                {
                    p.Message("You need to provide a name to add."); return;
                }

                if (!bot.Controllers.Add(arg))
                {
                    p.Message("{0} is already in the {1} controllers list.", arg, bot.RelayName);
                }
                else
                {
                    bot.Controllers.Save();
                    p.Message("{0} added to the {1} controllers list.", arg, bot.RelayName);
                }
                break;

            case "remove":
                if (arg.Length == 0)
                {
                    p.Message("You need to provide a name to remove."); return;
                }

                if (!bot.Controllers.Remove(arg))
                {
                    p.Message("{0} is not in the {1} controllers list.", arg, bot.RelayName);
                }
                else
                {
                    bot.Controllers.Save();
                    p.Message("{0} removed from the {1} controllers list.", arg, bot.RelayName);
                }
                break;

            case "list":
                bot.Controllers.OutputPlain(p, bot.RelayName + " controllers",
                                            name + " list", arg);
                break;

            case "rank":
                if (arg.Length == 0)
                {
                    p.Message("{0} controllers have the rank {1}", bot.RelayName,
                              Group.GetColoredName(Server.Config.IRCControllerRank));
                    return;
                }

                Group grp = Matcher.FindRanks(p, arg);
                if (grp == null)
                {
                    return;
                }
                if (Server.Config.IRCControllerRank > data.Rank)
                {
                    p.Message("Cannot change the {0} controllers rank, " +
                              "as it is currently a rank higher than yours.", bot.RelayName); return;
                }
                if (grp.Permission > data.Rank)
                {
                    p.Message("Cannot set the {0} controllers rank to a rank higher than yours.", bot.RelayName); return;
                }

                Server.Config.IRCControllerRank = grp.Permission;
                SrvProperties.Save();
                p.Message("Set {0} controller rank to {1}&S.", bot.RelayName, grp.ColoredName);
                break;

            default:
                Help(p); break;
            }
        }