protected override void OnMessage(User user, string target, string message) { Console.WriteLine("[{0}] <{1}@{2}> {3}", target, user.Nick, user.Host, message); foreach (var pair in MatchHandlers) { Match match = Regex.Match(message, pair.Key); if (match.Success) { pair.Value(match, user, target, message); break; } } }
protected virtual void OnJoin(User user, string channel) { }
protected virtual void OnInvite(User user, string channel) { }
protected virtual void OnQuit(User user, string message) { }
protected virtual void OnNotice(User user, string target, string message) { }
protected virtual void OnMode(User user, string target, string modes) { }
void OnOED(Match match, User user, string target, string message) { string phonemes = ""; bool success = OED.GetOEDIPA(match.Groups[1].Value, ref phonemes); string response; if (success) response = phonemes; else response = "Request failed"; Respond(user, target, response); }
void OnIPA(Match match, User user, string target, string message) { string translation = XSAMPA.TranslateText(match.Groups[1].Value); Respond(user, target, translation); }
protected override void OnInvite(User user, string channel) { JoinChannel(channel); }
void Respond(User user, string target, string line) { bool isPrivateMessage = target.Length > 0 && target[0] != '#'; if (isPrivateMessage) SendMessage(user.Nick, line); else SendMessage(target, line); }
void OnVersion(Match match, User user, string target, string message) { int revision = Assembly.GetCallingAssembly().GetName().Version.Revision; string response = string.Format("\x01VERSION From the entrails to the dirt, r{0}\x01", revision); SendNotice(user.Nick, response); }