• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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
CSHARP Code
  1. using System;
  2. using System.Threading;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Net;
  7. using System.Collections;
  8. using System.Runtime.InteropServices;
  9. using System.Text.RegularExpressions;
  10.  
  11. namespace ShoutboxBot
  12. {
  13. class Program
  14. {
  15. static IniFile ini;
  16. static string Username = "";
  17. static string Password = "";
  18. static bool extreme_mode = true;
  19. static bool ignoreall = false;
  20. static string[] words = { };
  21. static string[] Owners = new string[]
  22. {
  23.  
  24. };
  25.  
  26.  
  27.  
  28. static Hashtable Shouts = new Hashtable();
  29.  
  30. static void Shout(WebClient aa, string msg)
  31. {
  32. System.Collections.Specialized.NameValueCollection Data = new System.Collections.Specialized.NameValueCollection();
  33. Data.Add("shout_data", msg.Replace("||", ":"));
  34. byte[] dataz = aa.UploadValues("http://www.itsmods.com/forum/xmlhttp.php?action=add_shout", "POST", Data);
  35. if (System.Text.Encoding.ASCII.GetString(dataz).Contains("success"))
  36. {
  37. Console.WriteLine(">>> [SHOUTBOT] " + msg);
  38. }
  39. else
  40. {
  41. Console.WriteLine("###############################\r\nFailed to post shout: " + System.Text.Encoding.ASCII.GetString(dataz) + "\r\n###############################");
  42. }
  43. }
  44.  
  45. static void ProcessCommand(string username, string msg, WebClient xxx)
  46. {
  47. if (Owners.Contains(username))
  48. {
  49. if (msg.StartsWith("!spam "))
  50. {
  51. string aaaa = "";
  52. int r = 0;
  53. while(r != 20)
  54. {
  55. r++;
  56. aaaa += ":"+msg.Substring(6)+": ";
  57. }
  58. Shout(xxx, aaaa);
  59. }
  60. else if (msg.StartsWith("!say "))
  61. {
  62. Shout(xxx, msg.Substring(5));
  63. }
  64. else if (msg == "!shutdown")
  65. {
  66. Shout(xxx, "/me [OFFLINE] kthxbaai");
  67. Environment.Exit(1);
  68. }
  69. }
  70. }
  71.  
  72. static void Main(string[] args)
  73. {
  74. Console.ForegroundColor = ConsoleColor.White;
  75. Console.WindowHeight = Console.LargestWindowHeight;
  76. Console.WindowWidth = Console.LargestWindowWidth;
  77. Console.Title = "Shoutbot";
  78.  
  79.  
  80. Console.WriteLine("Loading settings...");
  81. ini = new IniFile(Environment.CurrentDirectory + "\\settings.ini");
  82. Username = ini.IniReadValue("LOGIN", "username");
  83. Password = ini.IniReadValue("LOGIN", "password");
  84. Owners = ini.IniReadValue("SETTINGS", "owners").Split(new string[] { "," }, StringSplitOptions.None);
  85. extreme_mode = Convert.ToBoolean(ini.IniReadValue("SETTINGS", "extrememode"));
  86. ignoreall = Convert.ToBoolean(ini.IniReadValue("SETTINGS", "ignoreall"));
  87. try
  88. {
  89. words = System.IO.File.ReadAllLines("forbidden.txt");
  90. Console.WriteLine("Forbidden words loaded");
  91. }
  92. catch
  93. {
  94. Console.WriteLine("Failed opening forbidden.txt");
  95. Thread.Sleep(-1);
  96. }
  97.  
  98. Console.Write("Extreme mode = ");
  99. if (extreme_mode)
  100. {
  101. Console.ForegroundColor = ConsoleColor.Red;
  102. Console.WriteLine("ON");
  103. }
  104. else
  105. {
  106. Console.ForegroundColor = ConsoleColor.Green;
  107. Console.WriteLine("OFF");
  108. }
  109.  
  110. Console.ForegroundColor = ConsoleColor.White;
  111. Console.Write("Ignore all = ");
  112. if (ignoreall)
  113. {
  114. Console.ForegroundColor = ConsoleColor.Red;
  115. Console.WriteLine("ON");
  116. }
  117. else
  118. {
  119. Console.ForegroundColor = ConsoleColor.Green;
  120. Console.WriteLine("OFF");
  121. }
  122. Console.ForegroundColor = ConsoleColor.White;
  123. System.Collections.Specialized.NameValueCollection Data = new System.Collections.Specialized.NameValueCollection();
  124. Data.Add("username", Username);
  125. Data.Add("password", Password);
  126. Data.Add("submit", "Login");
  127. Data.Add("action", "do_login");
  128.  
  129. WebClient wb = new WebClient();
  130. byte[] bytes = wb.UploadValues("http://itsmods.com/forum/member.php", "POST", Data);
  131.  
  132. if (System.Text.Encoding.ASCII.GetString(bytes).Contains("successfully"))
  133. {
  134. Console.WriteLine("Logged in");
  135. CookieContainer cc = new CookieContainer();
  136. string cookies = wb.ResponseHeaders["Set-Cookie"];
  137. cc.SetCookies(new Uri("http://itsmods.com"), cookies);
  138.  
  139. WebClient xxx = new WebClient();
  140. xxx.Headers.Add("Cookie", cc.GetCookieHeader(new Uri("http://itsmods.com")));
  141. //Shout(xxx, "Shoutbot v1.1 ONLINE BITCHEZ, made by @JariZ | PLEASE DON'T BAN ME <img src="https://www.itsmods.com/forum/images/smilies/awesome.png" alt="Awesome" title="Awesome" class="smilie smilie_26" />");
  142. bool firstrun = true;
  143. while (true)
  144. {
  145. xxx = new WebClient();
  146. xxx.Headers.Add("Cookie", cc.GetCookieHeader(new Uri("http://itsmods.com")));
  147. //Shout(xxx, "<span style="font-weight: bold;">ShoutBot v1 initialized</span>. Made by @\"jariz\"!");
  148. string a = xxx.DownloadString("http://www.itsmods.com/forum/xmlhttp.php?action=show_shouts&last_id=0");
  149. string[] shoutsraw = a.Split(new string[] { "" }, StringSplitOptions.None);
  150. int count = -1;
  151. foreach (string x in shoutsraw.Reverse())
  152. {
  153. try
  154. {
  155. count++;
  156. string[] shoutsep = x.Split(new string[] { "-" }, StringSplitOptions.None);
  157. int index = 5;
  158. int user = 1;
  159. if (count == 0 || count == shoutsraw.Length - 1)
  160. {
  161. index = 9;
  162. user = 5;
  163. }
  164. string text = HtmlRemoval.StripTagsCharArray(shoutsep[index]);
  165. int id = Convert.ToInt32(shoutsep[user].Split(new string[] { "ShoutBox.promptReason(" }, StringSplitOptions.None)[1].Split(new string[] { ");\" s" }, StringSplitOptions.None)[0]);
  166. string username = HtmlRemoval.StripTagsCharArray(shoutsep[user].Split(new string[] { "false;\" >" }, StringSplitOptions.None)[1].Split(new string[] { "</a>" }, StringSplitOptions.None)[0]);
  167.  
  168. bool pm = false;
  169. try
  170. {
  171. if (shoutsep[10] == "color: #AF4300; font")
  172. {
  173. pm = true;
  174. text = shoutsep[11].Substring(34 + Username.Length).Replace("</span>", "");
  175. }
  176. }
  177. catch { }
  178.  
  179. if (Shouts[id] == null) // shout's not added yet
  180. {
  181. Shouts.Add(id, text);
  182. Console.Write(string.Format("[{0}] ", id));
  183. if (pm)
  184. {
  185. Console.ForegroundColor = ConsoleColor.Green;
  186. Console.Write("[PM] ");
  187. }
  188. Console.ForegroundColor = ConsoleColor.DarkYellow;
  189. Console.Write(username + ": ");
  190. Console.ForegroundColor = ConsoleColor.Yellow;
  191. Console.WriteLine(text);
  192. Console.ForegroundColor = ConsoleColor.White;
  193.  
  194. if (pm && !firstrun)
  195. {
  196. ProcessCommand(username, text, xxx);
  197. }
  198.  
  199. if (!ignoreall && !firstrun && !pm)
  200. {
  201. bool forbidden = false;
  202. if (extreme_mode)
  203. {
  204. foreach (string t in words)
  205. {
  206. if (text.ToLower().Contains(t.ToLower())) forbidden = true;
  207. }
  208. }
  209. else
  210. {
  211. foreach (string t in words)
  212. {
  213. if (text.ToLower() == t.ToLower()) forbidden = true;
  214. }
  215. }
  216.  
  217.  
  218. if (forbidden)
  219. {
  220. /*if (!username.ToLower().Contains("jariz"))
  221.   {*/
  222. Console.ForegroundColor = ConsoleColor.Red;
  223. Console.WriteLine("FORBIDDEN WORD!!!111");
  224. Console.ForegroundColor = ConsoleColor.White;
  225. Shout(xxx, "/me [AUTOMESSAGE] Please use the searchbox in the top-right corner, " + username);
  226. /*}
  227.   else
  228.   {
  229.   Console.WriteLine("JARIZ DETECTED, SKIPPING");
  230.   }*/
  231. }
  232. }
  233. }
  234. }
  235. catch (Exception z)
  236. {
  237.  
  238. }
  239. }
  240.  
  241. if (firstrun) firstrun = false;
  242. System.Threading.Thread.Sleep(1500);
  243. }
  244. }
  245. else
  246. {
  247. Console.WriteLine("Fail!");
  248. }
  249. }
  250. }
  251.  
  252. public static class HtmlRemoval
  253. {
  254. /// <summary>
  255. /// Remove HTML from string with Regex.
  256. /// </summary>
  257. public static string StripTagsRegex(string source)
  258. {
  259. return Regex.Replace(source, "<.*?>", string.Empty);
  260. }
  261.  
  262. /// <summary>
  263. /// Compiled regular expression for performance.
  264. /// </summary>
  265. static Regex _htmlRegex = new Regex("<.*?>", RegexOptions.Compiled);
  266.  
  267. /// <summary>
  268. /// Remove HTML from string with compiled Regex.
  269. /// </summary>
  270. public static string StripTagsRegexCompiled(string source)
  271. {
  272. return _htmlRegex.Replace(source, string.Empty);
  273. }
  274.  
  275. /// <summary>
  276. /// Remove HTML tags from string using char array.
  277. /// </summary>
  278. public static string StripTagsCharArray(string source)
  279. {
  280. char[] array = new char[source.Length];
  281. int arrayIndex = 0;
  282. bool inside = false;
  283.  
  284. for (int i = 0; i < source.Length; i++)
  285. {
  286. char let = source[i];
  287. if (let == '<')
  288. {
  289. inside = true;
  290. continue;
  291. }
  292. if (let == '>')
  293. {
  294. inside = false;
  295. continue;
  296. }
  297. if (!inside)
  298. {
  299. array[arrayIndex] = let;
  300. arrayIndex++;
  301. }
  302. }
  303. return new string(array, 0, arrayIndex);
  304. }
  305. }
  306. public class IniFile
  307. {
  308. public string path;
  309.  
  310. [DllImport("kernel32")]
  311. private static extern long WritePrivateProfileString(string section,
  312. string key, string val, string filePath);
  313. [DllImport("kernel32")]
  314. private static extern int GetPrivateProfileString(string section,
  315. string key, string def, StringBuilder retVal,
  316. int size, string filePath);
  317.  
  318. public IniFile(string INIPath)
  319. {
  320. path = INIPath;
  321. if (!System.IO.File.Exists(INIPath))
  322. System.IO.File.Create(INIPath);
  323. }
  324.  
  325. public void IniWriteValue(string Section, string Key, string Value)
  326. {
  327. WritePrivateProfileString(Section, Key, Value, this.path);
  328. }
  329.  
  330. public string IniReadValue(string Section, string Key)
  331. {
  332. StringBuilder temp = new StringBuilder(255);
  333. int i = GetPrivateProfileString(Section, Key, "", temp,
  334. 255, this.path);
  335. return temp.ToString();
  336.  
  337. }
  338. }
  339. }


