mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: May 2015
Posts: 249
splinny Offline OP
Fjord artisan
OP Offline
Fjord artisan
Joined: May 2015
Posts: 249
Twitch has its own chat groups, and to check which you are invited at (or created) you can check http://chatdepot.twitch.tv/room_memberships?oauth_token=[your_oauth_token_(w\o_"oauth:")]. And this link works fine with JSON.
And i found an old list of commands to manage this groups via sockets, but only DELETE works fine (each requires oauth_token=[your_token]):
to create: POST https://chatdepot.twitch.tv/rooms?irc_channel={irc_channel}&display_name={display_name}
to modify: PUT https://chatdepot.twitch.tv/rooms/{irc_channel}?public_invites_enabled={public_invites_enabled}&display_name={display_name}
({public_invites_enabled} = 1 or 0)
to invite: POST https://chatdepot.twitch.tv/room_memberships?irc_channel={irc_channel}&username={username}
to delete: DELETE https://chatdepot.twitch.tv/rooms/{irc_channel}

I tried firefox plugin to check headers and requests, which are sent when you use twitch`s own interfce to do this actions, and it looks same, but using sockets i get only "400 Bad Request". So is it possible to recreate browser`s actions via sockets? Maybe i am missing something.


Dont give a fish - teach to fish!
Joined: Dec 2008
Posts: 1,515
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
Well 400 code error is that you are trying to PUT/DELETE/GET/POST an incorrect link, also it would be good to show us your code so it can be more clear.


Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-
Joined: May 2015
Posts: 249
splinny Offline OP
Fjord artisan
OP Offline
Fjord artisan
Joined: May 2015
Posts: 249
alias test {
if ($sock(test)) { sockclose test }
sockopen test chatdepot.twitch.tv 80
; sockmark test $1
}

on *:sockopen:test:{
sockwrite -n $sockname POST https://chatdepot.twitch.tv/room_members...e=2nd_user_name HTTP/1.1
sockwrite -n $sockname Host: $sock($sockname).addr
sockwrite -n $sockname user-agent: Mozilla/*
sockwrite -n $sockname Connection: close
sockwrite -n $sockname $crlf
}

on *:sockread:test:{
if ($sockerr > 0) return
:nextread
sockread %temp
if ($sockbr == 0) return
echo -ag 1: %temp
goto nextread
}


Dont give a fish - teach to fish!
Joined: Dec 2008
Posts: 1,515
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
First of all you are trying to connect into an SSL server but your /sockopen does not has the correct port and did not had -e parameter (/help /sockopen)

Second you dont have to put the HOLE url link into the POST.

And please next code post please use "[ code ] [ /code ]" forum quotes because the copy paste (e.g: the link) was incorrect.

Give a try this:

Code:
alias testt {
  if ($sock(testing)) { sockclose testing }
  sockopen -e testing chatdepot.twitch.tv 443
  ; sockmark test $1
}

on *:sockopen:testing: {
  if ($sockerr) { sockclose $sockname | return }
  sockwrite -nt $sockname POST /room_memberships?oauth_token=my_token&irc_channel=_my_channel_1433531105324&username=2nd_user_name HTTP/1.1
  sockwrite -n $sockname Host: $sock($sockname).addr
  sockwrite -n $sockname User-Agent: Mozilla/*
  sockwrite -n $sockname Connection: close
  sockwrite -nt $sockname $crlf
}

on *:sockread:testing:{
  if ($sockerr) { sockclose $sockname | return }
  sockread %temp
  if ($sockbr) { echo 2 -a READ: $left(%temp,4098) }
}


I cannot full test it because i dont have the oauth token.


Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-
Joined: May 2015
Posts: 249
splinny Offline OP
Fjord artisan
OP Offline
Fjord artisan
Joined: May 2015
Posts: 249
READ: HTTP/1.1 400 Bad Request
READ: Server: nginx
READ: Date: Sat, 06 Jun 2015 08:46:47 GMT
READ: Content-Type: text/plain; charset=utf-8
READ: Content-Length: 120
READ: Connection: close
READ:

Code:
To get your token - http://www.twitchapps.com/tmi/
To get channel name - create group at twitch chat and check http://chatdepot.twitch.tv/room_memberships?oauth_token=YOUR_TOKEN


Dont give a fish - teach to fish!
Joined: Dec 2008
Posts: 1,515
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
Try use this code:

Code:
alias testt {
  if ($sock(testing)) { sockclose testing }
  sockopen -e testing chatdepot.twitch.tv 443
}

on *:sockopen:testing: {
  if ($sockerr) { sockclose $sockname | return }
  var %o = YOUR_OAUTH_TOKEN
  var %c = THE_CHANNEL
  var %n = THE_NICKNAME
  var %u = oauth_token= $+ %o $+ &irc_channel= $+ %c $+ &username= $+ %n
  sockwrite -nt $sockname POST /room_memberships HTTP/1.1
  sockwrite -nt $sockname Host: $sock($sockname).addr
  sockwrite -nt $sockname User-Agent: Mozilla/*
  sockwrite -nt $sockname Accept: application/json, text/javascript, */*; q=0.01
  sockwrite -nt $sockname Content-Type: application/x-www-form-urlencoded; charset=UTF-8
  sockwrite -nt $sockname Authorization: OAuth %o
  sockwrite -nt $sockname Cache-Control: no-cache
  sockwrite -nt $sockname Connection: keep-alive
  sockwrite -nt $sockname Content-Length: $len(%u)
  sockwrite -nt $sockname $+($crlf,%u)
}

on *:sockread:testing:{
  if ($sockerr) { sockclose $sockname | return }
  sockread %temp
  if ($sockbr) { echo 2 -a READ: $left(%temp,4098) }
}


Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-

Link Copied to Clipboard