mIRC Home    About    Download    Register    News    Help

Print Thread
#125178 15/07/05 08:19 AM
Joined: Jul 2005
Posts: 11
A
Pikka bird
OP Offline
Pikka bird
A
Joined: Jul 2005
Posts: 11
I have a very simple bot and I really want to improve it to liven up the channel I'm at. I'm really a newbie at mIRC scripting so I really want to learn more about it. If you can help me, it would be much appreciated.

I've seen these scripts on other channels but I have no idea how people scripted them.

One script is that if a user joined the channel, if the first thing he/she said is "hi" or "hi everyone" or something similar, the bot would say hi to the person. If the user doesn't say hi right after they join, but they say hi minutes later, the bot won't welcome them. If a user out of nowhere said "hi" to a friend they knew, the bot won't welcome them either.

Another script is a fun one. If someone typed the trigger:
!stab blah blah blah
The bot would respond by stabbing "blah blah blah", something like this:
Bot stabs blah blah blah 234 times.
The number is random.

Thanks in advance.

#125179 15/07/05 10:16 AM
Joined: Mar 2005
Posts: 74
D
Babel fish
Offline
Babel fish
D
Joined: Mar 2005
Posts: 74
For the "Hi" part:

on 1:JOIN:#: {
set % $+ $nick 1
.timer 1 60 unset % $+ $nick
}
on 1:TEXT:*hi*:#: {
if (% [ $+ [ $nick ] ] == 1) {
.msg # Hiya $nick
unset % $+ $nick
}
}
--
When someone joins, a small variable is stored. When the person types something with "hi" in it, during the first minute, the bot will greet.

2nd thingy:
on 1:TEXT:!stab*:#: {
.timer -m 1 500 describe $chan stabs $2 $rand(100,999) times.
}

#125180 15/07/05 02:41 PM
Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
No need for timers here
And I'd add something before the nick as the variable, you don't want someone called i throw off your global counter variable %i do you smile

You can leave out the green part if you don't like/understand it, it's just some extra checking that you don't say hi when someone starts with 'hilight me plz' or something smile

on 1:JOIN:#: {
set -u60 %chanjoin. $+ $nick 1
}
on 1:TEXT:hi*:#: {
if (%chanjoin. [ $+ [ $nick ] ] && $regex($1-,/^hi\b/is) ) {
.msg # Hiya $nick
unset %chanjoin. $+ $nick
}
}

#125181 15/07/05 06:32 PM
Joined: Jul 2005
Posts: 11
A
Pikka bird
OP Offline
Pikka bird
A
Joined: Jul 2005
Posts: 11
Wow. Thanks for the help you guys! mIRC scripting is really confusing, I'll try my best to learn.

Oh yeah, is there a way that I can make my bot say stuff in all caps? I'm working on this script:

Quote:

on *:text:!stamp*:#: {
if (%stamp == off) { describe # stamps on nick: TRIGGER IS DISABLED. }
else {
{ set %stampee $2 }
{ set %text $3- }
describe $chan stamps on %stampee $+ : %text $+ . }
}
alias stamp.on {
set %stamp on
}
alias stamp.off {
set %stamp off
}
menu channel {
Stamping
.on:/stamp.on
.off:/stamp.off
}


I want to make the %text be in all caps.

#125182 15/07/05 07:10 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
$upper(text) will return text in all caps.


Invision Support
#Invision on irc.irchighway.net
#125183 15/07/05 08:20 PM
Joined: Jul 2005
Posts: 11
A
Pikka bird
OP Offline
Pikka bird
A
Joined: Jul 2005
Posts: 11
Thanks for the help!

About the random numbers, is there a way I can make something else random?

For instance if someone types "<3" in a channel, the bot will respond by typing a random number of <3. It can range from one <3 to a hundred <3's. The <3 will be in random colors of red (ctrl+k 4) and pink (ctrl+k 13). And if someone types "<3 20", the bot will respond by typing 20 <3's.

Sorry if I'm asking too much. Thanks.

#125184 15/07/05 08:32 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
First, you'd have to decide how to trigger it. Obviously you don't want the bot to respond to everything like that.

Here's a basic idea that you can build off of:

Code:
on *:text:&lt;3*:#yourchan: {
  if ($2 isnum) {
    msg $chan $str($1,$2)
  }
  else msg $chan $str($1,$rand(1,10))
}


That will display the text the number of times in a single color.

If you want random coloring, you'll need to do something like this:

Code:
on *:text:&lt;3*:#yourchan: {
  if ($2 isnum) {
    set %counter 1
    while (%counter &lt;= $2) {
      var %color $iif($rand(1,2) == 1,04,13)
      set %output %output $+  $+ %color
      inc %counter
    }
    msg $chan %output
  }
  else {
    set %counter 1
    while (%counter &lt;= $rand(1,10)) {
      var %color $iif($rand(1,2) == 1,04,13)
      set %output %output $+  $+ %color
      inc %counter
    }
    msg $chan %output
  }
  unset %output
  unset %counter
  unset %color
}


That should display random colors of 04 and 13 for each heart.

Note that for both of these, I limited the default random number of repeats to 1-10. You can change that if you like. Just replace all the $rand(1,10) with whatever number instead of 10.


Invision Support
#Invision on irc.irchighway.net
#125185 15/07/05 11:14 PM
Joined: Jul 2005
Posts: 11
A
Pikka bird
OP Offline
Pikka bird
A
Joined: Jul 2005
Posts: 11
Thanks.

The first script with the single colors worked fine but when I tested out the second script with the random colors by typing in "<3" the bot responded with a space.

me: <3
Bot:

Did I do something wrong? All I did was change "#yourchan" into the name of the channel I'm at.

#125186 16/07/05 01:39 AM
Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
oops, in the second section you forgot to include the actual string
try this
Code:
on *:text:&lt;3*:#yourchan: {
  if ($2 isnum) {
    var %string = $str(&lt;3 $chr(32) ,$2)
    var %counter = 1
    while (%counter &lt;= $2) {
      var %color = $iif($rand(1,2) == 1,04,13)
      var %output = %output $+ %color $+ $gettok(%string,%counter,32) 
      inc %counter
    }
    msg $chan %output
  }
  else {
    var %repeat = $r(1,10)
    var %string = $str(&lt;3 $chr(32) ,%repeat)
    var %counter = 1
    while (%counter &lt;= %repeat) {
      var %color = $iif($rand(1,2) == 1,04,13)
      var %output = %output $+ %color $+ $gettok(%string,%counter,32)
      inc %counter
    }
    msg $chan %output
  }
halt
}


Note I used local vars as there is no outside event that will use the vars (/set)

#125187 17/07/05 12:18 AM
Joined: Jul 2005
Posts: 11
A
Pikka bird
OP Offline
Pikka bird
A
Joined: Jul 2005
Posts: 11
Thanks a lot!

#125188 18/07/05 01:22 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Good catch, MikeChat. Sorry about that.


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard