コード例 #1
0
 private static void DoAction(Action Action)
 {
     if (Action.ActionAPI == "GMail")
     {
         System.Diagnostics.Debug.WriteLine("AN ACTION WAS TRIGGERED. TRYING TO SEND A MAIL." + Action);
         GMail    gmail  = new GMail();
         string[] Scopes = { GmailService.Scope.GmailSend };
         gmail.GmailMain(Action.UserId, Scopes);
         string[] tokens = Action.ActionData.Split(' ');
         if (Action.TriggerAPI == "Crypto")
         {
             gmail.SendIt(tokens[0], tokens[1], ("Area triggered: " + Action.Name + " (" + Action.TriggerAPI + " : " + Action.TriggerData + ")"), ("Area triggered: " + Action.Name + " (" + Action.TriggerAPI + " : " + Action.TriggerData + ")"));
         }
         else if (Action.TriggerAPI == "Twitch")
         {
             gmail.SendIt(tokens[0], tokens[1], ("Area triggered: " + Action.Name + " (" + Action.TriggerAPI + ")"), "Area trigger: your bot is connected on " + Action.TriggerData + " channel");
         }
     }
 }
コード例 #2
0
ファイル: LOL.cs プロジェクト: FrancoisGayraud/AREA
        public void useLolApi()
        {
            var    url = @"https://euw1.api.riotgames.com/lol/summoner/v3/summoners/by-name/" + summonerName + "?api_key=RGAPI-c2f9a714-35cf-43a3-b74b-02be9a4b942e";
            string JsonResponse;

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

            request.AutomaticDecompression = DecompressionMethods.GZip;

            using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                using (Stream stream = response.GetResponseStream())
                    using (StreamReader reader = new StreamReader(stream))
                    {
                        JsonResponse = reader.ReadToEnd();
                    }
            JsonForLol Response = JsonConvert.DeserializeObject <JsonForLol>(JsonResponse);
            GMail      gmail    = new GMail();

            string[] Scopes = { GmailService.Scope.GmailSend };
            gmail.GmailMain(userId, Scopes);
            gmail.SendIt(From, To, "Your league data", "Your id : " + Response.id + "\nYour summoner level: " + Response.summonerLevel + "\nYour account ID : " + Response.accountId);
        }
コード例 #3
0
ファイル: Reddit.cs プロジェクト: FrancoisGayraud/AREA
        public void initReddit()
        {
            var    url = @"https://www.reddit.com/r/" + subName + "/new.json?sort=new";
            string JsonResponse;

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

            request.AutomaticDecompression = DecompressionMethods.GZip;

            using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                using (Stream stream = response.GetResponseStream())
                    using (StreamReader reader = new StreamReader(stream))
                    {
                        JsonResponse = reader.ReadToEnd();
                    }
            JsonForReddit Response = JsonConvert.DeserializeObject <JsonForReddit>(JsonResponse);
            GMail         gmail    = new GMail();

            string[] Scopes = { GmailService.Scope.GmailSend };
            gmail.GmailMain(userId, Scopes);
            System.Diagnostics.Debug.WriteLine(Response.data.children[0].data.selftext);
            gmail.SendIt(From, To, "Last thread in " + subName, "title : " + Response.data.children[0].data.title + "\ncontent :" + Response.data.children[0].data.selftext);
        }