本文整理汇总了C#中Meebey.SmartIrc4net.IrcEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# IrcEventArgs类的具体用法?C# IrcEventArgs怎么用?C# IrcEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IrcEventArgs类属于Meebey.SmartIrc4net命名空间,在下文中一共展示了IrcEventArgs类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ExecuteMethodFromRegex
public void ExecuteMethodFromRegex(IrcEventArgs e)
{
if(isRunning==true)
{
SendUnscramble(e);
}
foreach(KeyValuePair<string,string> pair in regexDictionary)
{
regex = new Regex(pair.Key);
if(regex.IsMatch(e.Data.Message))
{
string methodName = pair.Value;
//Get the method information using the method info class
MethodInfo mi = this.GetType().GetMethod(methodName);
object[] objargs = new object[1];
objargs[0]=e;
// //Invoke the method
// // (null- no paramyeseter for the method call
// // or you can pass the array of parameters...)
if(mi==null)
{
//client.SendMessage(SendType.Message, e.Data.Channel,"mi is null! "+e.Data.Message);
SharpBotClient.SharpBotClient.SendChannelMessag(e.Data.Channel,"handled from client");
}
else
{
mi.Invoke(this,objargs);
}
}
}
}
开发者ID:drewlander,项目名称:SharpBot,代码行数:33,代码来源:WordScrambler.cs
示例2: Execute
public override IEnumerable<string> Execute(IrcEventArgs e)
{
string args = "";
if (e.Data.MessageArray.Length > 1)
args = string.Join(" ", e.Data.MessageArray.Skip(1));
args = args.Replace("\'", "");
args = args.Replace(">", "");
args = args.Replace("<", "");
args = args.Replace("|", "");
try
{
var proc = new System.Diagnostics.Process();
proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = @"python";
proc.StartInfo.Arguments = scriptPath + " \"" + args + "\"";
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.WorkingDirectory = Directory.GetCurrentDirectory();
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.StandardOutputEncoding = Encoding.UTF8;
proc.Start();
string data = proc.StandardOutput.ReadToEnd();
proc.WaitForExit();
return new[] {data};
}
catch
{
}
return null;
}
开发者ID:Crobol,项目名称:Bot,代码行数:35,代码来源:PythonScriptCommand.cs
示例3: GetMatch
protected Match GetMatch(MessageType type, IrcEventArgs args)
{
string msg = args.Data.Message;
if (!msg.StartsWith(Prefix)) {
return null;
}
msg = msg.Substring(Prefix.Length);
var match = Attribute.Regex.Match(msg);
if (Attribute.Type != MessageType.All && Attribute.Type != type) {
return null;
}
if (!args.Data.Message.StartsWith(Prefix)) {
return null;
}
if (!match.Success) {
return null;
}
return match;
}
开发者ID:tgiphil,项目名称:SmartIrcBot4net,代码行数:26,代码来源:Command.cs
示例4: Execute
public override void Execute(IrcEventArgs args)
{
string nick = args.Data.Nick;
string fullName = args.Data.From;
if (args.Data.MessageArray.Length == 1)
{
PrintCommands(Bot.Commands, nick);
if (Bot.AdminUserRepository.IsAdminUser(fullName))
PrintCommands(Bot.AdminCommands, nick);
return;
}
if (args.Data.MessageArray.Length == 2)
{
if (!Bot.PluginManager.Plugins.Any(x => string.Equals(x.Name, args.Data.MessageArray[1], StringComparison.CurrentCultureIgnoreCase)))
throw new Exception(string.Format("Could not find the plugin with the name '{0}'",args.Data.MessageArray[1]));
BotPlugin plugin = Bot.PluginManager.Plugins.Find(x => string.Equals(x.Name, args.Data.MessageArray[1]));
PrintCommands(plugin.Commands, nick);
if (Bot.AdminUserRepository.IsAdminUser(fullName))
PrintCommands(plugin.AdminCommands, nick);
return;
}
throw new Exception("I'm not 100% sure what you were getting at by feeding me a ton of parameters...i'm just going to choke.");
}
开发者ID:krishemenway,项目名称:IrcBot,代码行数:32,代码来源:HelpCommand.cs
示例5: Execute
public override void Execute(IrcEventArgs e)
{
if (e.Data.MessageArray.Count() < 3)
{
e.Data.Irc.SendMessage(SendType.Message, e.Data.Nick, "Missing parameters");
return;
}
User user = userService.GetAuthenticatedUser(e.Data.From);
if (user != null && user.UserLevel == 10)
{
int userLevel = 1;
if (e.Data.MessageArray.Count() > 3)
int.TryParse(e.Data.MessageArray[3], out userLevel);
if (userService.CreateUser(e.Data.MessageArray[1], e.Data.MessageArray[2], userLevel) > 0)
{
e.Data.Irc.SendMessage(SendType.Message, e.Data.Nick, "User created");
}
else
{
e.Data.Irc.SendMessage(SendType.Message, e.Data.Nick, "User already exists");
}
}
else
{
e.Data.Irc.SendMessage(SendType.Message, e.Data.Nick, "You do not have authorization to use this command");
return;
}
}
开发者ID:pluraldj,项目名称:Bot,代码行数:31,代码来源:UserServiceCommands.cs
示例6: ProcessMessage
public override void ProcessMessage(IrcEventArgs e)
{
if (e.Data.MessageArray[0] == "!resetBlackjack")
{
Reset();
return;
}
if (CurrentState == States.NO_GAME && (e.Data.MessageArray[0]=="!jack" || e.Data.MessageArray[0] == "!blackjack"))
{
//start new game
currentPlayer = e.Data.Nick;
Deal();
CurrentState = States.CARDS_DEALT;
TellPlayerOfHands();
}
else if (CurrentState == States.CARDS_DEALT && e.Data.Nick == currentPlayer)
{
ParseCommand(e);
}
}
开发者ID:hissbot,项目名称:ChatBot,代码行数:25,代码来源:BlackjackModule.cs
示例7: OnMessage
public static void OnMessage(object sender, IrcEventArgs e)
{
string[] foulwords = new string[1];
Console.ForegroundColor = ConsoleColor.Yellow;
//highlighting
if (e.Data.Message.Contains(Config.User) == true)
{
Console.ForegroundColor = ConsoleColor.Green;
System.Console.WriteLine(e.Data.From + " : " + e.Data.Message);
}
else if (e.Data.From.Contains(Config.User) == true)
{
Console.ForegroundColor = ConsoleColor.Red;
System.Console.Write(e.Data.From + ": ");
Console.ResetColor();
Console.Write(e.Data.Message + "\n");
}
else if (foulwords.Any(p => e.Data.Message.Contains(p)))
{
Console.ForegroundColor = ConsoleColor.Red;
System.Console.Write(e.Data.From + ": ");
Console.ResetColor();
Console.Write(e.Data.Message + "\n");
}
else
{
System.Console.Write(e.Data.From + ": ");
Console.ResetColor();
Console.Write(e.Data.Message + "\n");
}
}
开发者ID:nnaricom,项目名称:osuchat,代码行数:33,代码来源:Program.cs
示例8: Execute
public override void Execute(IrcEventArgs e)
{
string message = "";
// If parameter is given, show help message of command <parameter>
if (e.Data.MessageArray.Count() > 1 && commands.ContainsKey(commandIdentifier + e.Data.MessageArray[1]))
message = commands[commandIdentifier + e.Data.MessageArray[1]].Name + ": " + commands[commandIdentifier + e.Data.MessageArray[1]].Help;
else
{
// Else list available commands
message = "Available commands: ";
foreach (ICommand command in commands.Values.Distinct())
{
message += command.Name;
if (command.Aliases != null)
message += " (" + string.Join(", ", command.Aliases) + ")";
if (command != commands.Values.Last())
message += ", ";
}
}
e.Data.Irc.SendMessage(SendType.Message, e.Data.Channel, message);
}
开发者ID:pluraldj,项目名称:Bot,代码行数:25,代码来源:Help.cs
示例9: Worker
protected override CommandCompletedEventArgs Worker(IrcEventArgs e)
{
Thread.Sleep(3000);
e.Data.Irc.SendMessage(SendType.Message, e.Data.Channel, "Async wait done");
return null;
}
开发者ID:pluraldj,项目名称:Bot,代码行数:7,代码来源:SyncVsAsync.cs
示例10: Execute
public override void Execute(IrcEventArgs args)
{
var message = args.Data.MessageArray;
var channel = args.Data.Channel;
var nick = args.Data.Nick;
List<QuestionSet> sets = new List<QuestionSet>();
if(message.Length > 2)
{
for(int i = 2;i < message.Length;i++)
{
int i1 = i;
QuestionSet questionSetToFind = TriviaPlugin.QuestionSets.Find(x => x.QuestionSetName.StartsWith(message[i1]));
if(questionSetToFind != null)
{
sets.Add(questionSetToFind);
}
}
}
if (!TriviaPlugin.Games.ContainsKey(channel))
{
TriviaPlugin.Games.Add(channel,
sets.Count > 0 ? new TriviaGame(TriviaPlugin, channel, sets) : new TriviaGame(TriviaPlugin, channel));
}
TriviaPlugin.Games[channel].StartGame(nick);
}
开发者ID:krishemenway,项目名称:IrcBot,代码行数:29,代码来源:StartGameCommand.cs
示例11: Execute
public override void Execute(IrcEventArgs args)
{
string destination = string.Empty;
ChannelList channelList = new ChannelList();
AddChannelsFromMessage(args.Data.MessageArray, channelList);
if(args.Data.Type == ReceiveType.QueryMessage)
{
if (channelList.Count == 0)
{
var channels = TaskListPlugin.Repository.GetChannels();
channelList.AddRange(channels);
}
destination = args.Data.Nick;
} else if(args.Data.Type == ReceiveType.ChannelMessage)
{
var channel = args.Data.Channel;
if(channelList.Count == 0)
{
channelList.Add(channel);
}
destination = channel;
}
foreach (var channel in channelList)
{
ShowTaskListForChannel(channel, destination);
}
}
开发者ID:krishemenway,项目名称:IrcBot,代码行数:32,代码来源:ShowTaskListsCommand.cs
示例12: Execute
public override void Execute(IrcEventArgs args)
{
var channel = args.Data.Channel;
var user = args.Data.Nick;
string madeNewTaskList = string.Empty;
if(args.Data.MessageArray.Length < 3)
throw new Exception("Not enough parameters supplied for command.");
var taskListName = GetTaskListName(args.Data.MessageArray);
string taskText = string.Empty;
for(int i = 2;i < args.Data.MessageArray.Length; i++)
taskText += string.Format(" {0}", args.Data.MessageArray[i]);
TaskList list = TaskListPlugin.Repository.GetTaskList(taskListName);
if(list == null)
{
// todo interface out a concept for default status
list = TaskListPlugin.Repository.CreateNewTaskList(taskListName, user, channel,string.Empty);
madeNewTaskList = "new";
}
Task newTask = list.NewTask(taskText, user);
TaskListPlugin.SendMessage(string.Format("Added task to {0} TaskList {1} ({2} / {3} completed)",madeNewTaskList, list.TaskName, list.CompletedTasks(),list.Tasks.Count), channel);
}
开发者ID:krishemenway,项目名称:IrcBot,代码行数:27,代码来源:NewTaskCommand.cs
示例13: Execute
public override void Execute(IrcEventArgs args)
{
List<QuestionSet> questionSets = new List<QuestionSet>();
var questionSetNodes = TriviaPlugin.PluginSettings.SelectNodes(QuestionSetXPath);
if(questionSetNodes == null)
throw new Exception("Could not find any question sets in Settings config");
foreach (XmlNode node in questionSetNodes)
{
string filePath = TriviaPlugin.Bot.FilePath + node.InnerText;
if (!string.IsNullOrEmpty(node.InnerText) && File.Exists(filePath))
{
string questonSetName;
if (node.Attributes[QuestionSetNameAttributeName] != null
&& !string.IsNullOrEmpty(node.Attributes[QuestionSetNameAttributeName].Value))
{
questonSetName = node.Attributes[QuestionSetNameAttributeName].Value;
}
else
{
questonSetName = node.InnerText;
}
QuestionSet set = new QuestionSet(filePath) { QuestionSetName = questonSetName };
questionSets.Add(set);
}
}
TriviaPlugin.QuestionSets = questionSets;
}
开发者ID:krishemenway,项目名称:IrcBot,代码行数:34,代码来源:LoadQuestionsCommand.cs
示例14: ShouldExecuteCommand
public override bool ShouldExecuteCommand(IrcEventArgs args)
{
var currentGame = TriviaPlugin.GetGameForChannel(args.Data.Channel);
return base.ShouldExecuteCommand(args)
&& currentGame != null && currentGame.CurrentState != GameState.Started;
}
开发者ID:krishemenway,项目名称:IrcBot,代码行数:7,代码来源:ResumeGameCommand.cs
示例15: Execute
public override IEnumerable<string> Execute(IrcEventArgs e)
{
string nick = "";
string message = "";
if (e.Data.MessageArray.Count() > 1)
{
nick = e.Data.MessageArray[1];
}
else
{
nick = store.GetUserSetting<string>(e.Data.Nick, "LastfmUsername");
if (string.IsNullOrWhiteSpace(nick))
nick = e.Data.Nick;
}
log.Info("Fetching now playing information for user \"" + nick + "\"");
try
{
message = FetchNowPlayingInfo(nick);
}
catch (Exception)
{
return new string[0];
}
return new[] { message };
}
开发者ID:Crobol,项目名称:Bot,代码行数:30,代码来源:NowPlaying.cs
示例16: banned_word_check
public static void banned_word_check(object sender, IrcEventArgs e)
{
if (badwords.Contains(e.Data.Message))
{
if (InDB(e.Data.Nick, settings.serverlist, e.Data.Channel) == false)
{
int i = rng.Next(kickreasons.Length + 1);
InsertEntry(e.Data.Nick, settings.serverlist, e.Data.Channel);
irc.RfcKick(e.Data.Channel, e.Data.Nick, kickreasons[i]);
}
else
{
if (GetKicks(e.Data.Nick, e.Data.Channel, settings.serverlist) >= 5) //ban nick if kicked 5 times.
{
irc.Ban(e.Data.Channel, e.Data.Host);
irc.RfcKick(e.Data.Channel, e.Data.Nick, "banned");
}
else
{
int i = rng.Next(kickreasons.Length + 1);
irc.RfcKick(e.Data.Channel, e.Data.Nick, kickreasons[i]);
UpdateKicks(e.Data.Nick, settings.serverlist, e.Data.Channel);
}
}
}
}
开发者ID:orcmaster112,项目名称:ircbot4wowps,代码行数:29,代码来源:Filter.cs
示例17: Worker
protected override CommandCompletedEventArgs Worker(IrcEventArgs e)
{
string url = "http://tyda.se/search?form=1&w=" + e.Data.Message.Split(new char[] { ' ' }, 2).LastOrDefault(); // TODO: URL encode
string html = HtmlHelper.GetFromUrl(url);
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(html);
HtmlNodeCollection foundNodes = doc.DocumentNode.SelectNodes("//div [@class = 'tyda_content']/descendant::table [@class = 'tyda_res_body']/descendant::table [starts-with(@class, 'tyda_res_body_trans')]/descendant::a [starts-with(@id, 'tyda_trans')]");
string message;
if (foundNodes != null && foundNodes.Count > 0)
{
StringBuilder sb = new StringBuilder();
sb.Append("Translate: ");
IEnumerable<HtmlNode> nodes = foundNodes.Take(4);
foreach (HtmlNode node in nodes)
{
if (!string.IsNullOrWhiteSpace(node.InnerText))
{
sb.Append(node.InnerText);
if (node != nodes.Last())
sb.Append(", ");
}
}
message = sb.ToString();
}
else
message = "No results found";
return new CommandCompletedEventArgs(e.Data.Channel, new List<string> { message });
}
开发者ID:pluraldj,项目名称:Bot,代码行数:32,代码来源:Tyda.cs
示例18: ExecuteCommands
public void ExecuteCommands(IrcEventArgs ircEventArgs, List<IBotCommand> commands)
{
foreach (IBotCommand command in commands)
{
bool shouldExecuteCommand = false;
try
{
shouldExecuteCommand = command.ShouldExecuteCommand(ircEventArgs);
}
catch (Exception e)
{
SendMessage(string.Format("Command threw and exception: {0}", e.Message), ircEventArgs.Data.Nick);
}
if (shouldExecuteCommand)
{
try
{
command.Execute(ircEventArgs);
}
catch (Exception e)
{
SendMessage(e.Message, ircEventArgs.Data.Nick);
PrintHelpSyntaxForCommand(ircEventArgs, command);
}
}
}
}
开发者ID:krishemenway,项目名称:IrcBot,代码行数:30,代码来源:IrcBotService.cs
示例19: Client_OnQueryMessage
void Client_OnQueryMessage(object sender, IrcEventArgs e)
{
using (var context = new DataContext())
{
switch (e.Data.Type)
{
case ReceiveType.Join:
Client.RfcNotice(e.Data.Nick, "Hi, I am a IRC bot written in C# that executes code with Roslyn.");
Client.RfcNotice(e.Data.Nick, "To try me out, send me a private message with the following: var hello = \"hello world\"; return hello;");
Client.RfcNotice(e.Data.Nick, "You can also execute multi-line commands by starting the line with \">>\" remember to have a return statement in your last command");
break;
case ReceiveType.ChannelMessage:
if ((e.Data.Type == ReceiveType.ChannelMessage && e.Data.Message.StartsWith(BotSettings.Default.Name) && e.Data.Message.Length > BotSettings.Default.Name.Length) || (e.Data.Message.StartsWith(">>") && e.Data.Message.Length > 4))
{
var queryCommand = e.Data.Message.Substring(string.Format(BotSettings.Default.Name).Length + 1).Trim();
ProcessCommand(e, context, queryCommand);
}
break;
case ReceiveType.QueryMessage:
var channelCommand = e.Data.Message;
ProcessCommand(e, context, channelCommand);
break;
}
}
}
开发者ID:fekberg,项目名称:C--Smorgasbord,代码行数:26,代码来源:Bot.cs
示例20: Load
public static bool Load(string trigger, IrcEventArgs e, out IrcTrigger ircTrigger)
{
ircTrigger = new IrcTrigger();
Regex regex = new Regex(string.Format(triggerFormat, trigger), RegexOptions.IgnoreCase);
Match m = regex.Match(e.Data.Message);
if(m.Success)
{
ircTrigger.Channel = e.Data.Channel;
ircTrigger.Nick = e.Data.Nick;
ircTrigger.Host = e.Data.Host;
ircTrigger.Message = m.Groups["args"].Value;
ircTrigger.Arguments =
(ircTrigger.Message.Length > 0 ?
ircTrigger.Message.Split(new char[] { ' ' }) :
new string[0]
);
ircTrigger.Trigger = m.Groups["trigger"].Value;
return true;
}
return false;
}
开发者ID:BauerUK,项目名称:WorldCupBot,代码行数:25,代码来源:IrcTrigger.cs
注:本文中的Meebey.SmartIrc4net.IrcEventArgs类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论