Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using PlayerIOClient;
- using System.Timers;
- using System.Net;
- using System.Text.RegularExpressions;
- using System.IO;
- using System.Collections;
- using System.Diagnostics;
- namespace HoneyBot
- {
- class Program
- {
- public static IniFile ini = new IniFile();
- public static Connection con;
- public static Boolean detect_kick = false;
- public static string owner;
- static Dictionary<int, string> ID2Username = new Dictionary<int, string>();
- static Dictionary<string, int> Username2ID = new Dictionary<string, int>();
- static Dictionary<int, Analysis> ID2Analysis = new Dictionary<int, Analysis>();
- public class Analysis { public uint FaceChanges = 0; public uint CrownChanges = 0; }
- public static void Tick(object a, object b)
- {
- foreach (KeyValuePair<int, Analysis> x in ID2Analysis)
- {
- try
- {
- if (x.Value.FaceChanges >= 10 || x.Value.CrownChanges >= 10)
- {
- Console.WriteLine("Detected: " + ID2Username[x.Key]);
- if (ID2Username[x.Key].ToLower() != owner)
- {
- if (detect_kick) con.Send("say", "/kick " + ID2Username[x.Key]);
- con.Send("say", "[HoneyBot] Detected: " + ID2Username[x.Key]);
- }
- }
- x.Value.FaceChanges = 0;
- }
- catch { }
- }
- }
- public static void Tick2(object a, object b)
- {
- try
- {
- using (WebClient wb = new WebClient())
- {
- wb.Proxy = null;
- foreach (string user in wb.DownloadString("http://atil.la/public_projects/HoneyBot/bad.lst?v=5").Split(','))
- {
- if (!BadPeople.Contains(user))
- BadPeople.Add(user);
- }
- }
- }
- catch { }
- }
- public static List<string> BadPeople = new List<string>();
- static void Main(string[] args)
- {
- Console.Title = "HoneyBot - Anti-Crash";
- Console.Write("Retrieving Blacklist...");
- using (WebClient wb = new WebClient())
- {
- wb.Proxy = null;
- foreach (string user in wb.DownloadString("http://atil.la/public_projects/HoneyBot/bad.lst").Split(','))
- {
- BadPeople.Add(user);
- }
- }
- Console.WriteLine("Done.");
- ini.Load("settings.ini");
- string username = ini.GetKeyValue("Login", "Email");
- string password = ini.GetKeyValue("Login", "Password");
- string room = ini.GetKeyValue("Login", "RoomID");
- string AuthType = ini.GetKeyValue("Advanced", "AUTH");
- try
- { detect_kick = bool.Parse(ini.GetKeyValue("Advanced", "DetectKick")); }
- catch { }
- Client c = null;
- if (AuthType.ToUpper() == "NORMAL")
- c = PlayerIO.QuickConnect.SimpleConnect("everybody-edits-su9rn58o40itdbnw69plyw", username, password);
- else if (AuthType.ToUpper() == "KONG")
- c = PlayerIO.QuickConnect.KongregateConnect("everybody-edits-su9rn58o40itdbnw69plyw", username, password);
- else if (AuthType.ToUpper() == "FB")
- c = PlayerIO.QuickConnect.FacebookOAuthConnect("everybody-edits-su9rn58o40itdbnw69plyw", password, "");
- con = c.Multiplayer.CreateJoinRoom(room, "Everybodyedits176", true, null, null);
- Timer timer = new Timer(2500);
- timer.AutoReset = true;
- timer.Enabled = true;
- timer.Elapsed += Tick;
- Timer timer2 = new Timer(120000);
- timer2.AutoReset = true;
- timer2.Enabled = true;
- timer2.Elapsed += Tick2;
- con.OnMessage += delegate(object s, Message e)
- {
- switch (e.Type)
- {
- case "face":
- if (ID2Analysis.ContainsKey((int)e[0]))
- ID2Analysis[(int)e[0]].FaceChanges++;
- break;
- case "k":
- if (ID2Analysis.ContainsKey((int)e[0]))
- ID2Analysis[(int)e[0]].CrownChanges++;
- break;
- case "add":
- if (e.Count >= 11)
- if ((int)e[11] <= 2) con.Send("say", "/kick " + (string)e[1] + " " + "[HoneyBot] You are below level 3.");
- if (BadPeople.Contains((string)e[1])) con.Send("say", "/kick " + (string)e[1] + " " + "[HoneyBot] You are banned.");
- if (ID2Username.ContainsKey((int)e[0])) ID2Username[(int)e[0]] = (string)e[1];
- else
- ID2Username.Add((int)e[0], (string)e[1]);
- if (Username2ID.ContainsKey((string)e[1])) Username2ID[(string)e[1]] = (int)e[0];
- else
- Username2ID.Add((string)e[1], (int)e[0]);
- if (!ID2Analysis.ContainsKey((int)e[0]))
- ID2Analysis.Add((int)e[0], new Analysis());
- break;
- case "init":
- System.Threading.Thread.Sleep(1000);
- Console.WriteLine("Connected to: {0}", room);
- owner = (string)e[0];
- con.Send("say", "[HoneyBot] Initalized.");
- break;
- }
- };
- con.OnDisconnect += delegate(object a, string b)
- {
- Console.WriteLine("[HoneyBot] Disconnected. [TIME: " + DateTime.Now + "]");
- Main(new string[] { });
- };
- con.Send("init"); con.Send("init2");
- Console.ReadLine();
- }
- }
- public class IniFile
- {
- private Hashtable m_sections;
- public IniFile()
- {
- m_sections = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
- }
- public void Load(string sFileName)
- {
- Load(sFileName, false);
- }
- public void Load(string sFileName, bool bMerge)
- {
- if (!bMerge)
- {
- RemoveAllSections();
- }
- IniSection tempsection = null;
- StreamReader oReader = new StreamReader(sFileName);
- Regex regexcomment = new Regex("^([\\s]*#.*)", (RegexOptions.Singleline | RegexOptions.IgnoreCase));
- Regex regexsection = new Regex("^[\\s]*\\[[\\s]*([^\\[\\s].*[^\\s\\]])[\\s]*\\][\\s]*$", (RegexOptions.Singleline | RegexOptions.IgnoreCase));
- Regex regexkey = new Regex("^\\s*([^=\\s]*)[^=]*=(.*)", (RegexOptions.Singleline | RegexOptions.IgnoreCase));
- while (!oReader.EndOfStream)
- {
- string line = oReader.ReadLine();
- if (line != string.Empty)
- {
- Match m = null;
- if (regexcomment.Match(line).Success)
- {
- m = regexcomment.Match(line);
- Trace.WriteLine(string.Format("Skipping Comment: {0}", m.Groups[0].Value));
- }
- else if (regexsection.Match(line).Success)
- {
- m = regexsection.Match(line);
- Trace.WriteLine(string.Format("Adding section [{0}]", m.Groups[1].Value));
- tempsection = AddSection(m.Groups[1].Value);
- }
- else if (regexkey.Match(line).Success && tempsection != null)
- {
- m = regexkey.Match(line);
- Trace.WriteLine(string.Format("Adding Key [{0}]=[{1}]", m.Groups[1].Value, m.Groups[2].Value));
- tempsection.AddKey(m.Groups[1].Value).Value = m.Groups[2].Value;
- }
- else if (tempsection != null)
- {
- Trace.WriteLine(string.Format("Adding Key [{0}]", line));
- tempsection.AddKey(line);
- }
- else
- {
- Trace.WriteLine(string.Format("Skipping unknown type of data: {0}", line));
- }
- }
- }
- oReader.Close();
- }
- public void Save(string sFileName)
- {
- StreamWriter oWriter = new StreamWriter(sFileName, false);
- foreach (IniSection s in Sections)
- {
- Trace.WriteLine(string.Format("Writing Section: [{0}]", s.Name));
- oWriter.WriteLine(string.Format("[{0}]", s.Name));
- foreach (IniSection.IniKey k in s.Keys)
- {
- if (k.Value != string.Empty)
- {
- Trace.WriteLine(string.Format("Writing Key: {0}={1}", k.Name, k.Value));
- oWriter.WriteLine(string.Format("{0}={1}", k.Name, k.Value));
- }
- else
- {
- Trace.WriteLine(string.Format("Writing Key: {0}", k.Name));
- oWriter.WriteLine(string.Format("{0}", k.Name));
- }
- }
- }
- oWriter.Close();
- }
- public System.Collections.ICollection Sections
- {
- get
- {
- return m_sections.Values;
- }
- }
- public IniSection AddSection(string sSection)
- {
- IniSection s = null;
- sSection = sSection.Trim();
- if (m_sections.ContainsKey(sSection))
- {
- s = (IniSection)m_sections[sSection];
- }
- else
- {
- s = new IniSection(this, sSection);
- m_sections[sSection] = s;
- }
- return s;
- }
- public bool RemoveSection(string sSection)
- {
- sSection = sSection.Trim();
- return RemoveSection(GetSection(sSection));
- }
- public bool RemoveSection(IniSection Section)
- {
- if (Section != null)
- {
- try
- {
- m_sections.Remove(Section.Name);
- return true;
- }
- catch (Exception ex)
- {
- Trace.WriteLine(ex.Message);
- }
- }
- return false;
- }
- public bool RemoveAllSections()
- {
- m_sections.Clear();
- return (m_sections.Count == 0);
- }
- public IniSection GetSection(string sSection)
- {
- sSection = sSection.Trim();
- if (m_sections.ContainsKey(sSection))
- {
- return (IniSection)m_sections[sSection];
- }
- return null;
- }
- public string GetKeyValue(string sSection, string sKey)
- {
- IniSection s = GetSection(sSection);
- if (s != null)
- {
- IniSection.IniKey k = s.GetKey(sKey);
- if (k != null)
- {
- return k.Value;
- }
- }
- return string.Empty;
- }
- public bool SetKeyValue(string sSection, string sKey, string sValue)
- {
- IniSection s = AddSection(sSection);
- if (s != null)
- {
- IniSection.IniKey k = s.AddKey(sKey);
- if (k != null)
- {
- k.Value = sValue;
- return true;
- }
- }
- return false;
- }
- public bool RenameSection(string sSection, string sNewSection)
- {
- bool bRval = false;
- IniSection s = GetSection(sSection);
- if (s != null)
- {
- bRval = s.SetName(sNewSection);
- }
- return bRval;
- }
- public bool RenameKey(string sSection, string sKey, string sNewKey)
- {
- IniSection s = GetSection(sSection);
- if (s != null)
- {
- IniSection.IniKey k = s.GetKey(sKey);
- if (k != null)
- {
- return k.SetName(sNewKey);
- }
- }
- return false;
- }
- public class IniSection
- {
- private IniFile m_pIniFile;
- private string m_sSection;
- private Hashtable m_keys;
- protected internal IniSection(IniFile parent, string sSection)
- {
- m_pIniFile = parent;
- m_sSection = sSection;
- m_keys = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
- }
- public System.Collections.ICollection Keys
- {
- get
- {
- return m_keys.Values;
- }
- }
- public string Name
- {
- get
- {
- return m_sSection;
- }
- }
- public IniKey AddKey(string sKey)
- {
- sKey = sKey.Trim();
- IniSection.IniKey k = null;
- if (sKey.Length != 0)
- {
- if (m_keys.ContainsKey(sKey))
- {
- k = (IniKey)m_keys[sKey];
- }
- else
- {
- k = new IniSection.IniKey(this, sKey);
- m_keys[sKey] = k;
- }
- }
- return k;
- }
- public bool RemoveKey(string sKey)
- {
- return RemoveKey(GetKey(sKey));
- }
- public bool RemoveKey(IniKey Key)
- {
- if (Key != null)
- {
- try
- {
- m_keys.Remove(Key.Name);
- return true;
- }
- catch (Exception ex)
- {
- Trace.WriteLine(ex.Message);
- }
- }
- return false;
- }
- public bool RemoveAllKeys()
- {
- m_keys.Clear();
- return (m_keys.Count == 0);
- }
- public IniKey GetKey(string sKey)
- {
- sKey = sKey.Trim();
- if (m_keys.ContainsKey(sKey))
- {
- return (IniKey)m_keys[sKey];
- }
- return null;
- }
- public bool SetName(string sSection)
- {
- sSection = sSection.Trim();
- if (sSection.Length != 0)
- {
- IniSection s = m_pIniFile.GetSection(sSection);
- if (s != this && s != null) return false;
- try
- {
- m_pIniFile.m_sections.Remove(m_sSection);
- m_pIniFile.m_sections[sSection] = this;
- m_sSection = sSection;
- return true;
- }
- catch (Exception ex)
- {
- Trace.WriteLine(ex.Message);
- }
- }
- return false;
- }
- public string GetName()
- {
- return m_sSection;
- }
- public class IniKey
- {
- private string m_sKey;
- private string m_sValue;
- private IniSection m_section;
- protected internal IniKey(IniSection parent, string sKey)
- {
- m_section = parent;
- m_sKey = sKey;
- }
- public string Name
- {
- get
- {
- return m_sKey;
- }
- }
- public string Value
- {
- get
- {
- return m_sValue;
- }
- set
- {
- m_sValue = value;
- }
- }
- public void SetValue(string sValue)
- {
- m_sValue = sValue;
- }
- public string GetValue()
- {
- return m_sValue;
- }
- public bool SetName(string sKey)
- {
- sKey = sKey.Trim();
- if (sKey.Length != 0)
- {
- IniKey k = m_section.GetKey(sKey);
- if (k != this && k != null) return false;
- try
- {
- m_section.m_keys.Remove(m_sKey);
- m_section.m_keys[sKey] = this;
- m_sKey = sKey;
- return true;
- }
- catch (Exception ex)
- {
- Trace.WriteLine(ex.Message);
- }
- }
- return false;
- }
- public string GetName()
- {
- return m_sKey;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement