CmdTriggers trigger Commands. There are different kinds of triggers which are handled differently, according to where they came from.
コード例 #1
0
 public override void Process(CmdTrigger trigger)
 {
     try
     {
         var helpName = trigger.Args.NextWord().ToLower();
         if (!string.IsNullOrEmpty(helpName))
         {
             var cmd = HelpCommandsManager.Search(helpName);
             if (cmd != null)
             {
                 HelpCommandsManager.Delete(cmd);
                 trigger.Reply(string.Format("Deleted command HelpTrigger: {0} HelpText: {1}", cmd.HelpName, cmd.HelpText));
             }
             else
             {
                 trigger.Reply("No command was found with that name!");
             }
         }
         else
         {
             trigger.Reply("An error occured deleting the specified command, it appears that the command did not exist, please check and try again or report the error!");
         }
     }
     catch (Exception e)
     {
         UtilityMethods.Print(e.Message + e.Data + e.StackTrace, true);
     }
 }
コード例 #2
0
 public override void Process(CmdTrigger trigger)
 {
     try
     {
         var helpName = trigger.Args.NextWord().ToLower();
         var helpText = trigger.Args.Remainder;
         if(!string.IsNullOrEmpty(helpName) && !string.IsNullOrEmpty(helpText))
         {
             if (string.IsNullOrEmpty(Convert.ToString(HelpCommandsManager.Search(helpName))))
             {
                 HelpCommandsManager.Add(HelpCommand.CreateHelpCommand(helpName, helpText));
                 trigger.Reply(string.Format("Added new command HelpTrigger: {0} HelpText: {1}", helpName, helpText));
             }
             else
             {
                 trigger.Reply("That help trigger already exists, please delete it first!");
             }
         }
         else
         {
             trigger.User.Msg("An error occured adding the specified command, one of the values came out as null, please check and try again or report the error!");
         }
     }
     catch (Exception e)
     {
         UtilityMethods.Print(e.Message + e.Data + e.StackTrace, true);
     }
 }
コード例 #3
0
 public override void Process(CmdTrigger trigger)
 {
     try
     {
         string[] attacks = {
                                "slaps %s",
                                "kicks %s",
                                "punches %s in the face",
                                "stings %s with a needle",
                                "shoots %s with a phaser"
                            };
         if (!string.IsNullOrEmpty(trigger.Args.Remainder))
         {
             var rand = new Random();
             int randomchoice = rand.Next(0, 4);
             if (trigger.Channel != null && !trigger.Channel.HasUser(trigger.Args.Remainder))
             {
                 trigger.Reply("I can't find that person to attack them!");
                 return;
             }
             string attack = attacks[randomchoice].Replace("%s", trigger.Args.Remainder);
             JadBot.Irc.CommandHandler.Describe(trigger.Target, attack, trigger.Args);
         }
         else
         {
             trigger.Reply("You didnt give me a nick to attack!");
         }
     }
     catch (Exception e)
     {
         WriteErrorSystem.WriteError(e);
     }
 }
コード例 #4
0
 public override void Process(CmdTrigger trigger)
 {
     var user = trigger.User;
     if (user == null)
     {
         trigger.Reply("AuthCommand requires User-argument.");
     }
     else
     {
         if (user.IsAuthenticated)
         {
             trigger.Reply("User {0} is authed as: {1}", user.Nick, user.AuthName);
         }
         else
         {
             var authMgr = trigger.irc.AuthMgr;
             if (authMgr.IsResolving(user))
             {
                 trigger.Reply("User {0} is being resolved - Please wait...", user.Nick, user.AuthName);
             }
             else if (!authMgr.CanResolve)
             {
                 trigger.Reply("Authentication is not supported on this Network.");
             }
             else
             {
                 trigger.Reply("Resolving User...".Colorize(IrcColorCode.Red));
                 authMgr.ResolveAuth(user);
             }
         }
     }
 }
コード例 #5
0
ファイル: IrcCommands.cs プロジェクト: WCell/WCell-IrcAddon
        public override void Process(CmdTrigger<IrcCmdArgs> trigger)
        {
            var chan = trigger.Args.Channel;
            var voteChan = trigger.Text.NextWord();
            Vote vote;

            // If we have a channel given in the argument list
            if (voteChan.Length > 0)
                vote = Vote.GetVote(trigger.Args.IrcClient.GetChannel(voteChan));
            vote = Vote.GetVote(chan);

            if (vote != null)
            {

                trigger.Reply("The vote has ended!");
                trigger.Reply(VoteMgr.Mgr.Stats(vote));
                trigger.Reply(VoteMgr.Mgr.Result(vote));
                VoteMgr.Mgr.EndVote(vote);
                return;

            }

            else
            {
                Vote[] votesArray = new Vote[VoteMgr.Votes.Values.Count];
                VoteMgr.Votes.Values.CopyTo(votesArray, 0);
                foreach (var vte in votesArray)
                    VoteMgr.Mgr.EndVote(vte);
                trigger.Reply("Disposed of {0} vote[s].", votesArray.Length);
            }
        }
コード例 #6
0
 public override void Process(CmdTrigger trigger)
 {
     var nick = trigger.Args.NextWord();
     var messagetosend = trigger.Args.Remainder;
     if (string.IsNullOrEmpty(nick) || string.IsNullOrEmpty(messagetosend))
     {
         trigger.Reply("Failed to parse input, please try again");
     }
     else
     {
         using (var db = new UtilityBotDBContainer())
         {
             var msg = new Message
             {
                 DateLeft = DateTime.Now.ToString(),
                 FromIrcNick = trigger.User.Nick,
                 IrcNick = nick,
                 MessageText = messagetosend
             };
             db.Messages.AddObject(msg);
             db.SaveChanges();
             trigger.Reply("Message saved");
             return;
         }
     }
 }
コード例 #7
0
 public override void Process(CmdTrigger trigger)
 {
     try
     {
         string nextWord = trigger.Args.NextWord().ToLower();
         if (nextWord == "safe")
         {
             trigger.Reply("Safely shutting down WCell saving data and Starting it up again");
             var prog = new Process
             {
                 StartInfo = { FileName = @"c:\wcellupdater.exe", Arguments = @"c:\wcellsource\run\ c:\run\ debug\" }
             };
             prog.Start();
         }
         if (nextWord == "utility")
         {
             trigger.Reply("Restarting Utility - If there is no auto restarter the utility will not return");
             JadBot.Parser.Kill();
             var restartbat = new StreamWriter("Restartbat.bat") {AutoFlush = true};
             restartbat.WriteLine("taskkill /F /IM jad_bot.exe");
             restartbat.WriteLine("start " + JadBot.Utility.StartInfo.FileName);
             var cmd = new Process {StartInfo = {FileName = "cmd.exe", Arguments = "start RestartBat.bat"}};
             cmd.Start();
         }
     }
     catch (Exception e)
     {
         WriteErrorSystem.WriteError(e);
     }
 }
コード例 #8
0
 public override void Process(CmdTrigger trigger)
 {
     var username = trigger.Args.NextWord();
     var userlevel = trigger.Args.NextWord().ToLower();
     if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(userlevel))
     {
         trigger.Reply("Invalid input please try again!");
     }
     else
     {
         if (!ValidateUserLevel(userlevel))
         {
             trigger.Reply("Invalid userlevel specified, options are guest,user,admin");
             return;
         }
         using (var db = new UtilityBotDBContainer())
         {
             foreach (var account in Queryable.Where(db.Accounts, account => account.Username == username))
             {
                 account.UserLevel = userlevel;
                 trigger.Reply("Account level changed to " + userlevel);
                 db.SaveChanges();
                 return;
             }
         }
     }
 }
コード例 #9
0
ファイル: Parser.cs プロジェクト: jaddie/WCell-Utility-Bot
 public override void Process(CmdTrigger trigger)
 {
     try
     {
         string filename = trigger.Args.NextWord();
         string httpLink = trigger.Args.Remainder;
         if(string.IsNullOrEmpty(filename) || string.IsNullOrEmpty(httpLink))
         {
             trigger.Reply("Error, invalid arguements try @help downloadlog");
             return;
         }
         trigger.Reply("Attempting to download log from {0} and save in unparsed folder as {1}", httpLink,
                       filename);
         var client = new WebClient();
         client.DownloadFile(httpLink, JadBot.UnparsedFolder + filename);
         using (var downloadedfile = new StreamReader(JadBot.UnparsedFolder + filename))
         {
             if (downloadedfile.BaseStream.Length < 1)
             {
                 trigger.Reply("The downloaded file looks empty, are you sure your link is valid?");
             }
             else
             {
                 trigger.Reply(
                     "Download complete file is saved in the unparsed logs folder as {0} you can now use the parse command on it.",
                     filename);
             }
         }
     }
     catch (Exception e)
     {
         WriteErrorSystem.WriteError(e);
     }
 }
コード例 #10
0
 public static void AddAccount(CmdTrigger trigger, string username, string password, string userlevel)
 {
     using (var db = new UtilityBotDBContainer())
     {
         var account = new Account { Username = username, Password = password, UserLevel = userlevel };
         db.Accounts.AddObject(account);
         db.SaveChanges();
     }
 }
