New Style of Bot Commander Final Release

By Cheiron on May 19, 2009

final and completed to my needs and sharing with you now is this unique bot commander.
like my other post, this does away with the !trigger in favour of regex and match words for the bot to work off of a /me command. this script was an accumalation of my request and debug from a very kind scripter, Jethro_ , who no doubt has algebraic headaches now from all the regex doing the code for me lol. i am deeply thankful to him and acknowledge him honestly here.

so, what can the bot do..

vop add / del , hop add / del , aop add / del , sop add / del
voice/devoice , halfop/dehalfop , op/deop , kick, ban, akick add / del
extended ban silence / unsilence , channel mode setting , mass channel modes

how to work the bot.

set your details where it says your_host/vhost (eg music@Tom.Jones.is.Welsh or jimmy@severhost.yourispdetails)

edited took some advice from another coment made on a different snippet about the danger of just using the if ($nick == mynick) check.. even with kill set to quick, a user can impersonate you for 20 secs which is more than enough time to cause issues heh.. updated to a more secure check.

in channel type in this format /me /

eg /me vop jimmy , /me set +M , /me silence timmy , /me akick jane , /me dhop a_fish_called_wanda

Mass mode part works differently to the set bit for this reason.
(1) set /me set +/- (room mode letter) eg /me set +M
(2) mode /me mode +/- (room mode letters) eg /me mode +iRSC
it is that simple.

here is the final code as tested on an unrealircd 3.2.7 server with anope services via a mirc v6.35 blank client. loads into a clean fresh remote

its as simple as that
i hope you enjoy it.

(p.s) if you want to make it ops triggerable instead of just you.. change the if ($nick == mynick) to if ($nick isop $chan)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;   Regex Bot commander final release    ;
;           Idea by Cheiron              ;
; Coded by Jethro_ and debugs by bone282 ;
; and Cheiron. Please out of respect     ;
; include this section when you paste in ;
; your remotes to give due where it is   ;
; due and enjoy this script. Cheiron     ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
on *:ACTION:*:#: {
  if ($address($nick,2) == your_host/vhost) 
    if ($regex($1-,/(^|\s)(kick?k?s?\s\S+)/i)) { tokenize 32 $regml(2) | kick $chan $2 }
    if ($regex($1-,/(^|\s)(vop?p?s?\s\S+)/i)) { tokenize 32 $regml(2) | cs vop $chan add $2 }
    if ($regex($1-,/(^|\s)(dvop?p?s?\s\S+)/i)) { tokenize 32 $regml(2) | cs vop $chan del $2 }
    if ($regex($1-,/(^|\s)(hop?p?s?\s\S+)/i)) { tokenize 32 $regml(2) | cs hop $chan add $2 }
    if ($regex($1-,/(^|\s)(dhop?p?s?\s\S+)/i)) { tokenize 32 $regml(2) | cs hop $chan del $2 }
    if ($regex($1-,/(^|\s)(aop?p?s?\s\S+)/i)) { tokenize 32 $regml(2) | cs aop $chan add $2 }
    if ($regex($1-,/(^|\s)(daop?p?s?\s\S+)/i)) { tokenize 32 $regml(2) | cs aop $chan del $2 }
    if ($regex($1-,/(^|\s)(sop?p?s?\s\S+)/i)) { tokenize 32 $regml(2) | cs sop $chan add $2 }
    if ($regex($1-,/(^|\s)(dsop?p?s?\s\S+)/i)) { tokenize 32 $regml(2) | cs sop $chan del $2 }
    if ($regex($1-,/(^|\s)(op?p?s?\s\S+)/i)) { tokenize 32 $regml(2) | mode $chan +o $2 }
    if ($regex($1-,/(^|\s)(deop?p?s?\s\S+)/i)) { tokenize 32 $regml(2) | mode $chan -o $2 }
    if ($regex($1-,/(^|\s)(halfop?p?s?\s\S+)/i)) { tokenize 32 $regml(2) | mode $chan +h $2 }
    if ($regex($1-,/(^|\s)(dehalfop?p?s?\s\S+)/i)) { tokenize 32 $regml(2) | mode $chan -h $2 }
    if ($regex($1-,/(^|\s)(voice?e?s?\s\S+)/i)) { tokenize 32 $regml(2) | mode $chan +v $2 }
    if ($regex($1-,/(^|\s)(devoice?e?s?\s\S+)/i)) { tokenize 32 $regml(2) | mode $chan -v $2 }
    if ($regex($1-,/(^|\s)(set?t?s?\s[\+\-][a-zA-Z]+)/i)) { tokenize 32 $regml(2) | mode $chan $2 }
    if ($regex($1-,/(^|\s)(ban?n?s?\s\S+)/i)) { tokenize 32 $regml(2) | mode $chan +b $address($2,2) }
    if ($regex($1-,/(^|\s)(unban?n?s?\s\S+)/i)) { tokenize 32 $regml(2) | mode $chan -b $address($2,2) }
    if ($regex($1-,/(^|\s)(akick?k?s?\s\S+)/i)) { tokenize 32 $regml(2) | cs akick $chan add $address($2,2) }
    if ($regex($1-,/(^|\s)(deakick?k?s?\s\S+)/i)) { tokenize 32 $regml(2) | cs akick $chan del $address($2,2) }
    if ($regex($1-,/(^|\s)(silence?e?s?\s\S+)/i)) { tokenize 32 $regml(2) | mode $chan +b ~q: $+ $address($2,2) }
    if ($regex($1-,/(^|\s)(unsilence?e?s?\s\S+)/i)) { tokenize 32 $regml(2) | mode $chan -b ~q: $+ $address($2,2) }
    if ($regex($1-,/(^|\s)(mode?e?s?\s\w+)/i)) { tokenize 32 $regml(2) | mode $chan + $+ $right($regml(2),6-1) }
    if ($regex($1-,/(^|\s)(demode?e?s?\s\w+)/i)) { tokenize 32 $regml(2) | mode $chan - $+ $right($regml(2),6-1) }
  }
}

