Пример #1
0
 /// <summary>
 /// Initialize everything that needs to be initialized once we're logged in.
 /// </summary>
 /// <param name="login">The status of the login</param>
 /// <param name="message">Error message on failure, MOTD on success.</param>
 public void RegisterCommand(string name, Cogbot.Actions.Command live)
 {
     string orginalName = name;
     name = name.Replace(" ", "").ToLower();
     while (name.EndsWith(".")) name = name.Substring(0, name.Length - 1);
     Monitor.Enter(Commands);
     live.TheBotClient = this;
     CommandInstance prev;
     if (!Commands.TryGetValue(name, out prev))
     {
         CommandInstance command = new CommandInstance(live);
         Commands.Add(name, command);
         command.Name = orginalName;
         if (command.IsStateFul)
         {
             live.TheBotClient = this;
             command.WithBotClient = live;
         }
     }
     else
     {
         if (prev.CmdType != live.GetType())
         {
             RegisterCommand("!" + orginalName, live);
         }
     }
     Monitor.Exit(Commands);
 }
Пример #2
0
        public void RegisterType(string name, Cogbot.Actions.Command command)
        {
            string orginalName = name;
            name = name.Replace(" ", "").ToLower();
            while (name.EndsWith(".")) name = name.Substring(0, name.Length - 1);

            if (!groupActions.ContainsKey(name))
            {
                groupActions.Add(name, command.GetCmdInfo());
                command.Name = orginalName;
            }
            else
            {
                RegisterType("!" + orginalName, command);
            }
        }