mIRC Homepage
Posted By: GEFFO Random remote scripts help needed - 26/08/10 09:24 AM
Hi IRC Experts

Could someone help me with a few remote scripts for a bot I'm using?

1) When I type !forum -> The bot replies with a PM link to a specified forum.

2) When I type !mod or !invite -> It replies with a PM. At the same time, the bot pings designated people online. Also, how should I set these designated people?

3) When I type !calc -> The bot does calculations?

And a general question, how I get the bot to join invite only channels? I'm doing /cs invite at the moment but I have to actually click it myself. How can I get the bot to automatically accept an invite?

Thanks guys!
Posted By: Thels Re: Random remote scripts help needed - 26/08/10 09:50 AM
In Options, IRC, there's an option "auto-join on invite", which should do the trick. Of course it would accept any invite, so other users would be able to invite your bot to weird places. Another solution would be:

Code:
on *:invite:#yourchannel: {
  /join -n $chan
}


You could also do:

Code:
on chanserv:invite:#: {
  /join -n $chan
}


And then add an entry for chanserv on your network on the Users tab. If you only need 1-3 channels, use the first method instead.

As for reacting to triggers, you're looking for:

Code:
on *:text:!forum:*: {
  /msg $nick The forum is located here.
}


Any kind of commands you can use yourself in the editbot, you can put in that script, and then some.

EDIT: Forgot code blocks.
Posted By: Riamus2 Re: Random remote scripts help needed - 26/08/10 10:12 AM
I think he wants the script to ask someone for an invite, not to actually invite someone or to join when invited.

Code:
on *:text:*:#yourchannel: {
  if ($1 == !invite) { msg $nick Requesting invite. | msg SOMENICK $nick requested invite to $chan $+ . }
  elseif ($1 == !mod) { msg $nick Requesting help from a mod. | msg SOMENICK $nick needs help. }
  elseif ($1 == !forum) { msg $nick Our forum is located at http://www.google.com/ }
  elseif ($1 == !calc) { msg $nick $calc($remove($$2-,$chr(36),$chr(124)) } 
}


Keep in mind with !calc that it will mostly only do basic calculations. Also, someone can verify if that is safe how I have it set up. I removed $ and | which should prevent any improper use of the command, but there may be other things that should be considered with such a command that I'm not thinking of.
Posted By: Thels Re: Random remote scripts help needed - 26/08/10 10:19 AM
Originally Posted By: Riamus2
I think he wants the script to ask someone for an invite, not to actually invite someone or to join when invited.


From what I understood, the bot is automatically asking Chanserv for an invite, but then doesn't actually accept the invitation.

Y'know, an even easier method would just to be:

/cs invite #channel
.timer 1 5 join #channel

That basically assumes that Chanserv will give you the invite, and then try joining the channel 5 seconds later. Not the most clean way of doing it, but surely the easiest.
Posted By: jaytea Re: Random remote scripts help needed - 26/08/10 10:38 AM
Originally Posted By: Riamus2

Keep in mind with !calc that it will mostly only do basic calculations. Also, someone can verify if that is safe how I have it set up. I removed $ and | which should prevent any improper use of the command, but there may be other things that should be considered with such a command that I'm not thinking of.


$calc($$2-) would be completely safe; the only potentially undesirable behaviour that could occur is evaluation of variables.
Posted By: GEFFO Re: Random remote scripts help needed - 26/08/10 10:42 AM
Hey guys

Wow, thanks for replying to quickly.

I've added the auto invite command into perform and it works great!

Re: The script for ! commands and calculator.

1) the SOMENICK part. I guess it's for one nick. Can I add multiple nicks? If so, how?

2) The calculator - Can I increase the limits of calculations?
Posted By: GEFFO Re: Random remote scripts help needed - 26/08/10 10:53 AM
Hi all

It's me again. Just testing out the script.

A few issues:

1) When I type !invite, the bot says Incorrect command usage: !invite <nickname> and then says 'Requesting invite' and then messages a person saying I requested an invite. The problem is that it does this twice. Any idea why?>

2) When I type !calc, there's no reaction from the bot. The script has been loaded. Is there something else I need to active?

Thanks
Posted By: Thels Re: Random remote scripts help needed - 26/08/10 10:58 AM
Originally Posted By: GEFFO
1) the SOMENICK part. I guess it's for one nick. Can I add multiple nicks? If so, how?


Just copy/paste the command:

Code:
elseif ($1 == !mod) { msg $nick Requesting help from a mod. | msg SOMENICK1 $nick needs help. | msg SOMENICK2 $nick needs help. | msg SOMENICK3 $nick needs help. }


If you end up with a lot of moderators, it might help to store these in a hash file, and scan through that, and then check as well if they are only before blindly sending them text, but that's a little more advanced.

Quote:
2) The calculator - Can I increase the limits of calculations?


It does anything $calc() does. As said, it's recommended to replace/remove the $ and % characters, because otherwise other users would have access to your variables and routines.

If you want more than that, you'd have to script your own routine.
Posted By: Thels Re: Random remote scripts help needed - 26/08/10 11:11 AM
Originally Posted By: GEFFO
Hi all

It's me again. Just testing out the script.

A few issues:

1) When I type !invite, the bot says Incorrect command usage: !invite <nickname> and then says 'Requesting invite' and then messages a person saying I requested an invite. The problem is that it does this twice. Any idea why?>

