private void Client_OnChannelMessage(object sender, IrcEventArgs e) { if (string.IsNullOrEmpty(e.Data.Message)) { return; } var from = new SenderDetails { Nickname = e.Data.Nick, Ident = e.Data.Ident, Hostname = e.Data.Host, }; var messageDetails = new MessageDetails(e.Data.Channel, from, e.Data.Message); lock ( monitorsLock ) { foreach (var monitor in registeredMonitors) { monitor.DoMessage(messageDetails); } } }
void MessageParser_ChannelMessage(object sender, IrcEventArgs e) { string msg = e.Data.Message; if (string.IsNullOrEmpty(msg)) { return; } string[] splits = msg.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (splits.Length == 0) { return; } string command = splits[0]; string[] args = splits.Skip(1).ToArray(); var from = new SenderDetails { Nickname = e.Data.Nick, Ident = e.Data.Ident, Hostname = e.Data.Host, }; // dumb skype relay related hack if (from.Ident == "~gib" && (from.Hostname == "me.the.steamgames.co" || from.Hostname == "2001:470:1f0f:4eb::4:1")) { command = splits.Skip(1) .FirstOrDefault(); args = splits .Skip(2) .ToArray(); if (string.IsNullOrEmpty(command)) { return; } var senderNick = splits[0]; if (senderNick.StartsWith("<") && senderNick.EndsWith(">")) { senderNick = senderNick.Substring(1, senderNick.Length - 2); } // turbo dirty from.Nickname = senderNick; } var triggeredCommand = RegisteredCommands .FirstOrDefault(c => c.Triggers.Any(t => string.Equals(command, t, StringComparison.OrdinalIgnoreCase))); if (triggeredCommand == null) { return; } Log.WriteInfo("CommandManager", "Handling command {0} from {1} in {2}", triggeredCommand.Triggers.First(), from, e.Data.Channel); triggeredCommand.DoRun(new CommandDetails { Trigger = command, Args = args, Sender = from, Channel = e.Data.Channel, }); }
void MessageParser_ChannelMessage( object sender, IrcEventArgs e ) { string msg = e.Data.Message; if ( string.IsNullOrEmpty( msg ) ) return; string[] splits = msg.Split( new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries ); if ( splits.Length == 0 ) return; string command = splits[ 0 ]; string[] args = splits.Skip( 1 ).ToArray(); var from = new SenderDetails { Nickname = e.Data.Nick, Ident = e.Data.Ident, Hostname = e.Data.Host, }; // dumb skype relay related hack if ( from.Ident == "~gib" && ( from.Hostname == "me.the.steamgames.co" || from.Hostname == "2001:470:1f0f:4eb::4:1" ) ) { command = splits.Skip( 1 ) .FirstOrDefault(); args = splits .Skip( 2 ) .ToArray(); if ( string.IsNullOrEmpty( command ) ) return; var senderNick = splits[ 0 ]; if ( senderNick.StartsWith( "<" ) && senderNick.EndsWith( ">" ) ) { senderNick = senderNick.Substring( 1, senderNick.Length - 2 ); } // turbo dirty from.Nickname = senderNick; } var triggeredCommand = RegisteredCommands .FirstOrDefault( c => c.Triggers.Any( t => string.Equals( command, t, StringComparison.OrdinalIgnoreCase ) ) ); if ( triggeredCommand == null ) return; Log.WriteInfo( "CommandManager", "Handling command {0} from {1} in {2}", triggeredCommand.Triggers.First(), from, e.Data.Channel ); triggeredCommand.DoRun( new CommandDetails { Trigger = command, Args = args, Sender = from, Channel = e.Data.Channel, } ); }
internal bool IsAdmin(SenderDetails sender) { return(IRCAdmins.Any(a => string.Equals(sender.Hostname, a, StringComparison.OrdinalIgnoreCase))); }
public MessageDetails(string channel, SenderDetails sender, string message) { this.Channel = channel; this.Sender = sender; this.Message = message; }