private void Client_PrivateMessageRecieved(object sender, ChatSharp.Events.PrivateMessageEventArgs e) { if (e.PrivateMessage.IsChannelMessage) { Console.WriteLine("{0}: <{1}> {2}", e.PrivateMessage.Source, e.PrivateMessage.User.Nick, e.PrivateMessage.Message); } else { Console.WriteLine("*{0}: <{1}> {2}", e.PrivateMessage.Source, e.PrivateMessage.User.Nick, e.PrivateMessage.Message); } /* * if (e.PrivateMessage.Message.ToLower().Contains("list")) * { * * * foreach (IrcChannel c in client.Channels) * { * Console.WriteLine(c.Name); * } * } */ Interpreter(e); }
private void stringSaveMessage(ChatSharp.Events.PrivateMessageEventArgs e) { try { using (var DB = new internetEntities()) { irkki testRow = new irkki { viesti = e.PrivateMessage.Message, nick = e.PrivateMessage.User.Nick, kanava = e.PrivateMessage.Source, aika = DateTime.Now, maara = 1 }; DB.irkki.Add(testRow); DB.SaveChanges(); } } catch (Exception eip) { try { using (var DB = new internetEntities()) { DB.logs.Add(new logs { message = e.ToString(), severity = 1 }); DB.SaveChanges(); } } catch (Exception se) { } } }
private void Interpreter(ChatSharp.Events.PrivateMessageEventArgs e) { // Console.WriteLine("Interpreting..."); Command tempCommand = new Command(); if (!CheckIgnore(e.PrivateMessage.User.Nick, e.PrivateMessage.User.Hostname)) { tempCommand.channelMessage = e.PrivateMessage.IsChannelMessage; if (e.PrivateMessage.IsChannelMessage) { tempCommand.chanOp = CheckMode(e.PrivateMessage.User.ChannelModes[client.Channels[e.PrivateMessage.Source]].ToString()); tempCommand.channel = config.channels[e.PrivateMessage.Source]; } tempCommand.source = e.PrivateMessage.Source; // Console.WriteLine(e.PrivateMessage.User.Nick); // Console.WriteLine(e.PrivateMessage.User.Hostname); // tempCommand.user.nick = e.PrivateMessage.User.Nick.ToString(); // tempCommand.user.hostName = e.PrivateMessage.User.Hostname; tempCommand.nick = e.PrivateMessage.User.Nick; tempCommand.message = e.PrivateMessage.Message; tempCommand.hostName = e.PrivateMessage.User.Hostname; tempCommand.admin = CheckAdmin(tempCommand.nick, tempCommand.hostName); // Console.WriteLine("blah"); tempCommand = parseCommand(tempCommand, e.PrivateMessage.Message); // Console.WriteLine("Success?"); if (tempCommand.commandFound) { ThreadStart processTaskThread = delegate { ExecuteCommand(tempCommand); }; new Thread(processTaskThread).Start(); } else { foreach (string key in prefExplain.Keys) { if (CommandLibrary.DyanmicCheckInline(key, tempCommand)) { ThreadStart processTaskThread = delegate { ExecuteCommand(tempCommand); }; new Thread(processTaskThread).Start(); } } } } // General stuff down here, like 'doot' or youtube commands // Actually no, find a better way or something }
private void OnMessageReceived(object sender, ChatSharp.Events.PrivateMessageEventArgs e) { lock (this) { var channel = this.client.Channels[e.PrivateMessage.Source]; var message = e.PrivateMessage.Message; var idx = message.IndexOf(this.nick + " "); if (idx == 0) { message = message.Substring(this.nick.Length + 1); var commandEnd = message.IndexOf(' '); if (commandEnd != -1 && this.handlers.TryGetValue(message.Substring(0, commandEnd).ToLowerInvariant(), out var handler)) { handler(channel, message.Substring(commandEnd + 1)); } } } }
protected virtual void MessageReceived(object sender, ChatSharp.Events.PrivateMessageEventArgs e) { }
void Client_UserMessageRecieved(object sender, ChatSharp.Events.PrivateMessageEventArgs e) { this.MessageReceived(sender, e); this.PrivateMessageReceived(sender, e); }