mIRC Homepage
Posted By: stobbsie Need help withmaking a add command command - 24/02/14 06:38 AM
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
}
}
}
*deleted*
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
}
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.
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.
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?
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?
Yes. Unless he adds them later (like feature suggestions file)
Still, no double evaluation.
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
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.
© mIRC Discussion Forums