mIRC Home    About    Download    Register    News    Help

Print Thread
Channel bound variables.. #252875 15/05/15 12:14 AM
Joined: Oct 2014
Posts: 49
JB_uk Offline OP
Ameglian cow
OP Offline
Ameglian cow
Joined: Oct 2014
Posts: 49
Hi all, the following script is concerning the activation of auto timed messages in a channel by the bot. I'm trying to do it so that it can run in multiple channels and the timer name will be different for each channel as shown by the $chan part in the timer name and name of the variables. This script in its current form doesn't seem to spew out any of the text in the file that it is reading from.

It is activated by typing the command followed by a number so then the messages are displayed every so many minutes
i.e. if the user typed !autocom 2 The messages would display every 2 minutes...

Code:
on *:TEXT:!autocom *:#: {
  if ($2 == off) { return }
  var %TimeAuto $2 
  var %FinalTimeAuto $+ $chan = %TimeAuto * 60
  if ($nick == $remove($chan,$chr(35))) {
    msg # /me AutoCom: ON
    .timerNow $+ $chan 72 (%FinalTimeAuto $+ $chan) Linksall #
    return
  }
  else { msg # $nick -> You do not have permission to perform this action. }
}

alias Linksall { 
  var %chan $1
  var %lines $lines(linksall $+ $remove($chan,$chr(35)).txt)
  if (!%counter) || (%counter > %lines) set %counter 1
  var %msg $read(linksall $+ $remove($chan,$chr(35)).txt,%counter)
  msg %chan %msg
  inc %counter
}

Any ideas lads?

Re: Channel bound variables.. [Re: JB_uk] #252889 15/05/15 06:02 PM
Joined: May 2015
Posts: 249
splinny Offline
Fjord artisan
Offline
Fjord artisan
Joined: May 2015
Posts: 249
You dont need unique %var`s for your script, "var %FinalTimeAuto = %TimeAuto * 60" is enough.
In your alias, you dont have $chan - you have only %chan (but using just $1 is shorter, instead of "var %chan = $1").


Dont give a fish - teach to fish!
Re: Channel bound variables.. [Re: splinny] #252890 15/05/15 06:08 PM
Joined: Jan 2004
Posts: 1,302
L
Loki12583 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,302
var %chan = $1 is better practice than assuming $1 will always be the channel; and it's more readable.

Re: Channel bound variables.. [Re: Loki12583] #252892 15/05/15 06:21 PM
Joined: May 2015
Posts: 249
splinny Offline
Fjord artisan
Offline
Fjord artisan
Joined: May 2015
Posts: 249
Var %chan, which wont be a chan name?)


Dont give a fish - teach to fish!
Re: Channel bound variables.. [Re: splinny] #252893 15/05/15 07:26 PM
Joined: Jan 2004
Posts: 1,302
L
Loki12583 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,302
Why wouldn't it be? He's passing # to the alias as $1.

Re: Channel bound variables.. [Re: JB_uk] #252901 16/05/15 01:30 PM
Joined: Feb 2015
Posts: 243
O
OrFeAsGr Offline
Fjord artisan
Offline
Fjord artisan
O
Joined: Feb 2015
Posts: 243
Code:
on *:TEXT:!autocom *:#: {
  if ($2 == off) { unset %counter | msg $chan Timed Messages For $chan Is Now Off }
  set $+(%,FinalTimeAuto,$chan) $calc($2 * 60)
  if ($nick == $remove($chan,$chr(35))) {
    describe $chan AutoCom: ON
    $+(.timerNow,$chan) 72 $($+(%,FinalTimeAuto,$chan),2) Linksall $chan
    return
  }
  else { msg # $nick -> You do not have permission to perform this action. }
}

alias Linksall { 
  var %chan = $remove($1,$chr(35))
  var %lines = $lines(linksall $+ %chan $+ .txt)
  if (!%counter) || (%counter > %lines) { set %counter 1 }
  var %msg = $read(linksall $+ %chan $+ .txt,%counter)
  msg $1 %msg
  inc %counter
}

Hi smile I modified some parts and it worked fine when i tested it.
Try it!!
Enjoy!!!