mIRC Home    About    Download    Register    News    Help

Print Thread
Twitch + Sockets #250795 31/01/15 07:01 AM
Joined: Dec 2014
Posts: 12
W
WhatdaFox Offline OP
Pikka bird
OP Offline
Pikka bird
W
Joined: Dec 2014
Posts: 12
Hello dear community.

I have an issue. I've been creating stuff for my bot but I'm not that good with sockets. I do know that what I'm about to request is delicate.

I need a code to send an automated message on twitch everytime someone subscribes to a specific channel. Why? There we have some info we want to share with subs like servers and teamspeak.

PM me if you think we should keep this out of forums (cuz spam you know?).

Thank you in advance.

Re: Twitch + Sockets [Re: WhatdaFox] #250803 31/01/15 08:49 AM
Joined: Sep 2014
Posts: 259
S
Sakana Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
Doesn't seem possible: http://discuss.dev.twitch.tv/t/how-to-send-private-message-via-api-or-irc/222

I imagine Twitch aren't interested in a feature like that, since it's so abusable.

Re: Twitch + Sockets [Re: Sakana] #250806 31/01/15 10:06 AM
Joined: Dec 2014
Posts: 12
W
WhatdaFox Offline OP
Pikka bird
OP Offline
Pikka bird
W
Joined: Dec 2014
Posts: 12
I do realise it's abusable but I can assure you I wouldn't use for those purposes.

Anyway, people on this forum say it's possible so I'll wait for more answers.

Originally Posted By: Belhifet
You can mass message people if you want, a bot can easily automate a process like this by sending the messages one at a time. I'd highly suggest to not send out automated messages to people though.


Originally Posted By: Belhifet
Then you'd just log in and navigate the site using sockets(http://www.twitch.tv/message/compose) and fill in the "to" box with $nick

Re: Twitch + Sockets [Re: WhatdaFox] #250817 31/01/15 01:48 PM
Joined: Jan 2004
Posts: 1,282
L
Loki12583 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,282
The request to send a message looks like this:
Code:
POST /message/compose HTTP/1.1
Host: www.twitch.tv
Connection: keep-alive
Content-Length: 166
Pragma: no-cache
Cache-Control: no-cache
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Origin: http://www.twitch.tv
User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.35 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Referer: http://www.twitch.tv/message/compose
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8
Cookie: unique_id=xxxxxxxxxxxxxx; __qca=xxxxxxxxxxxxxxx; language=en; persistent=xxxxxxxxxxxxxxxxx; api_token=xxxxxxxxxxxxxxxx; last_login=2015-01-31+13%3A36%3A48+UTC; _twitch_session_id=xxxxxxxxxxxx; mp_xxxxxxxxxxxxxx_mixpanel=%7B%22distinct_id%22%3A%20%22xxxxxxxxxxxxxxxxxxxx%22%2C%22; login=membear; name=Membear; csrf_token=xxxxxxxxxxxxxxxxxxx; __utmli=send

utf8=%E2%9C%93&authenticity_token=xxxxxxxxxxxxxxx%3D&to_login=touser&message%5Bsubject%5D=moo&message%5Bbody%5D=moo


So good luck grabbing the csrf_token and the rest of the cookies. This can be done by reading the cookies of a browser that's already been logged in, or logging in through sockets with mirc itself and keeping all the cookies.

Re: Twitch + Sockets [Re: Loki12583] #250827 31/01/15 08:53 PM
Joined: Dec 2014
Posts: 12
W
WhatdaFox Offline OP
Pikka bird
OP Offline
Pikka bird
W
Joined: Dec 2014
Posts: 12
Originally Posted By: Loki12583
The request to send a message looks like this:
Code:
POST /message/compose HTTP/1.1
Host: www.twitch.tv
Connection: keep-alive
Content-Length: 166
Pragma: no-cache
Cache-Control: no-cache
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Origin: http://www.twitch.tv
User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.35 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Referer: http://www.twitch.tv/message/compose
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8
Cookie: unique_id=xxxxxxxxxxxxxx; __qca=xxxxxxxxxxxxxxx; language=en; persistent=xxxxxxxxxxxxxxxxx; api_token=xxxxxxxxxxxxxxxx; last_login=2015-01-31+13%3A36%3A48+UTC; _twitch_session_id=xxxxxxxxxxxx; mp_xxxxxxxxxxxxxx_mixpanel=%7B%22distinct_id%22%3A%20%22xxxxxxxxxxxxxxxxxxxx%22%2C%22; login=membear; name=Membear; csrf_token=xxxxxxxxxxxxxxxxxxx; __utmli=send

utf8=%E2%9C%93&authenticity_token=xxxxxxxxxxxxxxx%3D&to_login=touser&message%5Bsubject%5D=moo&message%5Bbody%5D=moo


So good luck grabbing the csrf_token and the rest of the cookies. This can be done by reading the cookies of a browser that's already been logged in, or logging in through sockets with mirc itself and keeping all the cookies.



I really appreciate your help but I really dont know how to start. I never liked sockets and this is why I can't do it by myself. Any suggestion?

I have all the cookies but authenticity token. Where do I get it?

Re: Twitch + Sockets [Re: Loki12583] #250860 01/02/15 07:27 PM
Joined: Sep 2014
Posts: 259
S
Sakana Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
That's interesting. This seems to be the process?

1) GET to get the cookies from the main login main page
2) POST to login with those cookies
3) GET in /message/compose to get those cookies
4) POST with those cookies to send the message

So basically 4 sockopen events? That seems doable, but quite painful to write. I've also been shown this script, which is supposed to make it easy to save cookies and log in, but naturally I can't figure out how to make it work ^_^

http://script.quakenet.org/wiki/MHTTP