mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Mar 2010
Posts: 6
P
par0ar Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
P
Joined: Mar 2010
Posts: 6
Hi all,

I know nothing about making scripts / bots for IRC.

I have searched for and am unable to find a bot that will allow users to contact you by using !admin when they require help.

The user will type;
!admin > Bot PM's channel admins telling them "X" needs help

I have seen this bot on Gamesurge #twl_cod but have been unable to acquire the actual bot.

Im guessing its real easy and not much to it but i don't know what im doing so its far from easy at the moment.

If someone could help i would really appreciate it

Thanks

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
All you need is an on text script to do that.

Code:
on *:text:!admin:#channel: {
  var %admins = admin_nick_1 admin_nick_2 admin_nick_3
  var %c = 1, %t = $numtok(%admins,32)
  while (%c <= %t) {
    if ($gettok(%admins,%c,32) ison $chan) { var %admins.online = $addtok(%admins.online,$gettok(%admins,%c,32),44) }
    inc %c
  }
  msg %admins.online $nick needs help in $chan $+ .
}


Just repeat and change each admin_nick_* and #channel. You can add as many nicks as you want to the var %admins line. Separate them with spaces as shown.

How it works... when someone types !admin, the script will loop through and check each nick on your %admins line to see if they are in the channel. If so, it will add them to a list of online admins (separated by commas), then message them as /msg nick1,nick2,nick3 Message here. This prevents you from possibly being flooded offline for sending individual messages to too many people at once. You are limited to the number of nicks you can have (the length of the number of nicks), but you'd need at least 40-50 nicks to hit the limit, so that's not likely to be a problem for you.

You could make the script smaller by not having it check if the person is in the channel, but then you'll just get errors if one or more of the nicks are offline. This at least prevents the error messages.

Also, note that if you're just sending message to ops, you can skip having nicks and just send a message to all of the ops instead. On many networks, this can be done with wallops. For others, you can loop through the ops in the channel the same way this loops through your list of nicks and then send it out in the same way.

Here is how it works if you want everyone with op status to get the message:

Code:
on *:text:!admin:#channel: {
  var %c = 1, %t = $nick($chan,0,o)
  while (%c <= %t) {
    var %ops = $addtok(%ops,$nick($chan,%c,o),44) }
    inc %c
  }
  msg %ops $nick needs help in $chan $+ .
}


Remember to replace #channel with the channel name.

Last edited by Riamus2; 04/03/10 02:31 PM.

Invision Support
#Invision on irc.irchighway.net
Joined: Feb 2009
Posts: 133
C
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2009
Posts: 133
Originally Posted By: Riamus2
Code:
on *:text:!admin:#channel: {
  var %c = 1, %t = $nick($chan,0,o)
  while (%c <= %t) {
    var %ops = $addtok(%ops,$nick($chan,%c,o),44) }
    inc %c
  }
  msg %ops $nick needs help in $chan $+ .
}


u have one "}" not needed at end of $addtok and the /msg op1 op2 op3 $nick blabla... is wrong! that must be into the loop so the code is

Code:
on *:text:!admin:#channel:{
  var %c 1
  while $nick(#,%c,o) {
    msg $v1 $nick needs help in # $+ .
    inc %c
  }
}


WorldDMT
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Yes, the } was a mistake. However, no, the msg line should *not* be in the loop. As stated in my post, this prevents flooding by messaging everyone separately. It will message them all at once.

Code:
on *:text:!admin:#channel: {
  var %c = 1, %t = $nick($chan,0,o)
  while (%c <= %t) {
    var %ops = $addtok(%ops,$nick($chan,%c,o),44)
    inc %c
  }
  msg %ops $nick needs help in $chan $+ .
}


Invision Support
#Invision on irc.irchighway.net
Joined: Feb 2009
Posts: 133
C
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2009
Posts: 133
%ops = op1 op2 op3

msg %ops $nick needs help in $chan $+ .

result:
query op1: op2 op3 Nick needs help in #chan.

or not?


WorldDMT
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Look more closely. %ops is not space deliminated. It is comma deliminated. You can do a /msg nick,nick,nick some message (as I stated in the first post). There may be a limit on the number of nicks per message or some networks may not allow that. I haven't tested it on all types of server software or networks. However, yours will flood you off if you have more than about 5 ops in the channel.


Invision Support
#Invision on irc.irchighway.net
Joined: Feb 2009
Posts: 133
C
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2009
Posts: 133
ah ok i didnt saw the $chr(44) = ","

