Ejemplo n.º 1
0
        public static string GetShoutOut(Dictionary <string, dynamic> parameters)
        {
            string userName = (string)parameters["_chatterUsername"];

            string shoutOut = "";

            if (userName != "")
            {
                UserO    user    = new UserO();
                ChannelO channel = new ChannelO();
                user = UserD.GetUser(userName);
                if (user._total != 0)
                {
                    channel = GetChannelById(user.users[0]._id);

                    shoutOut = "✧・゚: ✧・゚: Streamer alert :・゚✧:・゚✧ ! Show some love to this wonderful human being at : http://twitch.tv/" + userName + " , they were last seen streaming " + channel.game;
                }
                else
                {
                    shoutOut = "This user doesn't exist, make sure you wrote their username correctly!";
                }
            }
            else
            {
                shoutOut = "You didn't specify any streamer for the shoutout";
            }

            return(shoutOut);
        }
Ejemplo n.º 2
0
        public static string GetFollowage(Dictionary <string, string> parameters)
        {
            string userName  = parameters["_username"];
            string channelId = parameters["_channelId"];

            UserO user = UserD.GetUser(userName);

            string        channelOauth = ConfigurationManager.AppSettings["channelOauth"];
            Followage     followage    = new Followage();
            StringBuilder message      = new StringBuilder();

            string         url        = string.Format("https://api.twitch.tv/kraken/users/{0}/follows/channels/{1}", user.users[0]._id, channelId);
            HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);

            if (webRequest != null)
            {
                webRequest.Method  = "GET";
                webRequest.Timeout = 12000;
                webRequest.Headers.Add("Client-ID", channelOauth);
                webRequest.ContentType = "application/json";
                webRequest.Accept      = "application/vnd.twitchtv.v5+json";
            }

            using (Stream s = webRequest.GetResponse().GetResponseStream())
            {
                using (StreamReader sr = new System.IO.StreamReader(s))
                {
                    var jsonResponse = sr.ReadToEnd();
                    followage = JsonConvert.DeserializeObject <Followage>(jsonResponse);
                }
            }

            if (followage.created_at == null)
            {
                message.Append(String.Format("{0}, you are not following the channel, what are you even waiting for D:", user.users[0].display_name));
            }
            else
            {
                DateTime baseDate      = new DateTime(1, 1, 1);
                DateTime FollowageDate = followage.created_at;
                DateTime currentDate   = DateTime.Now.ToLocalTime();

                TimeSpan span = currentDate - FollowageDate;

                int years   = (baseDate + span).Year - 1;
                int months  = (baseDate + span).Month - 1;
                int days    = (baseDate + span).Day;
                int hours   = (baseDate + span).Hour;
                int minutes = (baseDate + span).Minute;
                int seconds = (baseDate + span).Second;

                message.Append(string.Format("{0}, you have been following the channel for ", user.users[0].display_name));

                if (years != 0)
                {
                    if (years > 1)
                    {
                        message.Append(string.Format("{0} years ", years));
                    }
                    else
                    {
                        message.Append(string.Format("{0} year ", years));
                    }
                }

                if (months != 0)
                {
                    if (months > 1)
                    {
                        message.Append(string.Format("{0} months ", months));
                    }
                    else
                    {
                        message.Append(string.Format("{0} month ", months));
                    }
                }

                if (days != 0)
                {
                    if (days > 1)
                    {
                        message.Append(string.Format("{0} days ", days));
                    }
                    else
                    {
                        message.Append(string.Format("{0} day ", days));
                    }
                }

                if (hours != 0)
                {
                    if (hours > 1)
                    {
                        message.Append(string.Format("{0} hours ", hours));
                    }
                    else
                    {
                        message.Append(string.Format("{0} hour ", hours));
                    }
                }

                if (minutes != 0)
                {
                    if (minutes > 1)
                    {
                        message.Append(string.Format("{0} minutes ", minutes));
                    }
                    else
                    {
                        message.Append(string.Format("{0} minute ", minutes));
                    }
                }

                if (seconds != 0)
                {
                    if (seconds > 1)
                    {
                        message.Append(string.Format("{0} seconds ", seconds));
                    }
                    else
                    {
                        message.Append(string.Format("{0} second ", seconds));
                    }
                }
            }

            message.Append(". Thank you so much for the amazing support! ( ˘ ³˘)♡ ");

            return(message.ToString());
        }