2) When I type !calc, there's no reaction from the bot. The script has been loaded. Is there something else I need to active?

Thanks


You're most likely have more than one script installed, or have more than one ON TEXT entry in your script.

Each event will only trigger a single ON event entry per Remote script, though you can load multiple Remote scripts and have each of them affect your text.
Posted By: GEFFO Re: Random remote scripts help needed - 26/08/10 11:27 AM
Hi

Everything is working now except one thing. The calculator.

The bot doesn't respond at all. Is there a code that I code copy and paste into the original set? This code should enable the bot to sent a message to the actual channel in which the math question is asked rather than a PM.

Thanks
Posted By: Riamus2 Re: Random remote scripts help needed - 26/08/10 12:13 PM
Just change msg $nick to msg $chan.

As to it not responding, make sure you have only that script there and make sure you're using valid calculation requests. Try:

!calc 1+1

Considering you said the bot was replying with an error message (which wasn't included in what I wrote for you), most likely you have another script loaded and it's giving you the issues.

Also, you can usually use: msg nick,nick,nick some message to send a message to multiple nicks. There is a limit on the number you can send to at once though and that depends on the server. ** You may need spaces after each comma in that. I can't test right now.

You might also want to change the !calc line to:

Code:
  elseif ($1 == !calc) { msg $chan $2- = $calc($$2-) }


That will show the requested calculation along with the answer. And, per jaytea, we shouldn't really need to remove anything and I tried a few tests which don't give problems, so that should be fine.
Posted By: GEFFO Re: Random remote scripts help needed - 26/08/10 12:31 PM
That works sweeetly. Thank you!

One more dumb question.

I've added $chan $nick so that it pings the user. How do I get a : after their nick when it pings them?

Also, how do I add commas to my answers?
Posted By: GEFFO Re: Random remote scripts help needed - 26/08/10 02:01 PM
Oh yeah - Another one to test everyones skills.

Say the bot is in a private room (A) where there is only ops. A person comes into a normal chan (B) and wants an invite to another private room (C). The person types !private. At this point, how do I get my bot to send through a msg to the channel A. How do I also script the bot so that when the ops type !invite $nick, the person in channel B gets an invite and a message saying you're invited to channel C?

P.S. My calculator can't seem to read or process commas lol. How do I get it to do this?

Posted By: Knoeki Re: Random remote scripts help needed - 26/08/10 02:01 PM
Originally Posted By: GEFFO
That works sweeetly. Thank you!

One more dumb question.

I've added $chan $nick so that it pings the user. How do I get a : after their nick when it pings them?

Also, how do I add commas to my answers?


Have a look at $+, it allows you to merge 2 tokens (words) together.

for example:

Code:
$+($nick,:)

or
Code:
$nick $+ :


The results of the above are the same. Do it however you like. ;_)
Posted By: Thels Re: Random remote scripts help needed - 26/08/10 02:49 PM
Originally Posted By: GEFFO
Oh yeah - Another one to test everyones skills.


It's more about understanding what you want precisely. :P

Originally Posted By: GEFFO
Say the bot is in a private room (A) where there is only ops. A person comes into a normal chan (B) and wants an invite to another private room (C). The person types !private. At this point, how do I get my bot to send through a msg to the channel A. How do I also script the bot so that when the ops type !invite $nick, the person in channel B gets an invite and a message saying you're invited to channel C?


First, your bot needs to be on both channels #A and #B, since you want to pick up a message from #B and want to display it in #A.

Code:
on *:text:!private:#B: {
  msg #A $nick said !private in $+(#B, .)
}


Quote:
P.S. My calculator can't seem to read or process commas lol. How do I get it to do this?


In your script, you can use $chr(44) instead of a comma.
Posted By: 5618 Re: Random remote scripts help needed - 26/08/10 02:53 PM
Originally Posted By: GEFFO
P.S. My calculator can't seem to read or process commas lol. How do I get it to do this?
Calculations are done with the English period notation for decimal numbers.
You could probably replace commas by periods beforehand though:
Code:
$calc($replace($$2-,$chr(44),$chr(46)))
Posted By: Thels Re: Random remote scripts help needed - 26/08/10 02:57 PM
Originally Posted By: 5618
Originally Posted By: GEFFO
P.S. My calculator can't seem to read or process commas lol. How do I get it to do this?
Calculations are done with the English period notation for decimal numbers.
You could probably replace commas by periods beforehand though:
Code:
$calc($replace($$2-,$chr(44),$chr(46)))


Oh, I didn't even think he could mean that, and I live in a place where we use commas :P
Posted By: GEFFO Re: Random remote scripts help needed - 27/08/10 01:48 PM
All things moving ahead!

Another question - What's the script for sending an invite and a message to a person requesting a invite to a private room?

E.g. After a person requests an invite, the request is sent to a private where. All the mods have to do is to type !invite and an invite + msg is sent to the person from the bot?

It's the script for after mods typing !invite that I'm after.

Cheers
Posted By: Thels Re: Random remote scripts help needed - 27/08/10 04:24 PM
Code:
/invite %nickname #channel


Of course you have to save the nickname to a variable when someone requests an invite.

Is also a little insecure, since if 2 people request an invite close behind each other, a mod could think he's inviting the first one, but then he happens to invite the second one.
© mIRC Discussion Forums