mIRC Home    About    Download    Register    News    Help

Print Thread
#247785 26/08/14 02:09 PM
Joined: Aug 2014
Posts: 32
S
Sparkz Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Aug 2014
Posts: 32
I want to have a script where a mod in chat can add quotes to. I currently have this (taken from a normal commands script)

on $*:text:/^!addquote !?(\S+)/iS:#:{
if ($nick !isop #) { return }
writeini quotes.ini # $regml(1) $2-
var %text $read(quotes.txt,1)
if %text == $null {
var %line Commands List: ! $+ $regml(1) $+ ,
}
else {
var %line %text ! $+ $regml(1)
}

write -l1 commandsresonse.txt %line
msg # $nick - A new quote has been added to the quotes file.
}

Problem I am having is that I want a mod to be able to put !quote into chat and have the bot auto pick a random quote from the file and put it in chat. If anyone could please help me with this. I have been trying but I can't get it to work.

Thanks!

Sparkz #247786 26/08/14 02:43 PM
Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
I have no idea how that works from just looking at it.

I made something real quick for you instead:
Code:
on *:text:!quote*:#: $mid($1-,2-)
alias quote {
  if ($1 == add) { 
    if ($nick !isop #) return
    var %n $ini(quotes.ini,#,0)
    inc %n 
    writeini quotes.ini # %n $2-
    msg # Quote $chr(35) $+ %n added. Use !quote $chr(35) $+ %n $+ .
  }
  else {
    var %1 $iif($left($1,1) == $chr(35),$mid($1,2-),$1)
    if (%1 !isnum) { 
      if (%1 == random) {
        var %n $ini(quotes.ini,#,0)
        var %rng $rand(1,%n)
        msg # Quote $chr(35) $+ %rng $+ : $readini(quotes.ini,n,#,%rng)
      }
      else { 
        var %n $ini(quotes.ini,#,0)
        var %i 1
        while (%i <= %n) {
          var %read $readini(quotes.ini,n,#,%i)
          if ($1- isin %read) msg # Quote $chr(35) $+ %i $+ : $v2
          inc %i
        }
      }
    }
    elseif (%1 isnum) { 
      msg # Quote $chr(35) $+ %1 $+ : $readini(quotes.ini,n,#,%1)
    }
  }
}
Tested and working. Not tested extensively however.

Syntax is:
!quote add Text of your choice > Adds quote
!quote random > Returns a random quote
!quote (#1|1) > Returns the first quote.
!quote Text of > Returns any matches.


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Nillen #247793 26/08/14 05:38 PM
Joined: Aug 2014
Posts: 32
S
Sparkz Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Aug 2014
Posts: 32
Thank you so much. Just what I needed.

Nillen #248021 16/09/14 07:05 PM
Joined: Sep 2014
Posts: 52
Babel fish
Offline
Babel fish
Joined: Sep 2014
Posts: 52
How would I change this to display "Quote N does not exist" when someone types in a quote number that hasn't been created yet?

Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
Code:
msg # Quote $chr(35) $+ %1 $+ : $readini(quotes.ini,n,#,%1)
You can make an if statement to check if it exists using only this line as your reference.
/help if then else
/help $iif


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Nillen #248033 17/09/14 06:33 AM
Joined: Sep 2014
Posts: 52
Babel fish
Offline
Babel fish
Joined: Sep 2014
Posts: 52
Got it. Thanks for the help!

Nillen #248331 04/10/14 01:18 AM
Joined: Oct 2014
Posts: 13
B
Pikka bird
Offline
Pikka bird
B
Joined: Oct 2014
Posts: 13
I have a question. I'm still learning IRC, and this code is fantastic but I want to change it so I don't have to put in !quote random for a random quote. I would like to have it just be !quote. Problem is I have no idea where to make that change.

Joined: Dec 2008
Posts: 1,515
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
Originally Posted By: Blondemoscow
I have a question. I'm still learning IRC, and this code is fantastic but I want to change it so I don't have to put in !quote random for a random quote. I would like to have it just be !quote. Problem is I have no idea where to make that change.


Try using this code (NOT TESTED):

Code:
ON !*:TEXT:!*:#: {
  tokenize 32 $strip($1-,burci)
  if ($1 == !quote) {
    if (!$2) { quote random }
    elseif ($2) { quote $2- }
  }
}

alias quote {
  if ($1 == add) { 
    if ($nick !isop #) { return }
    var %n $ini(quotes.ini,#,0)
    inc %n 
    writeini quotes.ini # %n $2-
    msg # Quote $chr(35) $+ %n added. Use !quote $chr(35) $+ %n $+ .
  }
  else {
    var %1 $iif($left($1,1) == $chr(35),$mid($1,2-),$1)
    if (%1 !isnum) { 
      if (%1 == random) {
        var %n $ini(quotes.ini,#,0)
        var %rng $rand(1,%n)
        msg # Quote $chr(35) $+ %rng $+ : $readini(quotes.ini,n,#,%rng)
      }
      else { 
        var %n $ini(quotes.ini,#,0)
        var %i 1
        while (%i <= %n) {
          var %read $readini(quotes.ini,n,#,%i)
          if ($1- isin %read) msg # Quote $chr(35) $+ %i $+ : $v2
          inc %i
        }
      }
    }
    elseif (%1 isnum) { msg # Quote $chr(35) $+ %1 $+ : $readini(quotes.ini,n,#,%1) }
  }
}


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

Link Copied to Clipboard