コード例 #11
0
 public override void Process(CmdTrigger trigger)
 {
     try
     {
         trigger.Reply("http://wiki.wcell.org/index.php/WCell_API");
     }
     catch (Exception)
     {
         //None
     }
 }
コード例 #12
0
 public override void Process(CmdTrigger trigger)
 {
     try
     {
         trigger.Reply("If you have a picture you like show us or perhaps a file you want to send us .rar it and upload to http://bayimg.com/ and show us the link.");
     }
     catch (Exception e)
     {
         WriteErrorSystem.WriteError(e);
     }
 }
コード例 #13
0
 public override void Process(CmdTrigger trigger)
 {
     try
     {
         trigger.Reply(
             "AreaTriggers \n GOs \n Items \n NPCs \n Quests \n SpellsAndEffects \n Vehicles \n use these for the dumptype on the query command!");
     }
     catch (Exception e)
     {
         WriteErrorSystem.WriteError(e);
     }
 }
コード例 #14
0
 public override void Process(CmdTrigger trigger)
 {
     try
     {
         string searchTerm = trigger.Args.Remainder.Replace(" ", "%20");
         trigger.Reply("http://thepiratebay.org/search/" + searchTerm + "/0/7/0");
     }
     catch (Exception e)
     {
         WriteErrorSystem.WriteError(e);
     }
 }
コード例 #15
0
            //~find World.ReSync
            public override void Process(CmdTrigger trigger)
            {
                try
                {
                    trigger.Reply("Hai, I don't work yet! :O");

                }
                catch (Exception e)
                {
                    WriteErrorSystem.WriteError(e);
                }
            }
コード例 #16
0
 public override void Process(CmdTrigger trigger)
 {
     try
     {
         var lines = trigger.Irc.Client.SendQueue.Length;
         trigger.Irc.Client.SendQueue.Clear();
         trigger.Reply("Cleared SendQueue of {0} lines", lines);
     }
     catch (Exception e)
     {
         WriteErrorSystem.WriteError(e);
     }
 }
コード例 #17
0
 public override void Process(CmdTrigger trigger)
 {
     try
     {
         var norris = new StreamWriter("LinusFacts.txt", true) { AutoFlush = false };
         norris.WriteLine(trigger.Args.Remainder);
         trigger.Reply("Added the new Linus Torvalds fact: {0} to storage", trigger.Args.Remainder);
         norris.Close();
     }
     catch (Exception e)
     {
         WriteErrorSystem.WriteError(e);
     }
 }
コード例 #18
0
 public override void Process(CmdTrigger<IrcCmdArgs> trigger)
 {
     string word = trigger.Text.NextWord();
     string target = trigger.Text.NextWord();
     if (word.Equals("-u"))
     {
         TimeSpan time = TimeSpan.FromSeconds(trigger.Text.NextInt());
         trigger.Args.IrcClient.CommandHandler.Ban(target, time, trigger.Text.RemainingWords());
     }
     else
     {
         trigger.Args.IrcClient.CommandHandler.Ban(target, trigger.Text.RemainingWords());
     }
 }
コード例 #19
0
 public override void Process(CmdTrigger trigger)
 {
     try
     {
         using (var norris = new StreamWriter("ChuckNorrisFacts.txt", true))
         {
             norris.WriteLine(trigger.Args.Remainder);
             trigger.Reply("Added the new Chuck Norris fact: {0} to storage", trigger.Args.Remainder);
         }
     }
     catch (Exception e)
     {
         WriteErrorSystem.WriteError(e);
     }
 }
コード例 #20
0
            public override void Process(CmdTrigger trigger)
            {
                try
                {
                    int fahrenheit = Convert.ToInt32(trigger.Args.Remainder.Trim());
                    int celsius = (fahrenheit - 32) * 5 / 9;
                    int kelvin = (fahrenheit + 459) * 5 / 9;

                    trigger.Reply(trigger.Args.Remainder + " Fahrenheit is , " + celsius + "C , " + kelvin + " Kelvin");
                }
                catch (Exception e)
                {
                    trigger.Reply(e.ToString());
                }
            }
コード例 #21
0
            public override void Process(CmdTrigger trigger)
            {
                try
                {
                    int celsius = Convert.ToInt32(trigger.Args.Remainder.Trim());
                    int fahrenheit = (celsius * 9 / 5) + 32;
                    int kelvin = celsius + 273;

                    trigger.Reply(trigger.Args.Remainder + " Celsius is , " + fahrenheit + "F , " + kelvin + " Kelvin");
                }
                catch (Exception e)
                {
                    trigger.Reply(e.ToString());
                }
            }
