mIRC Home    About    Download    Register    News    Help

Topic Options
#244401 - 24/02/14 06:38 AM Need help withmaking a add command command
stobbsie Offline
Mostly harmless

Registered: 24/02/14
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
}
}
}

Top
#244403 - 24/02/14 02:05 PM Re: Need help withmaking a add command command [Re: stobbsie]
Crinul Offline
Vogon poet

Registered: 10/02/06
Posts: 181
Loc: Bucharest, Romania
*deleted*


Edited by Crinul (24/02/14 07:43 PM)

Top
#244404 - 24/02/14 03:10 PM Re: Need help withmaking a add command command [Re: Crinul]
Loki12583 Online
Hoopy frood

Registered: 22/01/04
Posts: 1263
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
}

Top
#244405 - 24/02/14 03:29 PM Re: Need help withmaking a add command command [Re: Loki12583]
Crinul Offline
Vogon poet

Registered: 10/02/06
Posts: 181
Loc: Bucharest, Romania
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.

Top
#244408 - 24/02/14 06:20 PM Re: Need help withmaking a add command command [Re: Crinul]
Loki12583 Online
Hoopy frood

Registered: 22/01/04
Posts: 1263
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.

Top
#244409 - 24/02/14 07:08 PM Re: Need help withmaking a add command command [Re: Loki12583]
Crinul Offline
Vogon poet

Registered: 10/02/06
Posts: 181
Loc: Bucharest, Romania
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?

Top
#244410 - 24/02/14 07:14 PM Re: Need help withmaking a add command command [Re: Crinul]
Loki12583 Online
Hoopy frood

Registered: 22/01/04
Posts: 1263
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?

Top
#244411 - 24/02/14 07:19 PM Re: Need help withmaking a add command command [Re: Loki12583]
Crinul Offline
Vogon poet

Registered: 10/02/06
Posts: 181
Loc: Bucharest, Romania
Yes. Unless he adds them later (like feature suggestions file)
Still, no double evaluation.

Top
#244412 - 24/02/14 07:30 PM Re: Need help withmaking a add command command [Re: Crinul]
Loki12583 Online
Hoopy frood

Registered: 22/01/04
Posts: 1263
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

Top
#244413 - 24/02/14 07:41 PM Re: Need help withmaking a add command command [Re: Loki12583]
Crinul Offline
Vogon poet

Registered: 10/02/06
Posts: 181
Loc: Bucharest, Romania
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.

Top