public override void OnDataReceived(object sender, IRCReadEventArgs e) { if (e.isAdmin && e.Split[3].ToLower() == ":" + Program.C.Config.CommandPrefix.ToLower() + "c#") { Connection C = (Connection)sender; string code = string.Join(" ", e.Split, 4, e.Split.Length - 4); if (File.Exists(code)) code = File.ReadAllText(code); object ret = ExecuteCode(code, "CSharpBot", "Program", "Main", true, e.Nick + "!" + e.User + e.Host); //@ is builtin if (ret == null) ret = "\x03" + "4NULL"; string sRet = ret.ToString().Replace("\r", ""); string[] returns = sRet.Split('\n'); C.WriteLine("PRIVMSG " + e.Split[2] + " :" + e.Nick + ", return:"); foreach (string s in returns) { C.WriteLine("PRIVMSG " + e.Split[2] + " :" + s); } } }
public override void OnDataReceived(object sender, IRCReadEventArgs e) { if (e.Message.Contains("PRIVMSG") && Regex.IsMatch(e.Message, @".+http://(?:www\.)?youtu(?:be\.com/watch\?v=|\.be/)(\w*)(&(amp;)?[\w\?=]*)?.+")) { Connection Conn = (Connection)sender; Match match = Regex.Match(e.Message, @".+http://(?:www\.)?youtu(?:be\.com/watch\?v=|\.be/)(\w*)(&(amp;)?[\w\?=]*)?"); string videoid = match.Groups[1].Value; if (videoid.Contains(".be")) videoid = match.Groups[2].Value; WebClient client = new WebClient(); string source = ""; bool good = true; try { source = client.DownloadString("http://gdata.youtube.com/feeds/api/videos/" + videoid); } catch (WebException) { good = false; Conn.WriteLine("PRIVMSG " + e.Message.Split(' ')[2] + " :There was an error fetching youtube video id " + videoid + "."); } Match titleMatch = Regex.Match(source, @"\<title\b[^>]*\>\s*(?<Title>[\s\S]*?)\</title\>", RegexOptions.IgnoreCase); string title = titleMatch.Groups["Title"].Value; if (good) Conn.WriteLine("PRIVMSG " + e.Message.Split(' ')[2] + " :YouTube video title is \"" + title + "\""); } }
public override void OnDataReceived(object sender, IRCReadEventArgs e) { Connection C = (Connection)sender; string[] split = e.Split; if (split.Length > 5 && split[4] == ":autorejoin" && split[5] == "on") { Activate = true; Core.Log("Autorejoin turned on", Core.LogLevel.Info); C.WriteLine("PRIVMSG " + split[2] + " :" + e.Nick + ", " + "Autorejoin turned on"); } if (split.Length > 5 && split[4] == ":autorejoin" && split[5] == "off") { Activate = false; Core.Log("Autorejoin turned off", Core.LogLevel.Info); C.WriteLine("PRIVMSG " + split[2] + " :" + e.Nick + ", " + "Autorejoin turned off"); } if (Activate == true) { if (split[1] == "KICK") { C.WriteLine("JOIN " + split[2]); } } }
public override void OnDataReceived(object sender, IRCReadEventArgs e) { Connection C = (Connection)sender; if (e.Message.Contains("001 " + C.UserInfo.Nick + " :Welcome to the")) { JoinReadinessTable.Add(new Tuple<Connection, bool>(C, true)); } }
public override void OnDataReceived(object sender, IRCReadEventArgs e) { if (e.Message.StartsWith("PING :")) { Connection C = (Connection)sender; string[] PingData = e.Message.Split(':'); C.WriteLine("PONG :" + PingData[1]); } }
public override void OnDataReceived(object sender, IRCReadEventArgs e) { if (e.Split.Length > 4 && e.Split[1] == "PRIVMSG" && e.Split[3] == ":" + Program.C.Config.CommandPrefix + "cmdprefix") { Connection C = (Connection)sender; Program.C.Config.CommandPrefix = e.Split[4]; C.WriteLine("PRIVMSG " + e.Split[2] + " :" + e.Nick + ": cmd prefix set to " + e.Split[4]); } }
public override void OnDataReceived(object sender, IRCReadEventArgs e) { if (e.Message.Contains("PRIVMSG ") && e.Message.Contains(Program.C.Config.CommandPrefix + "say")) { string[] split = e.Split; if (split.Length > 3) { Connection C = (Connection)sender; C.WriteLine("PRIVMSG " + split[2] + " :" + string.Join(" ", split, 4, split.Length - 4)); } } }
public override void OnDataReceived(object sender, IRCReadEventArgs e) { if (e.Split.Length > 3 && e.Split[1] == "PRIVMSG" && e.Split[3] == ":" + Program.C.Config.CommandPrefix + "quit" && e.isAdmin) { Connection C = (Connection)sender; if (e.Split.Length > 4) C.WriteLine("QUIT :" + string.Join(" ", e.Split, 4, e.Split.Length - 4)); else C.WriteLine("QUIT :CSharpBot 2 -- https://github.com/Merbo/CSharpBot-2 http://173.48.92.80/CSharpBot"); } }
public override void OnDataReceived(object sender, IRCReadEventArgs e) { if (e.Split.Length > 3 && e.Split[1] == "PRIVMSG" && e.Split[3] == ":" + Program.C.Config.CommandPrefix + "ls") { string Modules = ""; foreach (Module M in Program.Modules) { Modules += M.GetName() + ", "; } Modules = Modules.Remove(Modules.Length - 2, 2); Modules += "."; Connection C = (Connection)sender; C.WriteLine("PRIVMSG " + e.Split[2] + " :" + e.Nick + ": " + Modules); } }
public override void OnDataReceived(object sender, IRCReadEventArgs e) { if (e.Split.Length > 4 && e.Split[1] == "PRIVMSG" && e.Split[3] == ":" + Program.C.Config.CommandPrefix + "mode" && e.isOp || e.isAdmin) { string[] split = e.Message.Split(' '); if (split[2].StartsWith("#")) { Connection C = (Connection)sender; string Params = string.Join(" ", e.Split, 4, e.Split.Length - 4); C.WriteLine("MODE " + e.Split[2] + " :" + Params); } } }
/// <summary> /// Called when bot receives information on a connection /// </summary> /// <param name="sender">Boxed Connection object</param> /// <param name="e">Event args</param> public abstract void OnDataReceived(object sender, IRCReadEventArgs e);
public override void OnDataReceived(object sender, IRCReadEventArgs e) { }