mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Nov 2012
Posts: 18
J
Pikka bird
OP Offline
Pikka bird
J
Joined: Nov 2012
Posts: 18
What sample of code would I use to run set commands in a different file, even though I have a 'master' file with the main commands in it.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Just $read the file. Without the n parameter in $read, it will evaluate anything that is read. Be very careful doing that if anyone has access to write something to the file besides you. Doing that sort of thing can be a significant security risk.


Invision Support
#Invision on irc.irchighway.net
Joined: Nov 2012
Posts: 18
J
Pikka bird
OP Offline
Pikka bird
J
Joined: Nov 2012
Posts: 18
So what would the code be like?

$read C:\file.text ?

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
For syntax and examples: /help $read

Again, be aware that running commands this way leaves you open to security risks if you aren't careful. Never run a command from a file that people can write to.

Edit: I thought $read() was a little less secure. After I had a chance to test, simply using $read isn't quite enough, but here's one option:

Code:
alias command {
  noop $read(commands.txt,w,$1*)
}


commands.txt file:
Quote:

echo_hello | echo -a hello
echo_bye | echo -a bye


Use:
/command echo_hello
/command echo_bye

You can set the text file up with a command name to use followed by a pipe character and then followed by the command. The just specify the command name when using the command as shown and it will run the command in the text file that matches the command name you used.

You would of course have to adjust this to fit your needs. It's just a basic example.

Last edited by Riamus2; 09/11/12 06:22 PM.

Invision Support
#Invision on irc.irchighway.net
Joined: Nov 2012
Posts: 18
J
Pikka bird
OP Offline
Pikka bird
J
Joined: Nov 2012
Posts: 18
OK I will test this now.

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Or use the /play command and the -c switch. With /play, you don't need that external alias and the other switches allow you to set further parameters, if required.

Joined: Nov 2012
Posts: 18
J
Pikka bird
OP Offline
Pikka bird
J
Joined: Nov 2012
Posts: 18
Originally Posted By: Horstl
Or use the /play command and the -c switch. With /play, you don't need that external alias and the other switches allow you to set further parameters, if required.


Do you have an example/snippet of code that i could look at?

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Create for instance a file "example.txt" and add a set of commands to it:
Code:
window -a "status window" | echo -st starting example
echo -s ...minimizing and restoring mIRC...
showmirc -n
showmirc -r
echo -st done!

Now within mIRC, if you use the following command:
Code:
/.play -spc "example.txt" 500
mIRC will execute all commands in that file.

Of course you can put the play command inside a custom alias like:
Code:
alias example { .play -spc "example.txt" 500 }
The -c switch tells mIRC to treat all the line in the file as commmands.
The -p switch tells mIRC to give priority to this play request (just in case there are other playbacks running at the moment).
Note that /play requires some target window, therefore I put the -s switch (in mIRC, there will always be a status window).
"500" specifies the per-line playback delay in milliseconds, i.e. the time offset between the different command lines of your file. Note that as the first line in example.txt has two commands on it, there will be no delay in-between the two. You can put "0" for delay to have mIRC execute all the commands without any line delay.

The play command syntax is documented in detail at "playing files" in your mIRC helpfile. For example, you could use an ini-file and have mIRC play a given topic (as the command register, with one or more command line associated to it).

Joined: Nov 2012
Posts: 18
J
Pikka bird
OP Offline
Pikka bird
J
Joined: Nov 2012
Posts: 18
Originally Posted By: Horstl
Create for instance a file "example.txt" and add a set of commands to it:
Code:
window -a "status window" | echo -st starting example
echo -s ...minimizing and restoring mIRC...
showmirc -n
showmirc -r
echo -st done!

Now within mIRC, if you use the following command:
Code:
/.play -spc "example.txt" 500
mIRC will execute all commands in that file.

Of course you can put the play command inside a custom alias like:
Code:
alias example { .play -spc "example.txt" 500 }
The -c switch tells mIRC to treat all the line in the file as commmands.
The -p switch tells mIRC to give priority to this play request (just in case there are other playbacks running at the moment).
Note that /play requires some target window, therefore I put the -s switch (in mIRC, there will always be a status window).
"500" specifies the per-line playback delay in milliseconds, i.e. the time offset between the different command lines of your file. Note that as the first line in example.txt has two commands on it, there will be no delay in-between the two. You can put "0" for delay to have mIRC execute all the commands without any line delay.

The play command syntax is documented in detail at "playing files" in your mIRC helpfile. For example, you could use an ini-file and have mIRC play a given topic (as the command register, with one or more command line associated to it).


