public static StandardisedUser FromDiscordMention(string MessageSegment, BotInstance BotInstance) { StandardisedUser U = new StandardisedUser(); U.ID = MessageSegment.Replace("<@", "").Replace(">", "").Replace("!", ""); return(U); }
public static StandardisedUser FromTwitchUsername(string MessageSegment, BotInstance BotInstance, int Depth = 0) { if (Depth == 5) { return(null); } string UserName = MessageSegment.Replace("@", ""); try { WebRequest Req = WebRequest.Create("https://api.twitch.tv/helix/users?login="******"GET"; Req.Headers.Add("Authorization", BotInstance.LoginConfig["Twitch"]["API"]["AuthToken"].ToString()); WebResponse Res = Req.GetResponse(); string StreamString = new StreamReader(Res.GetResponseStream()).ReadToEnd(); Newtonsoft.Json.Linq.JToken JData = Newtonsoft.Json.Linq.JToken.Parse(StreamString); StandardisedUser U = new StandardisedUser(); U.ID = JData["data"][0]["id"].ToString(); U.UserName = UserName; return(U); } catch { return(null); FromTwitchUsername(MessageSegment, BotInstance, Depth + 1); } return(null); }