mIRC Home    About    Download    Register    News    Help

Print Thread
Command that adds/removes a command #244452 28/02/14 10:35 PM
Joined: Feb 2014
Posts: 16
L
LooseFlapper Offline OP
Pikka bird
OP Offline
Pikka bird
L
Joined: Feb 2014
Posts: 16
I know there's quite a few of these around but they were either not working for me or not what I was looking for.

I would like to create a script that allows OPs to use the following commands.

Quote:
!commandadd <!commandname> <text>
!commandremove <!commandname>

So for example if an OP types
Quote:
!commandadd !apples I love apples.

Whenever any other OP types !apples, it should reply 'I love apples'.


Thank you. smile


EDIT:
I would also like to be able to put the commands on a timer. smile Something like !repeat <!command> 120 and it should repeat every 120 seconds and then !repeat <!command> off. smile

Last edited by LooseFlapper; 01/03/14 12:14 AM.

/Loose
Re: Command that adds/removes a command [Re: LooseFlapper] #244453 01/03/14 12:34 AM
Joined: Jan 2004
Posts: 1,276
L
Loki12583 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,276
Looks like in my original response there was a problem with the text event to match the added commands, the regex needed to be surrounded in //: http://forums.mirc.com/ubbthreads.php/topics/244404/Re:_Need_help_withmaking_a_add#Post244404

This is tested and working:

Code:
on $*:text:/^!commandadd !?(\S+)/iS:#test:{
  if ($nick !isop #) return
  writeini commands.ini commands $regml(1) $$3-
}

on $*:text:/^!commandremove !?(\S+)/iS:#test:{
  if ($nick !isop #) return
  remini commands.ini commands $regml(1)
}

on $*:text:/^!repeat !?(\S+) (off|\d+)/iS:#test:{
  if ($nick !isop #) return
  
  var %command = $regml(1), %interval = $regml(2)
  
  if ($timer(command. $+ %command)) {
    if (%interval == off) .timercommand. $+ %command off
    else msg # ! $+ %command is already repeating
  }
  elseif ($readini(commands.ini,n,commands,%command)) {
    var %response = $v1
    .timercommand. $+ %command 0 $iif(%interval < 5,5,%interval) msg # $safe(%response)
    msg # %response
  }
}

on $*:text:/^!(\S+)/:#test:{
  if ($nick !isop #) return
  if ($readini(commands.ini,n,commands,$regml(1))) msg # $v1
}

alias safe return $!decode( $encode($1,m) ,m)

Re: Command that adds/removes a command [Re: Loki12583] #244454 01/03/14 12:53 AM
Joined: Feb 2014
Posts: 16
L
LooseFlapper Offline OP
Pikka bird
OP Offline
Pikka bird
L
Joined: Feb 2014
Posts: 16
Thank you Loki. smile <3


/Loose
Re: Command that adds/removes a command [Re: Loki12583] #244455 01/03/14 01:16 AM
Joined: Feb 2014
Posts: 16
L
LooseFlapper Offline OP
Pikka bird
OP Offline
Pikka bird
L
Joined: Feb 2014
Posts: 16
Is there a way to make the repeats stop repeating when no messages have been sent since the last repeat? smile


/Loose
Re: Command that adds/removes a command [Re: LooseFlapper] #244457 01/03/14 03:11 PM
Joined: Feb 2014
Posts: 16
L
LooseFlapper Offline OP
Pikka bird
OP Offline
Pikka bird
L
Joined: Feb 2014
Posts: 16
Or maybe make it an option for OPs. Something like
!repeat !apples 120 20
Where it will repeat the command !apples every 120 seconds if there has been 20 messages since last repeat.


/Loose
Re: Command that adds/removes a command [Re: LooseFlapper] #245006 08/04/14 08:09 PM
Joined: Mar 2014
Posts: 72
A
AllDayGrinding Offline
Babel fish
Offline
Babel fish
A
Joined: Mar 2014
Posts: 72
What would I have to type in chat to add a command or remove a command? like !commandadd !hello Welcome to the stream?

Re: Command that adds/removes a command [Re: Loki12583] #245147 11/04/14 09:00 PM
Joined: Mar 2014
Posts: 72
A
AllDayGrinding Offline
Babel fish
Offline
Babel fish
A
Joined: Mar 2014
Posts: 72
What would I type to add a command? Like !commandadd !Hello Hello! Welcome to the stream laugh