mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2014
Posts: 2
J
Jay_BHP Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
J
Joined: Dec 2014
Posts: 2
I'm very new to mIRC/coding and have built myself a very basic bot to do commands for !links, etc which works fine, but what i'm looking to do is have a quote system that would be able to pull the game title of what i'm playing for that cast which I assume would be from twitch api and add it to the end of the quote. A few people I know have this type of quote system with their bot so what it will look like when someone does !quote: "Insert quote here" - [Insert Game title here]. I'm wondering if anyone has been able to do something like this before or would have any suggestions as to where I could look to learn how to code this.

Cheers,

Jay (Boom_Headshot_Pod)

Joined: Jun 2014
Posts: 248
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Jun 2014
Posts: 248
You'll need some way to parse json. There are json handlers available for use.

Then you'll just need to retrieve the game title from the api at the time it is entered and append it to the quote.

Joined: Jan 2014
Posts: 107
M
Vogon poet
Offline
Vogon poet
M
Joined: Jan 2014
Posts: 107
Jay_BHP

I'm actually working on this for MajeyeBot.

Once I have it up and working, i'll post it here to help you out.

Joined: Dec 2014
Posts: 2
J
Jay_BHP Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
J
Joined: Dec 2014
Posts: 2
Thank you Majeye! That would be greatly appreciated.

Joined: Aug 2015
Posts: 16
A
Pikka bird
Offline
Pikka bird
A
Joined: Aug 2015
Posts: 16
I already have the twitch api bit done. It's very simple to do you just need a Json parser. There is a great one for mirc located Here http://hawkee.com/snippet/10194/

You would copy paste all the code there into a new remote file.

After that it's really simple
The script would be.

Code:
JSONOpen -u www.api.twitch.tv/kraken/streams/YOURTWITCHNAME
if ( $json(game,stream,game) != $null ) {
msg $chan $nick $+ , the current game is, $json(game,stream,game) $+ .
JSONClose game


}
Else {
msg $chan Sorry $nick the stream is not live
}


You can goto www.api.twitch.tv/kraken/streams/YOURTWITCHNAME to view all the other things you can grab. I recommend installing a Json viewer add on for chrome. It makes it a lot easier to find out the right path for the command. Such as the code for getting the stream title would be

$json(game,stream,channel,status)


Hope I helped

Last edited by acpixel; 19/08/15 09:55 AM.
Joined: Aug 2015
Posts: 13
D
Pikka bird
Offline
Pikka bird
D
Joined: Aug 2015
Posts: 13
I have a working version for this. If this isn't resolved by the time I get home after work I will post what I have. Though acpixel is right on track with using a JSON parser is the best method.

Last edited by Despized; 19/08/15 04:14 PM.
Joined: Aug 2015
Posts: 13
D
Pikka bird
Offline
Pikka bird
D
Joined: Aug 2015
Posts: 13
I was not able to edit my original post. Sorry for the extra day of wait. Though this is all dependent on a JSON parser/get script. I have one that I got off of these forums though I don't recall which one. Though they mainly work the same.

(Wims helped a great deal from these forums and deserves a giant amount of credit I also don't want to leave out that a lot of the basics for this came from searching the forums along with youtube videos.)


Variables used for this script. - Newquote file is the location of my ini file that houses all of my quotes. Quoteid is the current count of how many quotes are in the quote file. This will increase as quotes are added. Though I have not scripted a removal portion at this time.
Code:
%newquotefile D:\Documents\Docs\Streaming\DataSet\quotes.ini
%quoteID 100


Remote.ini portions of my quote script. - There is notes in this portion that I have put as to-do items. Things that are not done yet. Though I believe this will help quite a bit on a few things.
Code:
;Begin the new quotes section
;Need to add permission levels to all of these commands.

;Format: !quoteread (numberofquote)
;Reads out the quote by number requested and then checks to see if it is existing.
;Currently works!
on *:text:!quoteread *:#: {
  if ((%floodquote) || ($($+(%,floodquote.,$nick),2))) { return }
  set -u30 %floodquoteOn
  set -u60 %floodquote. $+ $nick On
  if ($2 <= %quoteID) {
    var %user = $readini(%newquoteFile, n, $2, user)
    var %date = $readini(%newquoteFile, n, $2, date)
    var %quote = $readini(%newquoteFile, n, $2, quote)
    var %game = $readini(%newquotefile, n, $2, game)
    msg $chan Quote $chr(91) $+ $chr(35) $+ $2 $+ $chr(92) $+ %quoteID $+ $chr(93) added by %user on %date while playing %game - $chr(34) $+ %quote $+ $chr(34)
  }
  else {
    msg $chan Quote does not exist $nick
  }
}

;Format: !qlines
;Reads the %quoteID to get the current quote count
;Currently works!
on *:TEXT:!qlines:#: { 
  if ((%floodquote) || ($($+(%,floodquote.,$nick),2))) { return }
  set -u10 %floodquoteOn
  set -u30 %floodquote. $+ $nick On
  msg $chan Total number of quotes: %quoteID
} 

;Format: !qlast
;Reads the last quote of the file and displays it.
;Currently works!
on *:TEXT:!qlast:#: { 
  if ((%floodquote) || ($($+(%,floodquote.,$nick),2))) { return }
  set -u10 %floodquoteOn
  set -u30 %floodquote. $+ $nick On
  var %user = $readini(%newquoteFile, n, %quoteID, user)
  var %date = $readini(%newquoteFile, n, %quoteID, date)
  var %quote = $readini(%newquoteFile, n, %quoteID, quote)
  var %game = $readini(%newquotefile, n, %quoteID, game)
  msg $chan Quote $chr(91) $+ $chr(35) $+ %quoteID $+ $chr(92) $+ %quoteID $+ $chr(93) added by %user on %date while playing %game $+ $chr(34) $+ %quote $+ $chr(34)
} 

; Format: !addQuote (quote text)
;This will add the quote with the date/username/game
;Currently works!
on @*:text:!addQuote*:#: {
  var %user = $nick
  var %date = $chr(91) $+ $adate $+ $chr(93)
  var %quote = $2-
  ;This will be evaluated using json
  jsonopen -ud game https://api.twitch.tv/kraken/channels/dreadfullydespized
  var %game = $chr(91) $+ $json(game,game) $+ $chr(93)
  jsonclose game
  ;create a portion that checks to see if the quote already exists (not done yet)
  writeini -n %newquoteFile $calc(%quoteID + 1) user %user
  writeini -n %newquoteFile $calc(%quoteID + 1) date %date
  writeini -n %newquoteFile $calc(%quoteID + 1) quote %quote
  writeini -n %newquoteFile $calc(%quoteID + 1) game %game

  msg $chan /me Quote $calc(%quoteID + 1) is from %user while playing %game during %date saying %quote
  inc %quoteID
}


quotes.ini file should look something like this.
Code:
[1]
user=derrf
date=[12/25/2014]
quote=Cheese Graters in the Morning
game=[DayZ]

[2]
user=shadywaffle
date=[01/10/2015]
quote=Im like a worm in grass. Wiggle wiggle
game=[DayZ]

[3]
user=ragegamestudios
date=[02/13/2015]
quote=only way to get views is through a little leg
game=[DayZ]


Link Copied to Clipboard