tnx smile


WorldDMT
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Np.

Anyhow, to the OP... in all honesty, you're much better off having an op channel that has a password (key) and just message the channel. Makes for one message, faster script, easy place for ops to chat, easy way to log anything op-related as well as anyone requesting help, etc.

Obviously, that's not necessary for most channels, but if you have some form of help channel or would like ops to communicate more, it can be very useful.


Invision Support
#Invision on irc.irchighway.net
Joined: Mar 2010
Posts: 6
P
par0ar Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
P
Joined: Mar 2010
Posts: 6
Awesome,

Thanks for your help guys ... I think i understand the workings of the script.

So if i was to create a channel just for ops as you suggested would the scripts then be ...

Code:
on *:text:!admin:#channel: {
  var %c = 1, %t = $nick(#opschannel,0,o)
  while (%c <= %t) {
    var %ops = $addtok(%ops,$nick($chan,%c,o),44)
    inc %c
  }
  msg %ops $nick needs help in $chan $+ .
}


I changed var %c = 1, %t = $nick(#opschannel,0,o)

Last edited by par0ar; 05/03/10 12:12 AM.
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Actually, if you're going to have a channel for just the ops, then you could just use
Code:
on *:text:!admin:#channel: .msg #opschannel $nick needs help in $chan $+ . 



Joined: Mar 2010
Posts: 6
P
par0ar Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
P
Joined: Mar 2010
Posts: 6
wow, so simple ....ok so then using the same "theory" (and i use that very loosely).

User types !admin which alerts ops by PM.
Code:
on *:text:!admin:#channel: .msg #opschannel $nick needs help in $chan $+ .


To return a message to the user letting them know that someone has been alerted that help is needed would be ....

Code:
on *:text:!admin: .$chan echo $nick A admin will be with you shortly.


or am i as lost as a rabbit in the ocean confused

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
If you want to notify an ops channel and the user as well, you'd do:

Code:
on *:text:!admin:#channel:{
  .msg #opschannel $nick needs help in $chan $+ .
  .msg $nick The ops have been notified that you need help.  Someone will be with you shortly.
}


You can, of course, use .notice to tell the person who needs help that the ops were notified, or you can msg the channel ($chan instead of $nick) so that it's visible for everyone.

Btw, just so you know... your change to the original looping script is almost correct. You'd want to change both $nick($chan, parts to $nick(#opschannel, --- you did one, but not the other. However, because only ops would be in the ops channel, there's no need for the loop. Just wanted to let you know that you had the right idea.

Last edited by Riamus2; 05/03/10 02:30 AM.

Invision Support
#Invision on irc.irchighway.net
Joined: Mar 2010
Posts: 6
P
par0ar Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
P
Joined: Mar 2010
Posts: 6
Awesome, thanks for the help guys i really appreciate it.

Can you give me some advice on where i can learn C?? (I think thats what this script language is).

Its cool when people help but i want to learn this so i can completely understand it, do my own stuff, as well as help others too.


Thanks again guys.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
This isn't C. It's MSL (mIRC Scripting Language). The easiest way to learn it is to get one or two really basic scripts (without many lines) and try to figure out what it does. Look at a piece of the script and use the help file to find out syntax and how it does what it's doing. Learning any language is slow, at least when learning on your own, so you have to be prepared to not learn everything in a couple of weeks. Also, knowing other programming or scripting languages can make learning MSL easier because you already have an idea of how programming/scripting should work. Then, it's just learning the language rather than learning the mechanics and the language.

The most useful help topics when starting out would be ones like:

/help on text
/help /set
/help /var
/help /echo
/help /msg
/help while
/help /inc
/help /dec
/help $calc
/help $nick
/help $chan
/help if then else --- note that I am not positive this will bring up the topic. You're looking for IF, ELSEIF, ELSE if you need to find it manually.

Beyond that, it's just a matter of trying things out and learning as you go. Try writing a small script that doesn't do that much and see if you can get it to work. If you can't, or it has some problems, then post it here with what you're trying to make it do and what it's doing wrong or not doing. We'll be happy to help show you how to make a script work, which will help you to learn. Then, as you learn more, you can expand into larger scripts and use more advanced commands - tokens, hash tables, sockets, binary variables, etc.


Invision Support
#Invision on irc.irchighway.net
Joined: Mar 2010
Posts: 6
P
par0ar Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
P
Joined: Mar 2010
Posts: 6
Sounds good ... thanks for your help and support smile


Link Copied to Clipboard