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!
t
true_life
Voice
Posts: 11
Joined: Tue May 14, 2013 3:44 am

one command all channels

Post by true_life »

Hi EveryOne!!!!

i want a tcl script for my bot which can send message to every channel it is in or to specific channel on a command such as

abcdbot is on #123 #xyz #678

the main channel is #123

and when i type .all HELLO PLEASE LISTEN

so the bot messages on every channel it is.

thanks
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

bind PUB - .all all 

proc all {nick uhost hand chan arg} { 

	if {![string match -nocase $chan "#123"]} { return }

  	foreach c [channels] { 
		if {[botonchan $c] && ($chan != $c)} {
	       	putserv "PRIVMSG $chan :$arg" 
      		}	 
   	}	 
}
Last edited by Madalin on Tue May 14, 2013 4:38 am, edited 1 time in total.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Madalin that's not what he asked for, besides, there's no need for the lrange.

Code: Select all

bind pub * .all pub:all

proc pub:all {nick uhost hand chan text} {
	if {![string match -nocase $chan "#123"]} return
	foreach chn [channels] {
		if {![botonchan $chn]} continue
		puthelp "PRIVMSG $chn :$text"
	}
}
Since you haven't mentioned any user flags I left to be available to all (the *), so adjust it to your needs.

Edit: Typo.
Last edited by caesar on Tue May 14, 2013 2:45 pm, edited 1 time in total.
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 »

I modifyed my copy now ... i read but as you saw i forgot about the main channel 'my mistake' the new version should work ok now
t
true_life
Voice
Posts: 11
Joined: Tue May 14, 2013 3:44 am

Post by true_life »

thank you both of you and it was very quick!
t
true_life
Voice
Posts: 11
Joined: Tue May 14, 2013 3:44 am

Post by true_life »

thank you both of you and it was very quick!
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

set controlChan "#123"

bind pubm -|- "$controlChan .all *" pub:all

proc pub:all {nick uhost hand chan text} {
   set text [join [lrange [split $text] 1 end]]
   foreach ch [channels] {
      if {![botonchan $ch] || [string equal $ch $::controlChan} continue
      puthelp "PRIVMSG $chan :$text"
   }
}
An easier approach is using pubm style glob-masks to limit what has to be checked inside the procedure, simplifying the entire thing.
t
true_life
Voice
Posts: 11
Joined: Tue May 14, 2013 3:44 am

Post by true_life »

can you add something by which on specific members can use this command?

like people with .chattr +P will be able to use the .all command
User avatar
Madalin
Master
Posts: 310
Joined: Fri Jun 24, 2005 11:36 am
Location: Constanta, Romania
Contact:

Post by Madalin »

Just change what in bold with the flag letter you want (local)

bind pubm -|here
t
true_life
Voice
Posts: 11
Joined: Tue May 14, 2013 3:44 am

Post by true_life »

[17:11:43] Tcl error [pub:all]: missing close-bracket


this is the reply im getting in party line
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

try this...

Code: Select all

set controlChan "#123" 

bind pubm -|- "$controlChan .all *" pub:all 

proc pub:all {nick uhost hand chan text} { 
   set text [join [lrange [split $text] 1 end]] 
   foreach ch [channels] { 
      if {![botonchan $ch] || [string equal -nocase $ch $::controlChan]} continue 
      puthelp "PRIVMSG $chan :$text" 
   } 
}
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
t
true_life
Voice
Posts: 11
Joined: Tue May 14, 2013 3:44 am

Post by true_life »

instead of replying to other channels, it is replying to the same channel.
User avatar
Madalin
Master
Posts: 310
Joined: Fri Jun 24, 2005 11:36 am
Location: Constanta, Romania
Contact:

Post by Madalin »

Modify

Code: Select all

puthelp "PRIVMSG $chan :$text" 
with

Code: Select all

puthelp "PRIVMSG $chn :$text" 
t
true_life
Voice
Posts: 11
Joined: Tue May 14, 2013 3:44 am

Post by true_life »

same! + the both lines above are same to.
t
true_life
Voice
Posts: 11
Joined: Tue May 14, 2013 3:44 am

Post by true_life »

Tcl error [pub:all]: can't read "chn": no such variable
Post Reply