So there has to be a separate text file for every external command? you can't compile them into one external file?

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Not if you use the .ini file structure. You could place every command (or set of commands) under a distinct [topic] header of a single .ini file.
What goal are you trying to attain by out-sourcing your commands, if I may ask?

Joined: Nov 2012
Posts: 18
J
Pikka bird
OP Offline
Pikka bird
J
Joined: Nov 2012
Posts: 18
Originally Posted By: Horstl
Not if you use the .ini file structure. You could place every command (or set of commands) under a distinct [topic] header of a single .ini file.
What goal are you trying to attain by out-sourcing your commands, if I may ask?


Say i give someone access to a file called "user1.txt(/.ini)" then they have access to add command to that file.

But then i'd want the main file "remote.ini" to use the commands in that file for said channel.

Then it would go on to add more external files such as user2,3,4,5,6...


The main file structure would then be something like

Code:
on *:text:*:#: {
  if ( $chan == #user1 ) {
    $read(user1.txt)
  }
}
on *:text:*:#: {
  if ( $chan == #user2 ) {
    $read(user2.txt)
  }
}


and so on, permissions and commands would be pulled from the different files.

I'd like the commands in each external file to look like:
Code:
on *:text:*!commandexample*:#: {
  msg $chan command example
}


this is a command example which it would look like in each file. So standard command format.

Last edited by Judgebot; 12/11/12 04:02 PM.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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.


Invision Support
#Invision on irc.irchighway.net
Joined: Nov 2012
Posts: 18
J
Pikka bird
OP Offline
Pikka bird
J
Joined: Nov 2012
Posts: 18
Originally Posted By: Riamus2
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:

Code:
!addcommand isop !command command example

Code:
!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)

isop:
Code:
if ( $nick isop $chan )

public:
Code:
on *:text:*!command*:#:{ 
  msg $chan command example
 }

Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Do you just want the script to be able to send messages or does it have to be able to execute other commands?

If the former, there's a much easier (and better) way of achieving what you want.

Joined: Nov 2012
Posts: 18
J
Pikka bird
OP Offline
Pikka bird
J
Joined: Nov 2012
Posts: 18
Originally Posted By: hixxy
Do you just want the script to be able to send messages or does it have to be able to execute other commands?

If the former, there's a much easier (and better) way of achieving what you want.


I'd like a way of someone else adding commands to the bot, without them touching/giving me the command script to be added.

So any way of doing that (pretty much) I would be great full

Joined: Feb 2003
Posts: 3,432
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
You can yes, but it's a bad bad idea, i could format your whole computer (or worse) if you give that type of access so it's not a good idea.

Last edited by sparta; 14/11/12 06:08 PM.

if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Joined: Nov 2012
Posts: 18
J
Pikka bird
OP Offline
Pikka bird
J
Joined: Nov 2012
Posts: 18
Originally Posted By: sparta
You can yes, but it's a bad bad idea, i could format your whole computer (or worse) if you give that type of access so it's not a good idea.


I'd still like to see this script/code please.

the bot is running on a server and all of the programs are backup-ed away from the computer

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
You know that the things people can do aren't limited to just that computer, right? If you're on a home network, they can gain access to other computers on the network. They can also easily get you banned from the IRC network and can send out viruses to people from your computer. They can also very easily set your computer up (outside of mIRC) to do things it shouldn't, such as passing on viruses or doing DDOS attacks on places. You are attempting to make it possible for someone to do anything they want from your computer as if they were sitting at the computer itself. This goes beyond whether you have a backup on that computer. It is just a really bad idea.


Invision Support
#Invision on irc.irchighway.net
Joined: Nov 2012
Posts: 18
J
Pikka bird
OP Offline
Pikka bird
J
Joined: Nov 2012
Posts: 18
Originally Posted By: Riamus2
You know that the things people can do aren't limited to just that computer, right? If you're on a home network, they can gain access to other computers on the network. They can also easily get you banned from the IRC network and can send out viruses to people from your computer. They can also very easily set your computer up (outside of mIRC) to do things it shouldn't, such as passing on viruses or doing DDOS attacks on places. You are attempting to make it possible for someone to do anything they want from your computer as if they were sitting at the computer itself. This goes beyond whether you have a backup on that computer. It is just a really bad idea.


The bot is used on TwitchTv, and I have spoken and know the twitch admins and they know me and the people who the bot will first be used for.


Link Copied to Clipboard