Exemplo n.º 1
0
        public static void ConnectToWiki(BotSettings settings)
        {
            CookieContainer cc = new CookieContainer();
            wc = new WebClientExt(cc);
            wc.Headers.Add("User-Agent", UserAgent);

            string loginPage = "https://developer.valvesoftware.com/w/index.php?title=Special:UserLogin&returnto=Main_Page";

            string loginSubmit = "https://developer.valvesoftware.com/w/index.php?title=Special:UserLogin&action=submitlogin&type=login&returnto=Main_Page";

            //Go to the login page to get the session cookie
            string s = wc.DownloadString(loginPage);

            //Search the string for the login token:
            string tokenkey = "name=\"wpLoginToken\" value=\"";
            int indexOfStart = s.IndexOf(tokenkey) + tokenkey.Length;
            int end = s.IndexOf("\"", indexOfStart);

            string token = s.Substring(indexOfStart, end - indexOfStart);

            string username = settings.VDCLogin;
            string password = settings.VDCPassword;

            NameValueCollection nvc = new NameValueCollection();

            nvc.Add("wpName", username);
            nvc.Add("wpPassword", password);
            nvc.Add("pwLoginAttempt", "Log In");
            nvc.Add("wpLoginToken", token);
            nvc.Add("wpRemember", "1");

            byte[] response = wc.UploadValues(loginSubmit, "POST", nvc);

            File.WriteAllText("test.html", Encoding.ASCII.GetString(response));
        }
Exemplo n.º 2
0
        public IRCBot(string ServerAddress, IrcUser USer)
            : base(ServerAddress, USer)
        {
            Settings = JsonConvert.DeserializeObject<BotSettings>(File.ReadAllText("BotSettings.txt"));

            if (Settings.Logging) LogWriter = new StreamWriter("IRCBotLog.txt");

            this.ConnectionComplete += IRCBot_ConnectionComplete;

            this.RawMessageRecieved += bot_RawMessage;

            RegisterCommand("function", FunctionMod);
            RegisterCommand("f", FunctionMod);

            RegisterCommand("ping", Ping);
            RegisterCommand("class", ModifyClass);

            RegisterCommand("param", ParamMod);
            RegisterCommand("diffdb", DiffDB);
            RegisterCommand("dumpwiki", DumpWiki);
            RegisterCommand("writepage", ForceWriteWikiPage);

            RegisterCommand("writeallpages", UpdateAllWikiPages);
            RegisterCommand("updatestatus", WikiStatus);

            RegisterCommand("user", UserMod);
            RegisterCommand("reload", Reload);

            RegisterCommand("addcaptcha", AddCaptcha);

            RegisterCommand("insult", InsultBot);

            RegisterCommand("help", Help);
            RegisterCommand("?", Help);
        }
Exemplo n.º 3
0
        string Reload(IrcCommand command)
        {
            if (!AccessCheck(command)) return "No Permision";

            Settings = JsonConvert.DeserializeObject<BotSettings>(File.ReadAllText("BotSettings.txt"));

            return "Done";
        }