本文整理汇总了C#中Squishy.Irc.Commands.CmdTrigger类的典型用法代码示例。如果您正苦于以下问题:C# CmdTrigger类的具体用法?C# CmdTrigger怎么用?C# CmdTrigger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CmdTrigger类属于Squishy.Irc.Commands命名空间,在下文中一共展示了CmdTrigger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Process
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: Process
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);
}
}
示例3: Process
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);
}
}
}
}
示例4: Process
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);
}
}
示例5: Process
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;
}
}
}
示例6: Process
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);
}
}
示例7: Process
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;
}
}
}
}
示例8: Process
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);
}
}
示例9: AddAccount
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();
}
}
示例10: Process
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);
}
}
示例11: Process
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);
}
}
示例12: Process
//~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);
}
}
示例13: Process
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);
}
}
示例14: Process
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());
}
}
示例15: Process
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);
}
}