mIRC Homepage

Quote system for twitch bot.

Posted By: Jay_BHP

Quote system for twitch bot. - 29/12/14 06:04 AM

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.


Jay (Boom_Headshot_Pod)
Posted By: Belhifet

Re: Quote system for twitch bot. - 29/12/14 06:14 AM

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.
Posted By: Majeye

Re: Quote system for twitch bot. - 30/12/14 09:35 AM


I'm actually working on this for MajeyeBot.

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

Re: Quote system for twitch bot. - 09/01/15 10:16 PM

Thank you Majeye! That would be greatly appreciated.
Posted By: acpixel

Re: Quote system for twitch bot. - 19/08/15 09:53 AM

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.

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


Hope I helped
Posted By: Despized

Re: Quote system for twitch bot. - 19/08/15 04:13 PM

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.
Posted By: Despized

Re: Quote system for twitch bot. - 21/08/15 12:41 AM

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.
%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.
;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.
quote=Cheese Graters in the Morning

quote=Im like a worm in grass. Wiggle wiggle

quote=only way to get views is through a little leg
© 2021 mIRC Discussion Forums