mIRC Home    About    Download    Register    News    Help

Print Thread
Running commercials with the API #246465 12/06/14 04:12 PM
Joined: Mar 2014
Posts: 215
J
judge2020 Offline OP
Fjord artisan
OP Offline
Fjord artisan
J
Joined: Mar 2014
Posts: 215
I am a little confused with using the twitch API and sockets, I would like to start from the beginning. I would like to be able to run commercials ever 20 or so minutes, and as i talked to xangold (xanbot) editors cannot run commercials through chat, so .commercial is completely useless. To do this you must run the API and sockets.
1. I have already requested the Client ID, how do i use this?
2. I have opened the json in the mIRC remote.
3. i installed the SSL library.

So can i get a noob-friendly guide on what to do next?


#imAbeginner
i made a chat bot for mark_paintball! http://twitch.tv/mark_paintball
Re: Running commercials with the API [Re: judge2020] #246483 13/06/14 04:45 AM
Joined: Apr 2014
Posts: 191
B
blessing Offline
Vogon poet
Offline
Vogon poet
B
Joined: Apr 2014
Posts: 191
You use client ID to request access token.

Re: Running commercials with the API [Re: blessing] #246486 13/06/14 12:50 PM
Joined: Mar 2014
Posts: 215
J
judge2020 Offline OP
Fjord artisan
OP Offline
Fjord artisan
J
Joined: Mar 2014
Posts: 215
How do i do that?


#imAbeginner
i made a chat bot for mark_paintball! http://twitch.tv/mark_paintball
Re: Running commercials with the API [Re: judge2020] #246487 13/06/14 03:42 PM
Joined: Jul 2003
Posts: 40
H
HadS Offline
Ameglian cow
Offline
Ameglian cow
H
Joined: Jul 2003
Posts: 40
Ok, you want to program a twich's bot through mIRC and you're seems to be new to programation. No offense here.

Don't be hasted and don't try now to create/improve your bot I you're learning programming.

I advise you to read with attention the mIRC help file in order to get the importants programimng's concepts. If/Else, loop, %variable, strings, dialog, function, events, sockets, etc...
If you have questions about these concepts, feel free to request help, The community will certainly answer you.

I answered you yesterday on a different topic. I had explained you how to make your code correct, wich mIRC's concept you shoud know and I even wrote the correct code for you. You didn't answered.

I think you only want users make code for you.





Last edited by HadS; 13/06/14 03:51 PM.
Re: Running commercials with the API [Re: HadS] #246488 13/06/14 03:46 PM
Joined: Jan 2004
Posts: 1,302
L
Loki12583 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,302
He's been here for three months asking the most basic questions; I agree that he wants things done for him. Through multiple topics I've guided him through this process. He's commented on another topic where I gave the code to start commercials.

This contains everything you need to know, if after reading the help files on a specific command you still don't understand, then fine. But don't respond with "how does this work", "this doesn't work", or "what do I do now".

https://gist.github.com/memnochxx/5676bef5707a8019f0ca

Last edited by Loki12583; 13/06/14 04:00 PM.
Re: Running commercials with the API [Re: Loki12583] #246489 13/06/14 03:54 PM
Joined: Jul 2003
Posts: 40
H
HadS Offline
Ameglian cow
Offline
Ameglian cow
H
Joined: Jul 2003
Posts: 40
Thank you for that clarification wink

Re: Running commercials with the API [Re: judge2020] #246507 15/06/14 05:12 AM
Joined: Apr 2014
Posts: 191
B
blessing Offline
Vogon poet
Offline
Vogon poet
B
Joined: Apr 2014
Posts: 191
You can do it manually using this link
Code:
https://api.twitch.tv/kraken/oauth2/authorize?response_type=token&client_id=[your client ID]&redirect_uri=http://localhost&scope=channel_commercial

Just replace [your client ID] with your client ID.
Then you will be directed to error page which is fine.
If you do it correctly, you will see your access token at the url/address bar.
Copy and save it in your file for future reference.


Re: Running commercials with the API [Re: blessing] #246646 23/06/14 09:31 PM
Joined: Mar 2014
Posts: 215
J
judge2020 Offline OP
Fjord artisan
OP Offline
Fjord artisan
J
Joined: Mar 2014
Posts: 215
Sorry if this is a bad question, but how do i open the menu on line 355 so i can run the twitch.setup alias?
also put my client ID in the CLIENT_ID_HERE that was on line 347


#imAbeginner
i made a chat bot for mark_paintball! http://twitch.tv/mark_paintball
Re: Running commercials with the API [Re: judge2020] #246648 24/06/14 12:30 AM
Joined: Jan 2004
Posts: 1,302
L
Loki12583 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,302
If you need to reinitialize the twitch.ini file, then you can delete the file and access the menu from the right click menu in your channel. Or you could just call the alias from the command line...

And you're meant to only edit the client id in the ini file, not the script itself, but changing it in the file won't really hurt anything.