Comments

Sign in to comment.
sparko   -  Aug 26, 2009

This is kinda pointless if you ask me, regex is quite slow in mIRC, although, indeed the possibilities using it; are endless. You'd be better off with a few $istoks and $strip. Not to mention if you match, and capture, and then use $regml(N) it removes the need for RE-STRIPPING $1-

 Respond  
WorldDMT   -  Jun 17, 2009

about $address($nick,2) u can put $wildsite

u can use hash tables if u want "/hadd -m name " like this

/hadd -m xcom kick kick # $2

/hadd -m xcom vop cs vop $chan add $2

for all commands.....

to remove /hdel xcom

and the code

on *:start:{ hmake xcom | if ($exists(xcom.data)) hload xcom xcom.data }
on *:exit:if $hget(xcom) { hsave xcom xcom.data | hfree xcom }
on @*:action:#:if (($wildsite == your_host/vhost) && ($hget(xcom,$1))) $($v1,2)
 Respond  
Cheiron   -  Jun 17, 2009

i have no issues with it. i did notice one very unusual thing thing though between the 2!

with the regex one... you can slip the command into a sentance, but your one .. we cant.

for example... with the regex one i can go /me ponders for a little bit and decides that we can voice timmy after all as he has earnt it.
and it will do it..
with your edit .. it wont.. it has to be a direct /me command

just found it out and surprised me :)

they both work as good as each other mind you

i have done a minor update on the check to make it a bit more secure :)

 Respond  
WorldDMT   -  Jun 17, 2009

i told u that was just an idea u have to see what messing and do it :)

 Respond  
Cheiron   -  Jun 16, 2009

this was using his version

