mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2007
Posts: 280
Fjord artisan
OP Offline
Fjord artisan
Joined: Jan 2007
Posts: 280
Hi, ive got this quote script with add, del etc. but I can't figure out how to fix the bug that whenever somebody adds a quote, it DOES add the WHOLE line, but whenever somebody requests to read THAT quote, it doesn't show the whole line at all! example:

14.52.30: <%DJ-Serv> (QUOTE #272/#272) ¿Yoeri? zegt: wies de ongelukkige?||(6)DevilShadow(6) zegt: hou je bek homo||¿Yoeri? zegt: ik weet 1 ding zeker, dak geen homo ben. hoe heet hij ?||¿Yoeri? zegt: en k denk dat t een hij is omdat je me homo noemt uit t oogpunt van projectie: Projectie is een reflectie van je eigen karaktereigenschappen en visies gecombineerd met je levenservaringen geprojecteerd op datgene dat je niet kent van de andere pe

At 'pe' it stops and still had to message about 50 letters/characters more. Is there a way to put those letters/characters, who are left behind, in a SECOND line when messaging?

The add and 'request' parts are:


Code:
 if $1 == .addquote {
    write %quotes_file $2-  $+ %sys_color2 $+ ( $+ $nick at  $+ %sys_color $+ $date $+  $+ %sys_color2 $+ / $+ %sys_color $+ $time $+  $+ %sys_color2 $+ )
    write %quotes_onlinefile $2- ||  $+ $chr(37) $+ color $+ ( $+ Toegevoegd door $nick op $fulldate $+ )
    upload %quotes_onlinefile
    msg %logchan %logsyntax The new quote has been added.
  }


Code:
 if $1 == .quote {
    if $2 == 1 { 
      msg $chan  $+ %sys_color $+ ( $+ %sys_color2 $+ QUOTE $+ %sys_color $+ ) This quote was a test quote. Not available for IRC.
      msg %logchan %logsyntax  $+ $nick $+  requested "quote" in " $+ $chan $+ ", but an error has occured (test quote).
      halt
    }
    else {
      if ($2 isnum) && ($2 <= $lines(%quotes_file)) && $2 != 248 {
        msg $chan  $+ %sys_color $+ ( $+ %sys_color2 $+ QUOTE $chr(35) $+ $2 $+ $chr(47) $+ $lines(%quotes_file) $+  $+ %sys_color $+ ) $read(%quotes_file, $2) 
        msg %logchan %logsyntax  $+ $nick $+  requested "quote" in " $+ $chan $+ ", no errors have occured.
      }
    }
  }


Squee whenever a squee squee's. Squee whenever a squee does not squee.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
You basically have 2 options. You can just split the line at a fixed number of characters (about 400 works for most networks). This is easy, but means words will split.

Code:
    else {
      if ($2 isnum) && ($2 <= $lines(%quotes_file)) && $2 != 248 {
        var %quote = $read(%quotes_file, $2)
        msg $chan  $+ %sys_color $+ ( $+ %sys_color2 $+ QUOTE $chr(35) $+ $2 $+ $chr(47) $+ $lines(%quotes_file) $+  $+ %sys_color $+ ) $left(%quote,400)
        msg $chan  $+ %sys_color $+ ( $+ %sys_color2 $+ QUOTE $chr(35) $+ $2 $+ $chr(47) $+ $lines(%quotes_file) $+  $+ %sys_color $+ ) $right(%quote,-400)
        msg %logchan %logsyntax  $+ $nick $+  requested "quote" in " $+ $chan $+ ", no errors have occured.
      }
    }


Note that you can of course edit the format of that.

The other option is to scan words to find a suitable line break location. This is somewhat slower, but shouldn't be noticeable.

Code:
    else {
      if ($2 isnum) && ($2 <= $lines(%quotes_file)) && $2 != 248 {
        var %quote = $read(%quotes_file, $2)
        var %c = 1, %t = $numtok(%quote,32)
        while (%c <= %t) {
          var %quote.line = %quote.line $gettok(%quote,%c,32)
          if ($len(%quote.line) > 400) {
            msg $chan  $+ %sys_color $+ ( $+ %sys_color2 $+ QUOTE $chr(35) $+ $2 $+ $chr(47) $+ $lines(%quotes_file) $+  $+ %sys_color $+ ) %quote.line
            unset %quote.line
          }
          inc %c
        }
        if (%quote.line) {
          msg $chan  $+ %sys_color $+ ( $+ %sys_color2 $+ QUOTE $chr(35) $+ $2 $+ $chr(47) $+ $lines(%quotes_file) $+  $+ %sys_color $+ ) %quote.line
        }
        msg %logchan %logsyntax  $+ $nick $+  requested "quote" in " $+ $chan $+ ", no errors have occured.
      }
    }


The useful thing with the second method is that it will automatically split the line as many times as necessary. Of course, you're still limited to how long the variable can be and displaying too many lines at once can get you flooded off the network. You can adjust each "400" to whatever number works best for the network you're using. Again, you can edit formatting if desired.


Invision Support
#Invision on irc.irchighway.net
Joined: Jan 2007
Posts: 280
Fjord artisan
OP Offline
Fjord artisan
Joined: Jan 2007
Posts: 280
Thanks a lot! Works fine, both of them.
I've done that too with 'lastquote' and 'randquote', works fine!


I've just got 1 question left, maybe if you could help. I've tried i myself but I couldn't quite figure out how to use it.


I'm trying to let my bot msg the line and total lines (simple: $lines(%quotes_file) ) of the quote he is currently messaging when somebody requested .randquote

This is what it messages now:

11.40.19: <~DJ-Serv> (QUOTE) (21:17:38) -=(+King)=- Wij houden allemaal allemaal van wes (Wes at Thu Nov 12 21:17:27 2009)


But I want it like this:


11.40.19: <~DJ-Serv> (QUOTE #<line_of_quote>/<totalquotes>) (21:17:38) -=(+King)=- Wij houden allemaal allemaal van wes (Wes at Thu Nov 12 21:17:27 2009)


The total quotes is simple, I just need to add $lines(%quotes_file). But the 'line_of_quote', I don't know. Could you help?


Without totalquotes:
Code:
if $1 == .randquote {
    var %quotes = $read(%quotes_file)
    msg $chan  $+ %sys_color $+ ( $+ %sys_color2 $+ QUOTE $+  $+ %sys_color $+ ) $read(%quotes_file)
  }


With totalquotes:
Code:
if $1 == .randquote {
    var %quotes = $read(%quotes_file)
    msg $chan  $+ %sys_color $+ ( $+ %sys_color2 $+ QUOTE $chr(35) $+ <needs_to_be_quoteline> $+ $chr(47) $+ $lines(%quotes_file) $+  $+ %sys_color $+ ) 
  }




EDIT: I've forgotten to say something. I was wrong about the 'fact' that it DID add the WHOLE line of someone who add's a quote. Well, it doesn't add the whole quote. Is there any option available for too? That it DOES add the WHOLE line someone adds? (When its very long)

Last edited by DuXxXieJ; 12/03/10 12:22 PM.

Squee whenever a squee squee's. Squee whenever a squee does not squee.
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Use $readn for the line number you just read, e.g.

Code:
var %quote = $read(somefile,n)
msg $chan Random quote no. $readn of $lines(somefile) is: %quote


Note how "%quote" is used in the second line (instead of reading another random line with a different number).
Also note the ",n" in $read(somefile,n). Without that n-switch, mIRC will evaluate the line it reads. This may seriously exploit you, especially if other users are allowed to add quotes unaudited.

About your script not adding the whole quote: long messages are truncated by the IRC server in the first place, so most likely your script simply isn't receiving the whole quote. You can check this with some easy /echo debugging.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
As far as displaying the quote number, you're using $2 as the quote number for reading it from the file. So just use $2 of $lines(%quotes_file) or format it however you want to.

And, Horstl is right about why you're likely missing some of the quotes - you can only add the full quote if the entire quote gets send through the channel, which may not happen if it's too long. Tell people to keep quotes smaller. smile

And using ,n in $read is a good suggestion.


Invision Support
#Invision on irc.irchighway.net
Joined: Jan 2007
Posts: 280
Fjord artisan
OP Offline
Fjord artisan
Joined: Jan 2007
Posts: 280
Well, the weird thing is that their whole quote gets send, but not added. frown

The ,n in $read works fine. But my colors won't work anymore. If I remove the ,n it does. How to fix?


Squee whenever a squee squee's. Squee whenever a squee does not squee.
Joined: Feb 2009
Posts: 133
C
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2009
Posts: 133
i think better to use hash tables if u have colors in data


WorldDMT
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
The whole quote getting send to the server (without error) does not mean it's received by other clients untruncated. smile


About the n switch: I suggest you write only "raw" data into your file ($nick, $ctime and the quote). The formatting / coloring could go into your output routine instead. Example:
Code:
  [...]

  if ($1 == .addquote) {
    write %quotes_file $ctime $nick $2-
    [...]
  }

  elseif ($1 == .quote) && ($2 isnum 1-) && ($read(%quotes_file,n,$2)) {

  ; $v1 is now the unformatted line as read from the file (i.e. non-evaluated)
  ; now calculate the first "word" back into date/time, take the second "word" for the nick, the remaining is the quote itself.
  var %date = $date($gettok($v1,1,32)), %time = $time($gettok($v1,1,32)), %nick = $gettok($v1,2,32), %quote = $gettok($v1,3-,32)

  ; having these put in variables, you can easily create your colored output line (example only)
  var %quote =  $+ %sys_color2 $+ QUOTE $readn of $lines(%quotes_file) (by %nick on %date - %time $+ ): %quote

  ; "%quote" is now the formatted line and may be sent to the chan (or split into multiple lines first, like in the code by Riamus2)
  [...]

  }



Link Copied to Clipboard