Re: Running commercials with the API [Re: Loki12583] #246652 24/06/14 01:04 PM
Joined: Mar 2014
Posts: 215
J
judge2020 Offline OP
Fjord artisan
OP Offline
Fjord artisan
J
Joined: Mar 2014
Posts: 215
I am getting insufficient parameeters when i try to run the alias, i expect it's because in the last writeini in twitch.setup says %chan instead of $chan, but if that is not the reason correct me.

I looked at your post about the following user, and this is what my twitch.ini looks like: (i do fill in those fields with my ID and token)

Also cannot find that menu in the right-click menu of my channel, maybe i'm clicking in the wrong place but i could not find it.


#imAbeginner
i made a chat bot for mark_paintball! http://twitch.tv/mark_paintball
Re: Running commercials with the API [Re: judge2020] #246654 24/06/14 02:10 PM
Joined: Jan 2004
Posts: 1,302
L
Loki12583 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,302
It's not because of %chan, %chan is set either by the parameters passed to the alias or by $mnick. You should have more scopes listed for your channel, but I'll guess that's just because you didn't show the whole file.

The only thing that could be preventing the menu from showing is syntax errors or missing parts to the script. Could you please paste the exact errors you're getting and the entire contents of the script file here:

http://pastebin.com/

*Edit, the menu would also not show if the twitch.ini file exists but the channel does not have a client_id or token set.

Last edited by Loki12583; 24/06/14 02:59 PM.
Re: Running commercials with the API [Re: Loki12583] #246655 24/06/14 05:55 PM
Joined: Mar 2014
Posts: 215
J
judge2020 Offline OP
Fjord artisan
OP Offline
Fjord artisan
J
Joined: Mar 2014
Posts: 215
I got the menu working by pasting twitch.mrc again. Also that image from earlier was me pasting it in there myself. Basically starting over, deleting that file, I clicked the 'twitch setup' and set up the file with my client ID. When i use the 'request token' menu I get an error "Could not retrieve token", Could this be from requesting a token before with blessing's link?


#imAbeginner
i made a chat bot for mark_paintball! http://twitch.tv/mark_paintball
Re: Running commercials with the API [Re: judge2020] #246656 24/06/14 06:10 PM
Joined: Jan 2004
Posts: 1,302
L
Loki12583 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,302
I've tested the token retrieval under IE 11, Firefox 30, and Chrome 37. What browser and OS are you using? If using NoScript, make sure to allow the page instead of clicking the link it provides.

If the url of the page contains an #access_token=xxxxxx string, you can manually copy this token into twitch.ini under your channel's section as token=xxxxxx. If the url does not contain that string, please respond with what it does contain. Requesting multiple tokens should not be a problem.

Last edited by Loki12583; 24/06/14 06:17 PM.
Re: Running commercials with the API [Re: Loki12583] #246657 24/06/14 07:15 PM
Joined: Mar 2014
Posts: 215
J
judge2020 Offline OP
Fjord artisan
OP Offline
Fjord artisan
J
Joined: Mar 2014
Posts: 215
I was getting an error but just now i tried and it worked o_o. Now I have all the scopes.

It's all setup now, I created a simple !follow command for people in the chat to get a free follower. Now when i try to run a commercial with the !commercial or the commercial right-click menu It doesn't run the commercial, and i don't get an error [one that goes in the chat], i get this error in my status window:
Code:
* /sockopen: 'twitch.follow.1239193423' socket in use (line 38, twitch.mrc)

EDIT: also happens when i try !topic, I know i have editor permissions but it seems to not be working smirk

Last edited by judge2020; 24/06/14 08:41 PM.

#imAbeginner
i made a chat bot for mark_paintball! http://twitch.tv/mark_paintball
Re: Running commercials with the API [Re: judge2020] #246660 24/06/14 08:50 PM
Joined: Jan 2004
Posts: 1,302
L
Loki12583 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,302
$ticks is not sufficient to create a unique socket name if called quickly enough, you can instead increment a variable to use before naming the socket.

Code:
inc -e %nonce
var %sockname = twitch.follow. $+ %nonce


I've updated the code to include this "nonce" (only for twitch.follow at this point, although I should do it for every socket). I've also added a window to display errors, at this point only errors for commercials are displayed. You can reach the debug window named Twitch.tv under the Window item in the menubar. If you are unsure what the errors mean, please report what they are.

As always you can see the specific changes by checking the revisions page (these changes are split over two revisions): https://gist.github.com/memnochxx/5676bef5707a8019f0ca/revisions


*Edit: if you aren't calling these things too quickly it sounds like you have the script loaded twice.

Last edited by Loki12583; 24/06/14 09:00 PM.
Re: Running commercials with the API [Re: Loki12583] #246664 25/06/14 06:34 AM
Joined: Mar 2014
Posts: 215
J
judge2020 Offline OP
Fjord artisan
OP Offline
Fjord artisan
J
Joined: Mar 2014
Posts: 215
Loading up your revision, the menu for request token on the channel my bot moderates shows up. Doing this i got the commercials and topic and all that loaded up smile
Thanks, if i am in critical need of help i'll let you know.


#imAbeginner
i made a chat bot for mark_paintball! http://twitch.tv/mark_paintball