This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Random MSG

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
User avatar
iamdeath
Master
Posts: 323
Joined: Fri Feb 11, 2005 2:32 pm
Location: *HeLL*
Contact:

Random MSG

Post by iamdeath »

I need a small script which will make my bot msg randomly anyone in the channel after every x minutes op/voices are exempted they wont be msged by the bot. One more thing, if the bot msgs someone then it wont msg that nick until that nick parts the channel or quits from IRC.

is it possible that you create me this small script.

Thanks
iamdeath
|AmDeAtH @ Undernet
Death is only the *Beginning*...
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Code: Select all

set randmsg(time) 10

set randmsg(chan) #channel

set randmsg(msgs) {
 "msg 1"
 "msg 2"
 "msg 3"
}

bind time - * send:msg
bind part - * rem:nick
bind sign - * rem:nick
bind kick - * rem:nick

proc send:msg {m h args} {
 global randmsg
 if {([scan $m %d]+([scan $h %d]*60)) % $randmsg(time)  == 0} {
  set cl [split [string tolower [join [chanlist $randmsg(chan)]]]]
  set cll [llength $cl]
  set n [lindex $cl [rand $cll]]
  while {[set c [expr {[isvoice $n $randmsg($chan)] || [isop $n $randmsg(chan)] || [info exists randmsg(n:$n)]}]]} {
   set i [lsearch -exact $cl $n]
   set cl [lreplace $cl $i $i]
   if {[incr cll -1] < 1} {break}
   set n [lindex $cl [rand $cll]]
  }
  if {!$c} {
   puthelp "privmsg $n :[lindex $randmsg(msgs) [rand [llength $randmsg(msgs)]]]"
   set randmsg(n:$n) 1
  }
 }
}

proc rem:nick {nick uhost hand chan arg {rsn ""}} {
 global randmsg
 if {$rsn != ""} { set nick $arg }
  if {[info exists randmsg(n:[set nick [string tolower $nick]])]} {
  unset randmsg(n:$nick)
 }
}
Edit: Now it should not msg ops/voices and nicks that have already been msged unless they part/quit.
Edit2: Fixed error.
Edit3: Added refresh list on kick as well.
Last edited by Sir_Fz on Fri Jun 22, 2007 7:48 pm, edited 5 times in total.
User avatar
iamdeath
Master
Posts: 323
Joined: Fri Feb 11, 2005 2:32 pm
Location: *HeLL*
Contact:

Post by iamdeath »

Thanks alot SirFz, let me put it in the bot and will let you know if I find any problem.

Thanks once again.

iamdeath
|AmDeAtH @ Undernet
Death is only the *Beginning*...
User avatar
iamdeath
Master
Posts: 323
Joined: Fri Feb 11, 2005 2:32 pm
Location: *HeLL*
Contact:

Post by iamdeath »

The problem is that the bot is msging itself and also it's messagin the ops and voiced users. How can I make it not msg itself and op/voice users.

also it is msging users always, can't we restrict it so that if the bot msged one user it shouldnt msg him/her anymore until that nick parts or quits


I did this to find out:

Code: Select all

  puthelp "privmsg $n :[lindex $randmsg(msgs) [rand [llength $randmsg(msgs)]]]"
  putlog "Just msged $n"
  set randmsg(n:$n) 1
I found out:

Code: Select all

[17:37] <ShetanGal> [17:38] Just msged lair
[17:38] <ShetanGal> [17:39] Just msged cancerian
[17:39] <ShetanGal> [17:40] Just msged cheetah
[17:40] <ShetanGal> [17:41] Just msged shetangal
[17:41] <ShetanGal> [17:42] Just msged lair
[17:42] <ShetanGal> [17:43] Just msged alone_m_isb
You see the nickname lair comes 2 times lair is an op too and bot msges itself as it's nickname is ShetanGal.


Thanks
|AmDeAtH @ Undernet
Death is only the *Beginning*...
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Try the edited code now.
User avatar
iamdeath
Master
Posts: 323
Joined: Fri Feb 11, 2005 2:32 pm
Location: *HeLL*
Contact:

Post by iamdeath »

thanks alot, it's working smooth now :-)

Thank you soo much

iamdeath
|AmDeAtH @ Undernet
Death is only the *Beginning*...
User avatar
iamdeath
Master
Posts: 323
Joined: Fri Feb 11, 2005 2:32 pm
Location: *HeLL*
Contact:

Post by iamdeath »

Code: Select all

[03:02] <ShetanGal> [03:03] Tcl error [send:msg]: random limit must be greater than zero
[03:03] <ShetanGal> [03:04] Tcl error [send:msg]: random limit must be greater than zero
[03:04] <ShetanGal> [03:05] Tcl error [send:msg]: random limit must be greater than zero
This is what I get in DCC any idea?

thanks
iamdeath
|AmDeAtH @ Undernet
Death is only the *Beginning*...
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

I edited the code and the error must not appear anymore.
User avatar
iamdeath
Master
Posts: 323
Joined: Fri Feb 11, 2005 2:32 pm
Location: *HeLL*
Contact:

Post by iamdeath »

Thanks alot, it's working perfect now.

Thank you soo much :)

iamdeath
|AmDeAtH @ Undernet
Death is only the *Beginning*...
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

I've edited it again and added removing the nick from the already-msged nicks if it is kicked.
User avatar
iamdeath
Master
Posts: 323
Joined: Fri Feb 11, 2005 2:32 pm
Location: *HeLL*
Contact:

Post by iamdeath »

Thank you soo much SirFz, I really appreciate your efforts.

Thank You

iamdeath
|AmDeAtH @ Undernet
Death is only the *Beginning*...
Post Reply