mIRC Home    About    Download    Register    News    Help

Print Thread
Need help withmaking a add command command #244401 24/02/14 06:38 AM
Joined: Feb 2014
Posts: 1
S
stobbsie Offline OP
Mostly harmless
OP Offline
Mostly harmless
S
Joined: Feb 2014
Posts: 1
im trying to make a command to allow me to make more commands so far i have manege to make it add

on *:text: !trigger *:#: msg #stobbsie action

when i run the command with
!addcommand !trigger action
but i what it to say

on *:text:!trigger*:#: { msg $chan action }

but apparently { , } and $chan are reserved and cant be used any suggestions on how to fix this also how can i remove the space before and after !trigger this is the code im using


on *:text:!addcommand *:#: {
if ($2 == show) { msg $chan Commands avalible are !addcommand | return }
else {
write scripts\ilordcommands.txt on *:text: $2 *:$chan: { msg $chan $3- }
msg $chan done
}
}
}

Re: Need help withmaking a add command command [Re: stobbsie] #244403 24/02/14 02:05 PM
Joined: Feb 2006
Posts: 181
C
Crinul Offline
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2006
Posts: 181
*deleted*

Last edited by Crinul; 24/02/14 07:43 PM.
Re: Need help withmaking a add command command [Re: Crinul] #244404 24/02/14 03:10 PM
Joined: Jan 2004
Posts: 1,277
L
Loki12583 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,277
Writing raw text and then loading it as a script is dangerous, instead you should just keep a list of commands and responses.

Code:
on $*:text:/^!addcommand !?(\S+)/iS:#:{
  writeini commands.ini commands $regml(1) $$3-
}

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

Re: Need help withmaking a add command command [Re: Loki12583] #244405 24/02/14 03:29 PM
Joined: Feb 2006
Posts: 181
C
Crinul Offline
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2006
Posts: 181
Dangerous? How? (It could stop working with too many on text)
Do you see the posts count on the OP? Do you expect him to understand your code? Or just use it?
You would have to explain in more detail.

Re: Need help withmaking a add command command [Re: Crinul] #244408 24/02/14 06:20 PM
Joined: Jan 2004
Posts: 1,277
L
Loki12583 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,277
It's dangerous because it allows arbitrary code to be run which could compromise the entire system. I expect anyone using code provided on the forum to look up anything they don't recognize in the help files.

Re: Need help withmaking a add command command [Re: Loki12583] #244409 24/02/14 07:08 PM
Joined: Feb 2006
Posts: 181
C
Crinul Offline
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2006
Posts: 181
Quote:
It's dangerous because it allows arbitrary code to be run which could compromise the entire system.


/write and /msg do not double evaluate content.

Am I missing something here?

Re: Need help withmaking a add command command [Re: Crinul] #244410 24/02/14 07:14 PM
Joined: Jan 2004
Posts: 1,277
L
Loki12583 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,277
Originally Posted By: Crinul
/write and /msg do not double evaluate content.

Am I missing something here?


Presumably he is loading the file he writes to as a remote script. Otherwise why would he be writing events to it?

Re: Need help withmaking a add command command [Re: Loki12583] #244411 24/02/14 07:19 PM
Joined: Feb 2006
Posts: 181
C
Crinul Offline
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2006
Posts: 181
Yes. Unless he adds them later (like feature suggestions file)
Still, no double evaluation.

Re: Need help withmaking a add command command [Re: Crinul] #244412 24/02/14 07:30 PM
Joined: Jan 2004
Posts: 1,277
L
Loki12583 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,277
Originally Posted By: Crinul
Yes. Unless he adds them later (like feature suggestions file)
Still, no double evaluation.


I don't think his purpose is to implement a feature suggestion. It's to allow users to create new "commands" (in real time) which cause his bot to respond appropriately. Writing new events to a file is not the way to go about this. If you're writing user input to loaded scripts you've just compromised your system.

!addcommand !exploit $findfile(.,*,1,run notepad)
!addcommand !exploit exploited | run notepad

Re: Need help withmaking a add command command [Re: Loki12583] #244413 24/02/14 07:41 PM
Joined: Feb 2006
Posts: 181
C
Crinul Offline
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2006
Posts: 181
Now I see.
It's the remotes that make it dangerous, not the write part.
I was thinking about the code only.

Thanks for the clarification, Loki12583.