コード例 #22
0
 public override void Process(CmdTrigger trigger)
 {
     try
     {
         string target = trigger.Target.ToString();
         if (trigger.Args.NextModifiers() == "target")
         {
             target = trigger.Args.NextWord();
         }
         JadBot.Irc.CommandHandler.Describe(target, trigger.Args.Remainder, trigger.Args);
     }
     catch (Exception e)
     {
         trigger.Reply("I cant write that action, perhaps invalid target?");
         trigger.Reply(e.Message);
         WriteErrorSystem.WriteError(e);
     }
 }
コード例 #23
0
ファイル: trac.cs プロジェクト: jaddie/WCell-Notifier
 public override void Process(CmdTrigger trigger)
 {
     try
     {
         string reply = "";
         foreach (var value in TracBackend.GetTicket(trigger.Args.NextInt(1)))
         {
             reply += value;
             reply += "   ";
         }
         reply = reply.Replace("\n", " ");
         reply = reply.Replace("\r", " ");
         trigger.Reply(reply);
     }
     catch (Exception e)
     {
         // Error handling
     }
 }
コード例 #24
0
 public override void Process(CmdTrigger trigger)
 {
     try
     {
         var linusLines = new List<string>();
         var linus = new StreamReader("LinusFacts.txt");
         while (!linus.EndOfStream)
         {
             linusLines.Add(linus.ReadLine());
         }
         var rand = new Random();
         int randnum = rand.Next(0, linusLines.Count - 1);
         trigger.Reply(linusLines[randnum]);
         linus.Close();
     }
     catch (Exception e)
     {
         WriteErrorSystem.WriteError(e);
     }
 }
コード例 #25
0
 public override void Process(CmdTrigger trigger)
 {
     try
     {
         string target = trigger.Target.ToString();
         if (trigger.Args.NextModifiers() == "target")
         {
             target = trigger.Args.NextWord();
         }
         if(!string.IsNullOrEmpty(trigger.Args.Remainder))
         trigger.Irc.CommandHandler.Describe(target, trigger.Args.Remainder, trigger.Args);
         else
         trigger.Reply("Empty action");
     }
     catch (Exception e)
     {
         trigger.Reply("I cant write that action, perhaps invalid target?");
         trigger.Reply(e.Message);
         UtilityMethods.Print(e.Message + e.Data + e.StackTrace, true);
     }
 }
コード例 #26
0
ファイル: trac.cs プロジェクト: jaddie/WCell-Notifier
 public override void Process(CmdTrigger trigger)
 {
     try
     {
         string summary = "", description = "";
         PageAttributes attributes = new PageAttributes();
         bool notify = false;
         while (trigger.Args.HasNext)
         {
             var next = trigger.Args.NextModifiers();
             switch (next)
             {
                 case "s":
                 case "summary":
                     summary = trigger.Args.NextWord("\"");
                     break;
                 case "d":
                 case "description":
                     description = trigger.Args.NextWord("\"");
                     break;
                 case "a":
                 case "attr":
                     attributes.comment = trigger.Args.NextWord("\"");
                     break;
                 case "n":
                 case "notify":
                     notify = Convert.ToBoolean(trigger.Args.NextWord());
                     break;
                 default:
                     Console.WriteLine(trigger.Args.NextWord("\""));
                     break;
             }
         }
         trigger.Reply(TracBackend.CreateTicket(summary, description, attributes, notify));
     }
     catch (Exception e)
     {
         // Error handling
     }
 }
コード例 #27
0
 public override void Process(CmdTrigger trigger)
 {
     //trigger.Reply(IrcClient.Version);
     AssemblyName asmName = Assembly.GetAssembly(GetType()).GetName();
     trigger.Reply(asmName.Name + ", v" + asmName.Version);
 }
コード例 #28
0
 public override void Process(CmdTrigger trigger)
 {
     trigger.Irc.CommandHandler.Unban(trigger.Args.NextWord(), trigger.Args.RemainingWords());
 }
コード例 #29
0
 public override void Process(CmdTrigger trigger)
 {
     var chan = trigger.Channel;
     if (chan == null)
     {
         chan = trigger.irc.GetChannel(trigger.Args.NextWord());
         if (chan == null)
         {
             trigger.Reply("Invalid Channel.");
             return;
         }
     }
     chan.Topic = trigger.Args.Remainder;
 }
コード例 #30
0
 public override void Process(CmdTrigger trigger)
 {
     trigger.Irc.UserName = trigger.Args.NextWord();
 }