Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool TwitchEmoteResolver(String emote, bool FFZ)
- {
- if (FFZ)
- {
- XmlDocument xmlDoc = new XmlDocument();
- string xmlStr;
- string cssStr;
- using (var wc = new WebClient())
- {
- cssStr = wc.DownloadString("http://frankerfacez.storage.googleapis.com/global.css");
- xmlStr = wc.DownloadString("http://frankerfacez.storage.googleapis.com/");
- }
- //Check if Global Emote
- if (cssStr.Contains("content: \"" + txtBox.Text + "\""))
- {
- EmoteText = txtBox.Text;
- EmoteURL = "http://frankerfacez.storage.googleapis.com/global/" + txtBox.Text + ".png";
- return true;
- }
- else //Check all other emotes
- {
- xmlDoc.LoadXml(xmlStr);
- XmlNodeList emotes = xmlDoc.GetElementsByTagName("Contents");
- foreach (XmlNode node in emotes)
- {
- if (node.FirstChild.FirstChild.InnerText.Contains("/" + txtBox.Text + ".png"))
- {
- EmoteText = txtBox.Text;
- EmoteURL = "http://frankerfacez.storage.googleapis.com/" + node.FirstChild.FirstChild.InnerText;
- return true;
- }
- }
- }
- }
- else //FFZ == False, check Twitch
- {
- var emotes = JSON.FromUri(new Uri("https://api.twitch.tv/kraken/chat/emoticons"));
- foreach (var emoteSearch in emotes.emoticons)
- {
- if (Regex.IsMatch(txtBox.Text, emoteSearch.regex))
- {
- EmoteText = emoteSearch.regex;
- foreach (var image in emoteSearch.images)
- {
- if (image.emoticon_set == null)
- {
- EmoteURL = image.url;
- break;
- }
- EmoteURL = image.url;
- }
- return true;
- }
- }
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement