protected override void OnPart(IrcContext context) { if (context.InvolvesBotClient) { _timer.Stop(); } }
protected override void OnPrivateMessage(IrcContext context) { if (context.IsBangCommand) { if (context.Parameters.Last().Equals("!url", StringComparison.InvariantCultureIgnoreCase) && Authorized(context)) { Enabled = !Enabled; context.Privmsg(context.Parameters[0], string.Format("UrlBot: [\x02{0}\x02]", Enabled ? "Active" : "Inactive")); } if (context.Parameters.Last().Equals("!geno", StringComparison.InvariantCultureIgnoreCase)) { var rec = _repo.Random <Record>(); var tinyUrl = GetTinyUrl(rec.Url); context.Privmsg(context.Parameters[0], string.Format("Here's your random link - {0}", tinyUrl)); } } else if (Enabled) { var match = Regex.Match(context.Parameters.Last(), REGEX_URL); if (match.Success) { var title = GetTitle(match.Value); if (title != null) { var tinyUrl = GetTinyUrl(match.Value); context.Privmsg(context.Parameters[0], string.Format("[\x02Title\x02] {0} ({1})", title, tinyUrl)); Log(title, match, context); } } } }
protected virtual void OnKick(IrcContext context) { if (context.InvolvesBotClient && AutoRejoin) { context.Join(context.Parameters.First()); } }
protected virtual void OnKick(IrcContext context) { if(context.InvolvesBotClient && AutoRejoin) { context.Join(context.Parameters.First()); } }
public void IncomingMessage(IrcContext context) { if(context.IsServerMessage) { OnServerMessage(context); } else { switch(context.Command.ToUpper()) { case "PRIVMSG": OnPrivateMessage(context); break; case "JOIN": OnJoin(context); break; case "MODE": OnMode(context); break; case "KICK": OnKick(context); break; case "PART": OnPart(context); break; case "TOPIC": OnTopic(context); break; default: OnOtherMessage(context); break; } } }
protected override void OnJoin(IrcContext context) { if (context.InvolvesBotClient) { _context = context; _channel = _context.Parameters.First(); _timer.Start(); } }
public void IncomingMessage(IrcContext context) { if (context.Parameters.Any()) { var msg = context.Parameters.Last(); if (msg.First() == DELIM && msg.Last() == DELIM) { HandleCtcpCommand(context); } } }
public void IncomingMessage(IrcContext context) { if(context.Parameters.Any()) { var msg = context.Parameters.Last(); if(msg.First() == DELIM && msg.Last() == DELIM) { HandleCtcpCommand(context); } } }
private void HandleCtcpCommand(IrcContext context) { var msg = context.Parameters.Last().Trim(DELIM); var cmd = msg.Split(' ')[0]; switch (cmd.ToUpper()) { case "VERSION": context.Write("{1} {2}: {0}VERSION {3}:{4}:{5}{0}", DELIM, context.Command, context.Nickname, "Nothing Special", "0.1b", "Windows 3.11"); break; } }
private void HandleCtcpCommand(IrcContext context) { var msg = context.Parameters.Last().Trim(DELIM); var cmd = msg.Split(' ')[0]; switch(cmd.ToUpper()) { case "VERSION": context.Write("{1} {2}: {0}VERSION {3}:{4}:{5}{0}", DELIM, context.Command, context.Nickname, "Nothing Special", "0.1b", "Windows 3.11"); break; } }
private void Log(string title, Match match, IrcContext context) { var record = new Record { Title = title, Url = match.Value, Domain = match.Groups["domain"].Value, User = context.Nickname, Channel = context.Parameters[0], Timestamp = DateTime.Now }; _repo.Add(record); _repo.CommitChanges(); }
protected override void OnServerMessage(IrcContext context) { var code = context.GetReplyCode(); if (code == ServerReplyCode.EndOfMessageOfTheDay) { context.Join(_channel); } else if (code == ServerReplyCode.NameReply) { _nameBuffer.AddRange(context.Parameters.Last().Split(' ')); } else if (code == ServerReplyCode.EndOfNames) { _names = _nameBuffer.ToArray(); _nameBuffer.Clear(); } }
public void IncomingMessage(IrcContext context) { if(context.Command.Equals("PONG", StringComparison.InvariantCultureIgnoreCase)) { Latency = DateTime.Now.Subtract(_lastPing); } if(context.Command == "001") { _server = context.Prefix; _context = context; _timer.Start(); } if(context.Command == "PING") { // the server pings the client?! It happens! context.Write("PONG {0}", context.Parameters.Last()); } }
public void IncomingMessage(IrcContext context) { if (context.Command.Equals("PONG", StringComparison.InvariantCultureIgnoreCase)) { Latency = DateTime.Now.Subtract(_lastPing); } if (context.Command == "001") { _server = context.Prefix; _context = context; _timer.Start(); } if (context.Command == "PING") { // the server pings the client?! It happens! context.Write("PONG {0}", context.Parameters.Last()); } }
public void IncomingMessage(IrcContext context) { if (context.IsServerMessage) { OnServerMessage(context); } else { switch (context.Command.ToUpper()) { case "PRIVMSG": OnPrivateMessage(context); break; case "JOIN": OnJoin(context); break; case "MODE": OnMode(context); break; case "KICK": OnKick(context); break; case "PART": OnPart(context); break; case "TOPIC": OnTopic(context); break; default: OnOtherMessage(context); break; } } }
private bool Authorized(IrcContext context) { var ops = _names.Where(n => n.StartsWith("@")); return(ops.Any(o => o.Substring(1).Equals(context.Nickname, StringComparison.InvariantCultureIgnoreCase))); }
protected virtual void OnPart(IrcContext context) { }
protected override void OnMode(IrcContext context) { context.Names(_channel); }
protected virtual void OnTopic(IrcContext context) { }
protected virtual void OnPrivateMessage(IrcContext context) { }
protected virtual void OnMode(IrcContext context) { }
protected virtual void OnJoin(IrcContext context) { }
protected virtual void OnOtherMessage(IrcContext context) { }