Download

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

Credits
@JariZ coding
@iAegle itsmods login function
@surtek Banning the bot
[-] The following 7 users say Thank You to JariZ for this post:
  • Arteq, d0h!, iAegle, Nekochan, Pozzuh, The Clay Man, Yamato
  Reply
#2
hashtag swag
[Image: MaEIQ.png]
  Reply
#3
It's says me "Fail!"
C++/Obj-C developer. 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]
[-] The following 1 user says Thank You to Pozzuh for this post:
  • Yamato
  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]
[-] The following 1 user says Thank You to Pozzuh for this post:
  • JariZ
  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 2,298 11-08-2013, 11:11
Last Post: Nekochan
  Help source random weapons [HARD] Tony. 4 2,221 11-08-2013, 05:25
Last Post: [HARD] Tony.
  [Request] Health and Points on hud source robinvm 7 2,701 10-27-2013, 08:23
Last Post: robinvm
  [Release] [SOURCE] DOOR V2.0 [HARD] Tony. 5 2,903 09-26-2013, 14:01
Last Post: Nekochan
  [source] medic E-losev 6 2,723 07-26-2013, 06:18
Last Post: E-losev
  [source] vAmpIr E-losev 5 2,399 07-25-2013, 16:28
Last Post: Bandarigoda123
  [Release] Barata's REAL External Console Source C# barata 37 11,344 06-28-2013, 23:47
Last Post: barata
Rainbow [News] Valve strikes again (Source Filmmaker) estebespt 25 6,089 04-05-2013, 18:15
Last Post: SuperNovaAO
  MapEdit Source archit 0 1,932 03-28-2013, 12:06
Last Post: archit
  [email protected] Promod Source Files? koil 1 1,284 01-11-2013, 15:12
Last Post: Pozzuh

Forum Jump:


Users browsing this thread: 1 Guest(s)