mIRC Home    About    Download    Register    News    Help

Print Thread
New to IRC, Custom Commands? #218000 29/01/10 02:59 PM
Joined: Jan 2010
Posts: 1
B
BugHunter Offline OP
Mostly harmless
OP Offline
Mostly harmless
B
Joined: Jan 2010
Posts: 1
Hey there gents,

I've recently created my first IRC channel, I've managed to get everything working. But now I want to add an extra feature to my channel.

I would like to add "custom commands" as in !command for instance. I would like to be able to create my own commands and the result it shows in the channel. These would be used for random stuff, such as !topic to know the topic, !rules to see the rules of the channel etcetera.

I've already tried googling for it but nothing I could really use.

Hoping you could help me on my way,
BugHunter

Re: New to IRC, Custom Commands? [Re: BugHunter] #218005 29/01/10 03:39 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
You'll want to use the help file and look at some basic scripts.

The main thing you'll want to look at is: /help on text

Here's just a very basic example:

Code:
on *:text:!command:#channel: {
  msg $chan Some message.
}


In this example, you'd replace !command with the command you want to use. You can use wildcards if needed, for example !command*, and you can use multiple words. You'd replace #channel with your channel name, or you can just leave it as # if you want it to work for all channels. You'd also replace Some message with what you want sent to the channel. If you want it sent to the person who used the command instead of the channel, you can replace $chan with $nick.

Some other useful help topics:
/help on input
/help on notice
/help /var
/help /set
/help if then else <-- I think that will bring it up, otherwise look up /help elseif

Just one other example, showing another way to do the same thing, which in some cases works better.

Code:
on *:text:*:#channel: {
  if ($1 == !command) {
    msg $chan Some message
  }
}


Note that the trigger is no longer on the first line. Instead, we just use a wildcard so the even triggers on all text. Then, we use IF statements to check if the command is used ($1 is the first word, $2 is the second, etc. and == check that the first word is !command). You can also use $1- to compare all words (in this example, that would make this only work if only !command is used and not something like !command this). There are many other things you can do and the best thing is to just try things out and refer to the help file.

NOTE: Try it out yourself first. Then, if you have questions or it's not working the way you expect, come here and ask for help. Give what you've tried and what you want it to do and we can help out. Also, note that on TEXT events do *not* respond if you type something from the same client as the script. It will only respond to other people (or another client on your computer) typing something. Use on INPUT if you want it to respond to you. If you want it to respond to both you and others, you'll need to use both events even if that means some duplicate code.


Invision Support
#Invision on irc.irchighway.net