To understand If-Then-Else, you should already know the basics of RemotesI will explain to you the use of If-Then-Else statements, as mIRC F1 help fails...epically...
Let's establish a code! This one will be used to set the channel topic! It uses security...very minimal though.
- Code:
-
on 1:TEXT:!topic *:#channel: {
if ($me != isop) msg $chan I must be an op to set $chan topic!!!
if ($nick != isop) msg $chan You must be an op to set $chan topic!!!
if ($me == isop) { if ($nick == isop) msg cs topic $chan $1- } }
msg $chan Topic has been set to $1-
}
Since you already know basic remotes, I'll go over what we used to make this !topic.
You already know that the user must type !topic to set the topic
The :!topic *: means to listen for something after the user types !topic
Now we dive into the meat of Remotes!!!!
- Code:
-
if ($me != isop) msg $chan I must be an op to set $chan topic!!!
if - DUH self explanatory
($me - starts the if statement. Must be enclosed in ( )
!= - IS NOT EQUAL TO
isop - Is an Op
---This first statement checks to see if the bot is set as an op. If not, it notifies you.
($nick - The nick who wants to set the topic
---If the person trying to set the topic is not an op, it won't set the topic and notifies you.
($me == isop) - Checks to see if the bot is an op
IF the bot is an op, then it checks to see if the user is an op
($nick == isop) - Is user an op? If yes...
msg cs topic $chan $1- - Messages ChanServ, sets Topic, to $chan (the channel it's on), and $1- (the topic) Be SURE to include the
- after $1, otherwise it just includes the first word.
This is what mIRC F1 says about the operators (which is the
isop)
- Quote :
isalnum text contains only letters and numbers
isalpha text contains only letters
islower text contains only lower case letters
isupper text contains only upper case letters
ison nickname v1 is on channel v2
isop nickname v1 is an op on channel v2
ishop nickname v1 is a halfop on channel v2
isvoice nickname v1 has a voice on channel v2
isreg nickname v1 is a normal nick on channel v2
ischan if v1 is a channel which you are on.
isban if v1 is a banned address in the internal ban liston channel v2
isaop if v1 is a user in your auto-op list for channel v2 (v2
optional)
isavoice if v1 is a user in your auto-voice list for channel v2
(v2 optional)
isignore if v1 is a user in your ignore list with the ignore
switch v2 (v2 optional)
isprotect if v1 is a user in your protect list for channel v2
(v2 optional)
isnotify if v1 is a user in your notify list.