Twitch bot which post commands to hastebin - 14/01/15 11:05 AM
Hello!
I have made a twitchbot that you can add/delete custom commands to stored in a file. Instead of posting all commands in the twitch chat I want it to post them to hastebin. I have managed to do so, and I save the link to a global variable. The problem is however that my bot post the previous link to twitchchat instead of the newest. after my bot posts in twitchchat, i check my global variables and %hastelink is the newest link. Somehow my bot posts the old link before it gets updated.
Here is some of my code:
I can add the socketread too so you see how i set the global variable:
I have made a twitchbot that you can add/delete custom commands to stored in a file. Instead of posting all commands in the twitch chat I want it to post them to hastebin. I have managed to do so, and I save the link to a global variable. The problem is however that my bot post the previous link to twitchchat instead of the newest. after my bot posts in twitchchat, i check my global variables and %hastelink is the newest link. Somehow my bot posts the old link before it gets updated.
Here is some of my code:
Code:
;## the http alias is working as intended and post the variable, then find the key using socketread and sets the link to a global variable. /http post http://hastebin.com/documents/ %allcoms msg $chan Volcania Custom commands: %hastelink
I can add the socketread too so you see how i set the global variable:
Code:
on *:sockread:http.*:{ var %http.read sockread %http.read tokenize 32 %http.read if (!$1) return .signal -n http $1- if (HTTP/1.* 200 OK iswm $1-) echo $color(info) -s HTTP $hget(http,method) request to $hget(http,url) successful! while ($sockbr) { if (*{"key":* iswm %http.read) { unset %hastelink unset %hastekey set %hastekey $gettok($gettok(%http.read,4,34),1,44) set %hastelink http://hastebin.com/ $+ %hastekey echo -s Key : %hastelink } sockread %http.read } }