Esempio n. 1
0
 void seuntjie_SendMessage(SendMessage Message)
 {
     if (tmp.State == WebSocketState.Open)
     {
         if (csrf == "" || csrf == null)
         {
             string s1  = Client.GetStringAsync("ajax.php?a=get_csrf").Result;
             MDCsrf csr = SeuntjieBot.SeuntjieBot.JsonDeserialize <MDCsrf>(s1);
             csrf     = csr.csrf;
             lastCsrf = DateTime.Now;
         }
         List <KeyValuePair <string, string> > pairs = new List <KeyValuePair <string, string> >();
         pairs.Add(new KeyValuePair <string, string>("text", Message.Message));
         pairs.Add(new KeyValuePair <string, string>("a", "submit_chat"));
         pairs.Add(new KeyValuePair <string, string>("csrf", csrf));
         pairs.Add(new KeyValuePair <string, string>("user_id", Message.Pm?Message.ToUser.Uid.ToString():"0"));
         FormUrlEncodedContent Content = new FormUrlEncodedContent(pairs);
         try
         {
             string sEmitResponse = Client.PostAsync("ajax.php", Content).Result.Content.ReadAsStringAsync().Result;
             string s1            = Client.GetStringAsync("ajax.php?a=get_csrf").Result;
             MDCsrf csr           = SeuntjieBot.SeuntjieBot.JsonDeserialize <MDCsrf>(s1);
             csrf     = csr.csrf;
             lastCsrf = DateTime.Now;
         }
         catch (AggregateException e)
         {
         }
     }
 }
Esempio n. 2
0
        bool seuntjie_SendRain(User RainOn, double Amount)
        {
            string s1  = Client.GetStringAsync("ajax.php?a=get_csrf").Result;
            MDCsrf tmp = SeuntjieBot.SeuntjieBot.JsonDeserialize <MDCsrf>(s1);
            List <KeyValuePair <string, string> > pairs = new List <KeyValuePair <string, string> >();

            pairs.Add(new KeyValuePair <string, string>("a", "tip_user"));
            pairs.Add(new KeyValuePair <string, string>("user_id", RainOn.Uid.ToString()));
            pairs.Add(new KeyValuePair <string, string>("amount", Amount.ToString(System.Globalization.NumberFormatInfo.InvariantInfo)));
            pairs.Add(new KeyValuePair <string, string>("csrf", tmp.csrf));


            FormUrlEncodedContent Content = new FormUrlEncodedContent(pairs);

            try
            {
                string sEmitResponse = Client.PostAsync("ajax.php", Content).Result.Content.ReadAsStringAsync().Result;
                return(true);
            }
            catch (AggregateException e)
            {
                return(false);
            }
        }