mIRC Homepage

Need help withmaking a add command command

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
}
}
}
Posted By: Crinul

Re: Need help withmaking a add command command - 24/02/14 02:05 PM

*deleted*
Posted By: Loki12583

Re: Need help withmaking a add command command - 24/02/14 03:10 PM

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
}
Posted By: Crinul

Re: Need help withmaking a add command command - 24/02/14 03:29 PM

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.
Posted By: Loki12583

Re: Need help withmaking a add command command - 24/02/14 06:20 PM

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.
Posted By: Crinul

Re: Need help withmaking a add command command - 24/02/14 07:08 PM

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?
Posted By: Loki12583

Re: Need help withmaking a add command command - 24/02/14 07:14 PM

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?
Posted By: Crinul

Re: Need help withmaking a add command command - 24/02/14 07:19 PM

Yes. Unless he adds them later (like feature suggestions file)
Still, no double evaluation.
Posted By: Loki12583

Re: Need help withmaking a add command command - 24/02/14 07:30 PM

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
Posted By: Crinul

Re: Need help withmaking a add command command - 24/02/14 07:41 PM

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.
© 2019 mIRC Discussion Forums