private bool Part(string source, string parameters, string value) { string chan = parameters; chan = chan.Replace(" ", ""); string user = source.Substring(0, source.IndexOf("!")); string _ident; string _host; if (chan == config.DebugChan && instance.Nick != core.irc.NickName) { return(true); } _host = source.Substring(source.IndexOf("@") + 1); _ident = source.Substring(source.IndexOf("!") + 1); _ident = _ident.Substring(0, _ident.IndexOf("@")); config.channel channel = core.getChannel(chan); User us = new User(user, _host, _ident); if (channel != null) { lock (Module.module) { foreach (Module module in Module.module) { if (!module.working) { continue; } try { module.Hook_Part(channel, us); } catch (Exception fail) { core.handleException(fail); } } } User delete = null; if (channel.containsUser(user)) { lock (channel.UserList) { foreach (User User in channel.UserList) { if (User.Nick == user) { delete = User; break; } } channel.UserList.Remove(delete); } return(true); } return(true); } return(false); }
private bool ParseUser(string[] code) { if (code.Length > 8) { if (code[3] == config.DebugChan && instance.Nick != core.irc.NickName) { return(true); } config.channel channel = core.getChannel(code[3]); string ident = code[4]; string host = code[5]; string nick = code[7]; string server = code[6]; char mode = '\0'; if (code[8].Length > 0) { mode = code[8][code[8].Length - 1]; if (!core.irc.UChars.Contains(mode)) { mode = '\0'; } } if (channel != null) { if (!channel.containsUser(nick)) { User _user = null; if (mode != '\0') { _user = new User(mode.ToString() + nick, host, ident); } else { _user = new User(nick, host, ident); } lock (channel.UserList) { channel.UserList.Add(_user); } return(true); } lock (channel.UserList) { foreach (User u in channel.UserList) { if (u.Nick == nick) { u.Ident = ident; u.Host = host; break; } } } } } return(false); }
private bool Join(string source, string parameters, string value) { string chan = parameters; chan = chan.Replace(" ", ""); if (string.IsNullOrEmpty(chan)) { chan = value; } if (chan == config.DebugChan && instance.Nick != core.irc.NickName) { return(true); } string user = source.Substring(0, source.IndexOf("!")); string _host = source.Substring(source.IndexOf("@") + 1); string _ident = source.Substring(source.IndexOf("!") + 1); _ident = _ident.Substring(0, _ident.IndexOf("@")); config.channel channel = core.getChannel(chan); User _user = new User(user, _host, _ident); if (channel != null) { lock (Module.module) { foreach (Module module in Module.module) { try { if (module.working) { module.Hook_Join(channel, _user); } } catch (Exception fail) { core.Log("MODULE: exception at Hook_Join in " + module.Name, true); core.handleException(fail); } } } if (!channel.containsUser(user)) { lock (channel.UserList) { channel.UserList.Add(new User(user, _host, _ident)); } } return(true); } return(false); }
public void RetrieveStatus2(string nick, config.channel channel, string source) { try { string response = "I have never seen " + nick; bool found = false; string action = "quiting the network"; foreach (item xx in global) { if (nick.ToUpper() == xx.nick.ToUpper()) { found = true; config.channel last; switch (xx.LastAc) { case item.Action.Join: action = "joining the channel"; last = core.getChannel(xx.lastplace); if (last != null) { if (last.containsUser(nick)) { action += ", they are still in the channel"; } else { action += ", but they are not in the channel now and I don't know why, in"; } } break; case item.Action.Kick: action = "kicked from the channel"; break; case item.Action.Nick: if (xx.newnick == null) { action = "error NULL pointer at record"; break; } action = "changing the nickname to " + xx.newnick; last = core.getChannel(xx.lastplace); if (last.containsUser(xx.newnick)) { action += " and " + xx.newnick + " is still in the channel"; } else { action += ", but " + xx.newnick + " is no longer in channel"; } item nick2 = getItem(xx.newnick); if (nick2 != null) { TimeSpan span3 = DateTime.Now - nick2.LastSeen; switch (nick2.LastAc) { case item.Action.Exit: action += " because he quitted the network " + span3.ToString() + " ago. The nick change was done in"; break; case item.Action.Kick: action += " because he was kicked from the channel " + span3.ToString() + " ago. The nick change was done in"; break; case item.Action.Part: action += " because he left the channel " + span3.ToString() + " ago. The nick change was done in"; break; } } break; case item.Action.Part: action = "leaving the channel"; break; case item.Action.Talk: action = "talking in the channel"; last = core.getChannel(xx.lastplace); if (last != null) { if (last.containsUser(nick)) { action += ", they are still in the channel"; } else { action += ", but they are not in the channel now and I don't know why, in"; } } break; case item.Action.Exit: string reason = xx.quit; if (reason == "") { reason = "no reason was given"; } action = "quitting the network with reason: " + reason; break; } TimeSpan span = DateTime.Now - xx.LastSeen; if (xx.LastAc == item.Action.Exit) { response = "Last time I saw " + nick + " they were " + action + " at " + xx.LastSeen.ToString() + " (" + RegularModule.FormatTimeSpan(span) + " ago)"; } response = "Last time I saw " + nick + " they were " + action + " " + xx.lastplace + " at " + xx.LastSeen.ToString() + " (" + RegularModule.FormatTimeSpan(span) + " ago)"; break; } } string target = source; if (channel != null) { target = channel.Name; } if (nick.ToUpper() == source.ToUpper()) { response = "are you really looking for yourself?"; core.irc._SlowQueue.DeliverMessage(source + ": " + response, target, IRC.priority.normal); return; } if (nick.ToUpper() == config.NickName.ToUpper()) { response = "I am right here"; core.irc._SlowQueue.DeliverMessage(source + ": " + response, target, IRC.priority.normal); return; } if (channel != null) { if (channel.containsUser(nick)) { response = nick + " is in here, right now"; found = true; } } if (!found) { foreach (config.channel Item in config.channels) { if (Item.containsUser(nick)) { response = nick + " is in " + Item.Name + " right now"; break; } } } core.irc._SlowQueue.DeliverMessage(source + ": " + response, target, IRC.priority.normal); } catch (Exception fail) { handleException(fail); } }
public void Search() { try { if (misc.IsValidRegex(temp_nick)) { System.Text.RegularExpressions.Regex ex = new System.Text.RegularExpressions.Regex(temp_nick); string response = "I have never seen " + temp_nick; bool found = false; bool multiple = false; string results = ""; int cn = 0; string action = "quitting the network with reason "; foreach (item xx in global) { if (ex.IsMatch(xx.nick)) { if (found) { cn++; if (cn < 6) { results += xx.nick + ", "; } multiple = true; continue; } found = true; config.channel last = null; switch (xx.LastAc) { case item.Action.Join: action = "joining the channel"; last = core.getChannel(xx.lastplace); if (last != null) { if (last.containsUser(xx.nick)) { action += ", they are still in the channel"; } else { action += ", but they are not in the channel now and I don't know why, in"; } } break; case item.Action.Kick: action = "kicked from the channel"; break; case item.Action.Nick: if (xx.newnick == null) { action = "error NULL pointer at record"; } else { action = "changing the nickname to " + xx.newnick; last = core.getChannel(xx.lastplace); if (last.containsUser(xx.newnick)) { action += " and " + xx.newnick + " is still in the channel"; } else { action += ", but " + xx.newnick + " is no longer in channel"; } item nick = getItem(xx.newnick); if (nick != null) { TimeSpan span3 = DateTime.Now - nick.LastSeen; switch (nick.LastAc) { case item.Action.Exit: action += " because he quitted the network " + span3.ToString() + " ago. The nick change was done in"; break; case item.Action.Kick: action += " because he was kicked from the channel " + span3.ToString() + " ago. The nick change was done in"; break; case item.Action.Part: action += " because he left the channel " + span3.ToString() + " ago. The nick change was done in"; break; } } } break; case item.Action.Part: action = "leaving the channel"; break; case item.Action.Talk: action = "talking in the channel"; last = core.getChannel(xx.lastplace); if (last != null) { if (last.containsUser(xx.nick)) { action += ", they are still in the channel. It was in"; } else { action += ", but they are not in the channel now and I don't know why. It was in"; } } break; case item.Action.Exit: string reason = xx.quit; if (reason == "") { reason = "no reason was given"; } action = "quitting the network with reason: " + reason; break; } TimeSpan span2 = DateTime.Now - xx.LastSeen; if (xx.lastplace == null) { xx.lastplace = "N/A"; } if (xx.LastAc == item.Action.Exit) { response = "Last time I saw " + xx.nick + " they were " + action + " at " + xx.LastSeen.ToString() + " (" + RegularModule.FormatTimeSpan(span2) + " ago)"; } else { response = "Last time I saw " + xx.nick + " they were " + action + " " + xx.lastplace + " at " + xx.LastSeen.ToString() + " (" + RegularModule.FormatTimeSpan(span2) + " ago)"; } } } if (temp_nick.ToUpper() == temp_source.ToUpper()) { response = "are you really looking for yourself?"; core.irc._SlowQueue.DeliverMessage(temp_source + ": " + response, chan.Name); Working = false; return; } if (temp_nick.ToUpper() == config.NickName.ToUpper()) { response = "I am right here"; core.irc._SlowQueue.DeliverMessage(temp_source + ": " + response, chan.Name); Working = false; return; } if (chan.containsUser(temp_nick)) { response = temp_nick + " is in here, right now"; found = true; } if (multiple) { if (results.Length > 2) { results = results.Substring(0, results.Length - 2); } if (cn > 5) { results = results + " and " + (cn - 5).ToString() + " more results"; } response += " (multiple results were found: " + results + ")"; } core.irc._SlowQueue.DeliverMessage(temp_source + ": " + response, chan.Name); Working = false; return; } core.irc._SlowQueue.DeliverMessage(messages.get("Error1", chan.Language), chan.Name); Working = false; } catch (ThreadAbortException) { return; } catch (Exception fail) { handleException(fail); Working = false; } }
private bool Kick(string source, string parameters, string value) { string user = parameters.Substring(parameters.IndexOf(" ") + 1); string user2 = source.Substring(0, source.IndexOf("!")); string _ident; string _host; _host = source.Substring(source.IndexOf("@") + 1); _ident = source.Substring(source.IndexOf("!") + 1); _ident = _ident.Substring(0, _ident.IndexOf("@")); User user01 = new User(user, "", ""); User sr = new User(user2, _host, _ident); // [email protected] KICK #support HelpBot :Removed from the channel string chan = parameters.Substring(0, parameters.IndexOf(" ")); if (chan == config.DebugChan && instance.Nick != core.irc.NickName) { return(true);; } config.channel channel = core.getChannel(chan); if (channel != null) { lock (Module.module) { foreach (Module module in Module.module) { if (!module.working) { continue; } try { module.Hook_Kick(channel, sr, user01); } catch (Exception fail) { core.Log("MODULE: exception at Hook_Kick in " + module.Name, true); core.handleException(fail); } } } if (channel.containsUser(user)) { User delete = null; lock (channel.UserList) { foreach (User _user in channel.UserList) { if (_user.Nick == user) { delete = _user; break; } } if (delete != null) { channel.UserList.Remove(delete); } } } return(true); } return(false); }