mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
Joined: Jun 2013
Posts: 43
G
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Jun 2013
Posts: 43
I'm needing some help with a script I'm working on. What I want is when someone types in, for example,
Code:
!add [test] [this is a test command]

with the brackets, it will add a new remote so when they now type in !test it will reply 'this is a test command'. I would also like the new command they added to only be available on that channel.
Any help would be appreciated.

Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
Taking in input in this way can be dangerous, make sure to always use the 'n' switch with $readini and do not pass unknown text into a timer.

Code:
alias addcommand {
  var %chan = $1, %command = $2, %reply = $$3-
  writeini commands.ini %chan %command %reply
}

on *:text:*:#:{
  if ($regex($1-,/!add \[(\S+)\] \[(.+)\]/Si)) {
    addcommand # $+(!,$regml(1)) $regml(2)
  }
  elseif ($readini(commands.ini,n,#,$1)) {
    msg # $v1
  }
}

Joined: Jun 2013
Posts: 43
G
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Jun 2013
Posts: 43
Thanks so much for the help! laugh
Now that I've added the commands, is there an easier way to delete them instead of going into the .ini file and deleting them manually? So I would do
Code:
!remove [test]
and it deletes the command from the .ini file.
Thanks anyway for the help.

Last edited by GamingTom; 26/06/13 03:35 PM.
Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
Code:
alias addcommand {
  var %chan = $1, %command = $2, %reply = $$3-
  writeini commands.ini %chan %command %reply
}

alias remcommand {
  var %chan = $1, %command = $2
  remini commands.ini %chan %command
}

on *:text:*:#:{
  if ($regex($1-,/!add \[(\S+)\] \[(.+)\]/Si)) {
    addcommand # $+(!,$regml(1)) $regml(2)
  }
  elseif ($regex($1-,/!remove \[(\S+)\]/Si)) {
    remcommand # $+(!,$regml(1))
  }
  elseif ($readini(commands.ini,n,#,$1)) {
    msg # $v1
  }
}

Joined: Jun 2013
Posts: 43
G
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Jun 2013
Posts: 43
Thanks you so much for your help! However, I have something else I need help with if you don't mind. At the moment I have

Code:
!add [<command>] [<message>]


but I was wondering if it would be possible to do something like this so that it makes people on of a certain user level use it:

Code:
!add [<user level>] [<command>] [<message>]


And one other thing, how would I go about adding custom timers, for example:

Code:
!addtimer [<delay>] [<name>] [<message>]


and it would be activated by doing:

Code:
!activatetimer [<name>]


Would I use the same sort of format for the !add command?
Anyway, once again, thanks for your help.

Last edited by GamingTom; 27/06/13 02:19 PM.
Joined: Apr 2014
Posts: 2
A
Bowl of petunias
Offline
Bowl of petunias
A
Joined: Apr 2014
Posts: 2
mh, i need this too but its not working for me
what am i doing wrong?

i need to !addcom !command testforcommand
and a !delcom !command

to just add/remove commands to my bot which will give out some text/informations

i tried it with the script from loki, even if i edited some things for me like userlvls it dont work

can someone help me on that?

Joined: Apr 2014
Posts: 170
Vogon poet
Offline
Vogon poet
Joined: Apr 2014
Posts: 170
Code:
on $*:text:/^!addcom !?(\S+)/iS:#:{
  if ($nick !isop #) return
  writeini commands.ini commands $regml(1) $$3-
}
 
on $*:text:/^!delcom !?(\S+)/iS:#:{
  if ($nick !isop #) return
  remini commands.ini commands $regml(1)
}
 
on $*:text:/^!(\S+)/:#:{
  if ($nick !isop #) return
  if ($readini(commands.ini,n,commands,$regml(1))) msg # $v1
}




To add: "!addcom !test this is a test command"
To del: "!delcom !test"
To use: "!test" Bot -> this is a test command"

To edit, just redo the !addcom !test and add whatever you want the new message to be.

Last edited by Bramzee; 30/04/14 09:29 PM.
Joined: Apr 2014
Posts: 2
A
Bowl of petunias
Offline
Bowl of petunias
A
Joined: Apr 2014
Posts: 2
nice, ty very much, that works
i'll try to edit some things to get it as i want
(floot/msg/etc)
hope it will work then too

otherwise can i message you?
would be great

thank u

Joined: Apr 2014
Posts: 170
Vogon poet
Offline
Vogon poet
Joined: Apr 2014
Posts: 170
Code:
on $*:text:/^!(\S+)/:#:{
  if ((%floodcom) || ($($+(%,floodcom.,$2),2))) { return }
  set -u10 %floodcom On
  set -u30 %floodom. $+ $nick On
  if ($readini(commands.ini,n,commands,$regml(1))) msg # $v1
}


