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.

one command all channels

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Code: Select all

set controlChan "#123"
bind pub * .all pub:all

proc pub:all {nick uhost hand channel text} {
   if {![string match -nocase $channel $::controlChan]} return
   foreach chan [channels] {
      if {![botonchan $chan]} continue
      puthelp "PRIVMSG $chan :$text"
   }
}
Once the game is over, the king and the pawn go back in the same box.
t
true_life
Voice
Posts: 11
Joined: Tue May 14, 2013 3:44 am

Post by true_life »

its replying on all channel! including the 'main channel' twice!

and it has no o|o status so anyone can use it :o
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

# main control channel
set controlChan "#123"
# flags required
# global|channel
set controlFlags "o|o"

# create bind using flags and chan
bind pubm $controlFlags "$controlChan .all *" pub:all

proc pub:all {nick uhost hand chan text} {
   # pubm binds pass entire text, remove .all at front
   set text [join [lrange [split $text] 1 end]]
   # iterate channels
   foreach ch [channels] {
      # if bot isn't on channel or channel is control channel, skip
      if {![botonchan $ch] || [string equal $ch $::controlChan} continue
      # otherwise, issue text to the channel
      puthelp "PRIVMSG $ch :$text"
   }
}
t
true_life
Voice
Posts: 11
Joined: Tue May 14, 2013 3:44 am

Post by true_life »

Tcl error [pub:all]: missing close-bracket
User avatar
Madalin
Master
Posts: 310
Joined: Fri Jun 24, 2005 11:36 am
Location: Constanta, Romania
Contact:

Post by Madalin »

Try this

Code: Select all

# main control channel
set controlChan "#123"
# flags required
# global|channel
set controlFlags "o|o"

# create bind using flags and chan
bind pubm $controlFlags "$controlChan .all *" pub:all

proc pub:all {nick uhost hand chan text} {
	# pubm binds pass entire text, remove .all at front
	set text [join [lrange [split $text] 1 end]]
	# iterate channels
	foreach ch [channels] {
		# if bot isn't on channel or channel is control channel, skip
		if {![botonchan $ch] || [string equal $ch $::controlChan]} continue
		# otherwise, issue text to the channel
		puthelp "PRIVMSG $ch :$text"
	}
}
t
true_life
Voice
Posts: 11
Joined: Tue May 14, 2013 3:44 am

Post by true_life »

working fine except.. posting 2 replies.

i did,

.all testing final.


reply,

[03:29:20] <+bot1> test final
[03:29:22] <+bot1> final
User avatar
Madalin
Master
Posts: 310
Joined: Fri Jun 24, 2005 11:36 am
Location: Constanta, Romania
Contact:

Post by Madalin »

I was just reparing the bracelet missing... to solve that remove following line

Set text [join ......]
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

true_life wrote:working fine except.. posting 2 replies.

i did,

.all testing final.


reply,

[03:29:20] <+bot1> test final
[03:29:22] <+bot1> final
You need to .restart your bot. Multiple binds are tiggering now causing that repeat. Both the pub and pubm are surely loaded. The text is being correctly removed from the "pubm" bind, but the "pub" bind is having the first word removed incorrectly. This is evidence that indeed, you have not .restart'ed your bot.

Code: Select all

# main control channel
set controlChan "#123"
# flags required
# global|channel
set controlFlags "o|o"

# create bind using flags and chan
bind pubm $controlFlags "$controlChan .all *" pub:all

proc pub:all {nick uhost hand chan text} {
   # pubm binds pass entire text, remove .all at front
   set text [join [lrange [split $text] 1 end]]
   # iterate channels
   foreach ch [channels] {
      # if bot isn't on channel or channel is control channel, skip
      if {![botonchan $ch] || [string equal $ch $::controlChan]} continue
      # otherwise, issue text to the channel
      puthelp "PRIVMSG $ch :$text"
   }
}
Use the code as is and it works. Make sure to .restart before you do so to "clean" the binds out.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Code: Select all

set controlChan "#123"
bind pub * .all pub:all

proc pub:all {nick uhost hand channel text} {
   if {![string match -nocase $channel $::controlChan]} return
	set channels [channels]
	set pos [lsearch -nocase $channels $::controlChan]
	set channels [lreplace $channels $pos $pos]
	foreach chan $channels {
		if {![botonchan $chan]} continue
		puthelp "PRIVMSG $chan :$text"
	}
}
There. Now it should send that message to all channels except the control one. You should restart the bot as some binds aren't removed by a rehash.
Once the game is over, the king and the pawn go back in the same box.
User avatar
Madalin
Master
Posts: 310
Joined: Fri Jun 24, 2005 11:36 am
Location: Constanta, Romania
Contact:

Post by Madalin »

Instead of
set channels [channels]
set pos [lsearch -nocase $channels $::controlChan]
set channels [lreplace $channels $pos $pos]
i would really just use (thats why i dont use lsearch that much)

Code: Select all

if {$chan != $chn} { ... }
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

The foreach loop would execute that if statement n times (that represents the number of elements in the [channels] result), so this translates into executing that if statement 15 times, when could easily avoid that by those 3 lines that removes the control channel from the list.

The:

Code: Select all

if {$chan != $chn} { ... } 
is a bad idea to compare two strings like that. You should at least make both lower/higher case first, or better use string match -nocase that doesn't care if the two strings are lower/higher case.
Once the game is over, the king and the pawn go back in the same box.
Post Reply