11<11:59am> Joins: ira`s_RPORAR
06<11:59am>
Auto_Help sets mode: +v iras_RPORAR 04<11:59am> <Sleeping_On_The_Job> devoice iras_RPORAR
04<11:59am> Sleeping_On_The_Job devoice ira`s_RPORAR
06<11:59am>
Auto_Help sets mode: -v iras_RPORAR 04<11:59am> * Sleeping_On_The_Job set +M 06<11:59am> * Auto_Help sets mode: +M 04<11:59am> * Sleeping_On_The_Job set -M 06<11:59am> * Auto_Help sets mode: -M 04<11:59am> * Sleeping_On_The_Job mode iKSMC 06<11:59am> * Auto_Help sets mode: +iSKMC 04<11:59am> * Sleeping_On_The_Job unmode iKSMC 04<12:00pm> * Sleeping_On_The_Job demode iKSMC 06<12:00pm> * Auto_Help sets mode: -iSKMC 04<12:00pm> * Sleeping_On_The_Job vop iras_RPORAR
04<12:00pm> Sleeping_On_The_Job dvop ira`s_RPORAR
04<12:00pm>
Sleeping_On_The_Job kick iras_RPORAR 04<12:00pm> * iras_RPORAR was kicked by Auto_Help (Auto_Help)

i have spotted 2 main errors on both.. protection against setting things against itself (it can be made to kick itself etc) and also a security issue for people using it. i think the if ($nick isop $chan) is adequate... but not too convinced

 Respond  
Jethro   -  Jun 16, 2009

I notice WorldDMT used \w+ and that won't work for nicknames with special characters. He should have used \S+

 Respond  
Cheiron   -  Jun 16, 2009

ooops my bad. i forgot to change the text to action.. for me i have it text as i am used to that.. but for most people i recommened action :)
i will have a look at your one also WorldDMT and have a test and see what it is like :)
many thanks for that .. editing the mistake

 Respond  
WorldDMT   -  Jun 16, 2009

hi

but a saw u put /me vop jimmy "/me" is ON ACTION event not ON TEXT

btw u can also do this that is an e.g if it can help u some time

on *:action:*:#:{
  if $nick == yournick {
    if ($strip($1) == kick) kick # $2
    elseif $istok(set|mode|demode,$strip($1),124) {
      var %x $iif($strip($1) != set,$iif($left($strip($1),2) == de,- $+ $2,+ $+ $2),$2)
      mode # %x
    }
    elseif $regex($strip($1),/^(vop|dvop|hop|dhop|aop|daop|sop|dsop)\s?(\w+)?/iS) {
      var %x $iif($left($regml(1),1) == d,$remove($regml(1),$v1),$regml(1)),%y $iif($left($regml(1),1) == d,del,add)
      cs %x # %y $2
    }
    elseif $istok(akick|deakick,$strip($1),124) {
      var %x $iif($left($strip($1),2) == de,$remove($strip($1),de),$strip($1)),%y $iif($left($strip($1),2) == de,del,add)
      cs %x # %y $address($2,2)
    }
    elseif $regex($strip($1),/^(op|deop|halfop|dehalfop|voice|devoice)\s?(\w+)?/iS) {
      var %x $iif($left($regml(1),2) == de,$replace($regml(1),de,-,halfop,h,voice,v,op,o),$replace($regml(1),halfop,+h,voice,+v,op,+o))
      mode # %x $2
    }
    elseif $regex($strip($1),/^(ban|unban|silence|unsilence)\s?(\w+)?/iS) {
      var %x $iif($left($regml(1),2) == un,$replace($regml(1),un,-,ban $chr(32),b,silence,b ~q:),$replace($regml(1),ban,+b $chr(32),silence,+b ~q:))
      mode # %x $+ $address($2,2)
    }
  }
}
 Respond  
Cheiron   -  Jun 16, 2009

thank you Jethro_ :D it works a treat now. just saves so much time from having to do a trigger all the time

 Respond  
Jethro   -  Jun 16, 2009

lol Cheiron. Mistakes do happen to all of us. Just don't let them get the best of us. :P Nice going on the debug. :)

 Respond  
Cheiron   -  Jun 16, 2009

Final Release now updated folks. Many thanks to Jethro for whom this would not have been possible and to bone282 for the original debug. i did have to do some debugging to release this but i suspect poor Jethro had Algebraic headaches from all the regex GRINS and made a couple of rare errors. The actual code was sound.. just had to alter some of the commands that was all ( 2 x vop original) -> vop + dvop edited* , etc) very easy mistake when either tired or brain-farted from too much regex (i know i was!!)
Anyway.. i hope you enjoy this and please comment fairly .... Cheiron :)

 Respond  
bone282   -  May 22, 2009

you know what.. i think a regex manual snippet that echos to status or active might be a very handy tool indeed

 Respond  
WorldDMT   -  May 20, 2009

is a good idéa but u can use $findtok is simple...

 Respond  
Cheiron   -  May 19, 2009

ty. the rating has not shown though for the script. will be looking to upgrade this script soon too include other functions so keep eyes peeled

 Respond  
PATX   -  May 19, 2009

nice i like it 7/10

 Respond  
Cheiron   -  May 19, 2009

hehe.. i had a big read up on regex myself after finally locating a good tutorial and spotted it from what he had said and it is sort of making sense now.

 Respond  
Jethro   -  May 19, 2009

Oh my, how could I not have thought about using \S+ I completely blinded myself. With it, it'll work on nicks with special characters now. Big thanks to Bone282.

 Respond  
Firstmate   -  May 19, 2009

Its to trigger his commands.
In a sense its not really triggerless, more like, no one trigger-script

 Respond  
WorldDMT   -  May 19, 2009

hi

why all that regex??

 Respond  
RevJohn Straub   -  May 19, 2009

its a great code thanks makes it easier on me

 Respond  
Cheiron   -  May 19, 2009

thats got it. may thanks ;)

 Respond  
bone282   -  May 19, 2009

sure you can keep the regex.
change \w+ to \S+ :P

an uppercase \S matches any none-whitespace character.
where as the \s matches a whitespace character.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.