You wouldn't be able to use event syntax like that. At least, not without considerable work, or unless you want to load the file and use it that way as just another script file.
As far as what you are attempting, you should absolutely never do this. Consider what happens if someone decides it would be "fun" to put in a command to delete things from your computer or grab your password file from your browser or other history and cookie information from you browser and download it? It would be VERY easy for someone to do basically anything they wanted to your computer. And with that kind of control, they could make it so you don't even notice... write the command to do what they want, then change it back to something innocuous until they are ready to do something bad again.
Never, never, never let someone create their own command on your computer and execute it. This is a really dangerous idea for a script. Unless you and only you have access to write commands, or you can absolutely trust those who have access (I wouldn't trust anyone besides very close family and perhaps very close real life friends). It would never be a good idea to give that kind of control to anyone you meet online no matter how good you think you know them.
Ok, so is there a script snippet that does:
!addcommand isop !command command example
!addcommand public !command command example
!addcommand = the script
isop/public = the permissions
!command = the command you want adding (trigger)
command example = the text of the command (reply)
msg $chan command example