Esempio n. 1
0
        public static Task <CryptoAPI> TickerGetPrice(string symbol)
        {
            CryptoAPI cryptoAPI = null;
            int       count     = 0;

            return(Task.Factory.StartNew(() =>
            {
                while (cryptoAPI == null)
                {
                    string requestUriString = "";
                    double value = 1;
                    try
                    {
                        if (count == 0)
                        {
                            requestUriString = "https://api.gemini.com/v1/pubticker/" + symbol;
                        }
                        else
                        {
                            requestUriString = "https://api.gemini.com/v1/pubticker/" + symbol;
                        }

                        HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(requestUriString);
                        httpWebRequest.Proxy = null;
                        httpWebRequest.UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)";
                        HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                        Encoding aSCII = Encoding.ASCII;
                        string text = default(string);
                        using (StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream(), aSCII))
                        {
                            text = streamReader.ReadToEnd();
                        }
                        cryptoAPI = JsonConvert.DeserializeObject <CryptoAPI>(text.ToString());

                        value = Math.Min(Math.Min(cryptoAPI.ask, cryptoAPI.bid), cryptoAPI.last);

                        if (value == 0)
                        {
                            throw new System.Exception("value = 0 exception");
                        }
                    }
                    catch
                    {
                        count++;

                        if (count == 2)
                        {
                            break;
                        }

                        System.Threading.Thread.Sleep(500);

                        cryptoAPI = null;
                    }
                }

                return cryptoAPI;
            }));
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            string ent = CryptoAPI.Encrypt("password", "P@ssW03d");

            ent = "zEYqsw3XoQHGLgHd+5lqNUhv2vLK1VS38nRKqBT1PVpgQAdM9PyPPPnOm4Ri8G6yWLDn6kB9F9UOX6Gc2Vxk8lNAfFRTVHJJTjY=";
            string pswdHash = CryptoAPI.ComputeHash("12345678");
            //string pswd = CryptoAPI.Decrypt("ly7Xesz7x8eNA1DEVKeAHs0XB896Eoz941S6hNjU+Ajh33br8Y6avIcUrlA6ZqW1fKQo2k+bKyniidzVksxJv1NAfFRTVHJJTjY=", "P@ssW03d");
        }
Esempio n. 3
0
        private static void HandleAction(Action Action)
        {
            bool Triggered = false;

            if (Action.TriggerAPI == "Crypto")
            {
                Crypto.CryptoAPI Crypto = new CryptoAPI();
                Triggered = Crypto.IsTriggered(Action.TriggerData);
                if (Triggered)
                {
                    DoAction(Action);
                }
            }
            else if (Action.TriggerAPI == "Twitch")
            {
                if (!botRunning)
                {
                    string[]  tokens       = Action.ActionData.Split(' ');
                    TwitchApi twitch       = new TwitchApi(Action.TriggerData, tokens[0], tokens[1], Action.UserId);
                    Thread    TwitchThread = new Thread(twitch.initTwitchLoop);
                    TwitchThread.Start();
                    DoAction(Action);
                    botRunning = true;
                }
            }
            else if (Action.TriggerAPI == "League")
            {
                int      tmp;
                string[] tokens = Action.TriggerData.Split(' ');
                string[] data   = Action.ActionData.Split(' ');
                LOL      lol    = new LOL(data[0], data[1], Action.UserId);
                lol.summonerName = tokens[0];
                lol.useLolApi();
            }
            else if (Action.TriggerAPI == "Reddit")
            {
                string[] tokens = Action.TriggerData.Split(' ');
                string[] data   = Action.ActionData.Split(' ');
                Reddit   reddit = new Reddit(data[0], data[1], Action.UserId);
                reddit.subName = tokens[0];
                reddit.initReddit();
            }
        }