Release Shoutbot + source
#1
So yea, you might have seen him in the shoutbox already.
It's a bot that automatically responds to words that can be found in forbidden.txt
Bot can optimized in settings.ini
NOTE 'Owners' can be configured in settings.ini by the 'JariZ,barata,yomomma' format. Owners are case-sensitive.

[Image: tZk8FxkIcL.png]
[Image: sSxtCttm9J.png]

Issues
  • Users with a '-' in their name are able to bypass it (because of the way it filters)

Commands
Commands need to be send in a personal message to the bot
  • !say OHAI
    OHAI is your message, it will just say the message. You can add smileys by changing ':' to '||'. For example /pvt 1337 !say ||foreveralone||
  • !spam smileyname
    Where smileyname is the smiley it will spam 20 times example: /pvt 1337 !spam nyan
  • !shutdown
    Turns the bot off

Source
Code:
using System; using System.Threading; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net; using System.Collections; using System.Runtime.InteropServices; using System.Text.RegularExpressions; namespace ShoutboxBot { class Program { static IniFile ini; static string Username = ""; static string Password = ""; static bool extreme_mode = true; static bool ignoreall = false; static string[] words = { }; static string[] Owners = new string[] { }; static Hashtable Shouts = new Hashtable(); static void Shout(WebClient aa, string msg) { System.Collections.Specialized.NameValueCollection Data = new System.Collections.Specialized.NameValueCollection(); Data.Add("shout_data", msg.Replace("||", ":")); byte[] dataz = aa.UploadValues("http://www.itsmods.com/forum/xmlhttp.php?action=add_shout", "POST", Data); if (System.Text.Encoding.ASCII.GetString(dataz).Contains("success")) { Console.WriteLine(">>> [SHOUTBOT] " + msg); } else { Console.WriteLine("###############################\r\nFailed to post shout: " + System.Text.Encoding.ASCII.GetString(dataz) + "\r\n###############################"); } } static void ProcessCommand(string username, string msg, WebClient xxx) { if (Owners.Contains(username)) { if (msg.StartsWith("!spam ")) { string aaaa = ""; int r = 0; while(r != 20) { r++; aaaa += ":"+msg.Substring(6)+": "; } Shout(xxx, aaaa); } else if (msg.StartsWith("!say ")) { Shout(xxx, msg.Substring(5)); } else if (msg == "!shutdown") { Shout(xxx, "/me [OFFLINE] kthxbaai"); Environment.Exit(1); } } } static void Main(string[] args) { Console.ForegroundColor = ConsoleColor.White; Console.WindowHeight = Console.LargestWindowHeight; Console.WindowWidth = Console.LargestWindowWidth; Console.Title = "Shoutbot"; Console.WriteLine("Loading settings..."); ini = new IniFile(Environment.CurrentDirectory + "\\settings.ini"); Username = ini.IniReadValue("LOGIN", "username"); Password = ini.IniReadValue("LOGIN", "password"); Owners = ini.IniReadValue("SETTINGS", "owners").Split(new string[] { "," }, StringSplitOptions.None); extreme_mode = Convert.ToBoolean(ini.IniReadValue("SETTINGS", "extrememode")); ignoreall = Convert.ToBoolean(ini.IniReadValue("SETTINGS", "ignoreall")); try { words = System.IO.File.ReadAllLines("forbidden.txt"); Console.WriteLine("Forbidden words loaded"); } catch { Console.WriteLine("Failed opening forbidden.txt"); Thread.Sleep(-1); } Console.Write("Extreme mode = "); if (extreme_mode) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("ON"); } else { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("OFF"); } Console.ForegroundColor = ConsoleColor.White; Console.Write("Ignore all = "); if (ignoreall) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("ON"); } else { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("OFF"); } Console.ForegroundColor = ConsoleColor.White; System.Collections.Specialized.NameValueCollection Data = new System.Collections.Specialized.NameValueCollection(); Data.Add("username", Username); Data.Add("password", Password); Data.Add("submit", "Login"); Data.Add("action", "do_login"); WebClient wb = new WebClient(); byte[] bytes = wb.UploadValues("http://itsmods.com/forum/member.php", "POST", Data); if (System.Text.Encoding.ASCII.GetString(bytes).Contains("successfully")) { Console.WriteLine("Logged in"); CookieContainer cc = new CookieContainer(); string cookies = wb.ResponseHeaders["Set-Cookie"]; cc.SetCookies(new Uri("http://itsmods.com"), cookies); WebClient xxx = new WebClient(); xxx.Headers.Add("Cookie", cc.GetCookieHeader(new Uri("http://itsmods.com"))); //Shout(xxx, "Shoutbot v1.1 ONLINE BITCHEZ, made by @JariZ | PLEASE DON'T BAN ME :awesome:"); bool firstrun = true; while (true) { xxx = new WebClient(); xxx.Headers.Add("Cookie", cc.GetCookieHeader(new Uri("http://itsmods.com"))); //Shout(xxx, "[b]ShoutBot v1 initialized[/b]. Made by @\"jariz\"!"); string a = xxx.DownloadString("http://www.itsmods.com/forum/xmlhttp.php?action=show_shouts&last_id=0"); string[] shoutsraw = a.Split(new string[] { "<br />" }, StringSplitOptions.None); int count = -1; foreach (string x in shoutsraw.Reverse()) { try { count++; string[] shoutsep = x.Split(new string[] { "-" }, StringSplitOptions.None); int index = 5; int user = 1; if (count == 0 || count == shoutsraw.Length - 1) { index = 9; user = 5; } string text = HtmlRemoval.StripTagsCharArray(shoutsep[index]); int id = Convert.ToInt32(shoutsep[user].Split(new string[] { "ShoutBox.promptReason(" }, StringSplitOptions.None)[1].Split(new string[] { ");\" s" }, StringSplitOptions.None)[0]); string username = HtmlRemoval.StripTagsCharArray(shoutsep[user].Split(new string[] { "false;\" >" }, StringSplitOptions.None)[1].Split(new string[] { "</a>" }, StringSplitOptions.None)[0]); bool pm = false; try { if (shoutsep[10] == "color: #AF4300; font") { pm = true; text = shoutsep[11].Substring(34 + Username.Length).Replace("</span>", ""); } } catch { } if (Shouts[id] == null) // shout's not added yet { Shouts.Add(id, text); Console.Write(string.Format("[{0}] ", id)); if (pm) { Console.ForegroundColor = ConsoleColor.Green; Console.Write("[PM] "); } Console.ForegroundColor = ConsoleColor.DarkYellow; Console.Write(username + ": "); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(text); Console.ForegroundColor = ConsoleColor.White; if (pm && !firstrun) { ProcessCommand(username, text, xxx); } if (!ignoreall && !firstrun && !pm) { bool forbidden = false; if (extreme_mode) { foreach (string t in words) { if (text.ToLower().Contains(t.ToLower())) forbidden = true; } } else { foreach (string t in words) { if (text.ToLower() == t.ToLower()) forbidden = true; } } if (forbidden) { /*if (!username.ToLower().Contains("jariz")) {*/ Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("FORBIDDEN WORD!!!111"); Console.ForegroundColor = ConsoleColor.White; Shout(xxx, "/me [AUTOMESSAGE] Please use the searchbox in the top-right corner, " + username); /*} else { Console.WriteLine("JARIZ DETECTED, SKIPPING"); }*/ } } } } catch (Exception z) { } } if (firstrun) firstrun = false; System.Threading.Thread.Sleep(1500); } } else { Console.WriteLine("Fail!"); } } } public static class HtmlRemoval { /// <summary> /// Remove HTML from string with Regex. /// </summary> public static string StripTagsRegex(string source) { return Regex.Replace(source, "<.*?>", string.Empty); } /// <summary> /// Compiled regular expression for performance. /// </summary> static Regex _htmlRegex = new Regex("<.*?>", RegexOptions.Compiled); /// <summary> /// Remove HTML from string with compiled Regex. /// </summary> public static string StripTagsRegexCompiled(string source) { return _htmlRegex.Replace(source, string.Empty); } /// <summary> /// Remove HTML tags from string using char array. /// </summary> public static string StripTagsCharArray(string source) { char[] array = new char[source.Length]; int arrayIndex = 0; bool inside = false; for (int i = 0; i < source.Length; i++) { char let = source[i]; if (let == '<') { inside = true; continue; } if (let == '>') { inside = false; continue; } if (!inside) { array[arrayIndex] = let; arrayIndex++; } } return new string(array, 0, arrayIndex); } } public class IniFile { public string path; [DllImport("kernel32")] private static extern long WritePrivateProfileString(string section, string key, string val, string filePath); [DllImport("kernel32")] private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath); public IniFile(string INIPath) { path = INIPath; if (!System.IO.File.Exists(INIPath)) System.IO.File.Create(INIPath); } public void IniWriteValue(string Section, string Key, string Value) { WritePrivateProfileString(Section, Key, Value, this.path); } public string IniReadValue(string Section, string Key) { StringBuilder temp = new StringBuilder(255); int i = GetPrivateProfileString(Section, Key, "", temp, 255, this.path); return temp.ToString(); } } }

Download

.rar   Shoutbot.rar (Size: 5.61 KB / Downloads: 68)

Credits
@JariZ coding
@iAegle itsmods login function
@surtek Banning the bot
Reply

#2
hashtag swag
[Image: MaEIQ.png]
Reply

#3
It's says me "Fail!"
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
Reply

#4
It probably was a bad idea to release this though. Ah well, I hope @SuperNovaAO just bans all shoutbox spammers
[Image: MaEIQ.png]
Reply

#5
Quote:Users with a '-' in their name are able to bypass it (because of the way it filters)

Epic trolling bro Troll

iSpamalot
[Image: r212360a129ce9b84444093b6cd2699013a1fbn155.png]
Reply

#6
nice, thanks +rep
Reply

#7
Make the warning a private shout and everything will be Okay
Reply

#8
@Pozzuh Why, it's useful against noobs
@Lemon might add that
Reply

#9
(04-06-2012, 21:51)JariZ Wrote: @Pozzuh Why, it's useful against noobs
@Lemon might add that

people are just going to edit it to spam oma 24/7
[Image: MaEIQ.png]
Reply

#10
@Pozzuh then it's their fault if they end up being banned Troll
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  [Release] [SOURCE] Random Weapons. [HARD] Tony. 1 6,148 11-08-2013, 11:11
Last Post: Nekochan
  Help source random weapons [HARD] Tony. 4 6,556 11-08-2013, 05:25
Last Post: [HARD] Tony.
  [Request] Health and Points on hud source robinvm 7 8,178 10-27-2013, 08:23
Last Post: robinvm
  [Release] [SOURCE] DOOR V2.0 [HARD] Tony. 5 7,258 09-26-2013, 14:01
Last Post: Nekochan
  [source] medic E-losev 6 7,542 07-26-2013, 06:18
Last Post: E-losev
  [source] vAmpIr E-losev 5 6,765 07-25-2013, 16:28
Last Post: Bandarigoda123
  [Release] Barata's REAL External Console Source C# barata 37 30,130 06-28-2013, 23:47
Last Post: barata
Rainbow [News] Valve strikes again (Source Filmmaker) estebespt 25 18,695 04-05-2013, 18:15
Last Post: SuperNovaAO
  MapEdit Source archit 0 4,023 03-28-2013, 12:06
Last Post: archit
  W@W Promod Source Files? koil 1 3,498 01-11-2013, 15:12
Last Post: Pozzuh

Forum Jump:


Users browsing this thread:

Forum Powered By MyBB, Theme by © 2002-2026 Melroy van den Berg.