This should be the only thing you'll need floodprotection on. If people are spamming the !addcom and !delcom you can just basically copy/paste this and change "floodcom" to "floodadd" and "flooddel"

Also, yeah you can message me. I'm semi-new to all of this but I'm learning fast and willing to help if I can man smile

Last edited by Bramzee; 01/05/14 05:05 AM.
Joined: May 2014
Posts: 5
D
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
D
Joined: May 2014
Posts: 5
Towards Bram, ( I forgot to quote you :P )


I know a basic understanding on the way to program simple stuff, but is there a way I could make it also say for example "Command "(command) has been created" ?

Oh, I'm a noob. Haha, brain farted badly, but anyways, thanks for the code dude, thats really a nice addition for me! laugh

Uhm, is there a way to change the preface it uses, I've tried and it just doesn't work.

But about that feature where I can select a user level?

Last edited by Devin; 08/05/14 12:39 AM.
Joined: Apr 2014
Posts: 170
Vogon poet
Offline
Vogon poet
Joined: Apr 2014
Posts: 170
Not sure I know what you mean, could be the lack of sleep ha. Explain a little more in detail?

Joined: May 2014
Posts: 5
D
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
D
Joined: May 2014
Posts: 5
You know how it defaults to a "!" for commands and when you add them it defaults to that? Well my bot has a ~ instead, and I tried to do !addcom ~test test and that just made me type !~test xD, I just wanted to know how to change it, since I broke it while trying to :P

Joined: Apr 2014
Posts: 170
Vogon poet
Offline
Vogon poet
Joined: Apr 2014
Posts: 170
Is there a reason it has to have the "~" ?? If not, I'd suggest using just the ! but this will work if you don't care about the length or anything like that...

Ex:

You-> !addcom ~test THIS IS A TEST!
Bot-> Successfully created ~test!
You-> !~test
Bot-> THIS IS A TEST!

Code:
on $*:text:/^!~(\S+)/:#:{
  if ((%floodcom) || ($($+(%,floodcom.,$2),2))) { return }
  set -u10 %floodcom On
  set -u30 %floodom. $+ $nick On
  if ($readini(commands.ini,n,commands,$regml(1))) msg # $v1
}


That's my fix with no sleep in me. If it's not acceptable I'll be around tomorrow to help you smile Between the two of us, we should be able to get it lol.

Joined: Apr 2014
Posts: 191
B
Vogon poet
Offline
Vogon poet
B
Joined: Apr 2014
Posts: 191
replace all (!) in script with (~) except (!isop)

Joined: Apr 2014
Posts: 170
Vogon poet
Offline
Vogon poet
Joined: Apr 2014
Posts: 170
Already tested it that way, I couldn't get it working. It will add the command to the file, but won't read it. That's why I just used !~command for now.

Joined: May 2014
Posts: 5
D
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
D
Joined: May 2014
Posts: 5
The only reason I would need the preface ~ would be because the channel my bot is in has servers in it that relay chat and they use ! as prefaces. but thanks for the effort :P

Joined: Apr 2014
Posts: 191
B
Vogon poet
Offline
Vogon poet
B
Joined: Apr 2014
Posts: 191
Try if this works.

~addcom ~test this is a test
~test
~delcom ~test

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

on $*:text:/^~(\S+)/:#:{
  if ((%floodcom) || ($($+(%,floodcom.,$2),2))) { return }
  set -u10 %floodcom On
  set -u30 %floodom. $+ $nick On
  if ($readini(commands.ini,n,commands,$regml(1))) msg # $v1
}

Joined: May 2014
Posts: 5
D
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
D
Joined: May 2014
Posts: 5
Actually, replacing the two "!"'s with "~"s on the first lines of addcom and delcom it made the preface work.. Anyways, thanks alot for that code dude laugh

Joined: Apr 2014
Posts: 170
Vogon poet
Offline
Vogon poet
Joined: Apr 2014
Posts: 170
yeah... didn't try that ha. Good call man smile

Joined: May 2014
Posts: 7
O
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
O
Joined: May 2014
Posts: 7
Hey Everyone,

This has been a great help, I do have one question. Did anyone know out how to add the user level commands.

So right now I only have two options which is edit the script to have

This allowing anyone to use it

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


Or this allowing only ops

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

Is there a way when the op creates the command to say who can use it?

Page 1 of 2 1 2

Link Copied to Clipboard