egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

one command all channels
Goto page Previous  1, 2
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Tue May 14, 2013 2:48 pm    Post subject: Reply with quote

Code:

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.
Back to top
View user's profile Send private message
true_life
Voice


Joined: 14 May 2013
Posts: 11

PostPosted: Tue May 14, 2013 3:15 pm    Post subject: Reply with quote

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

and it has no o|o status so anyone can use it Surprised
Back to top
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Tue May 14, 2013 4:03 pm    Post subject: Reply with quote

Code:
# 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"
   }
}

_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
true_life
Voice


Joined: 14 May 2013
Posts: 11

PostPosted: Tue May 14, 2013 5:33 pm    Post subject: Reply with quote

Tcl error [pub:all]: missing close-bracket
Back to top
View user's profile Send private message
Madalin
Master


Joined: 24 Jun 2005
Posts: 310
Location: Constanta, Romania

PostPosted: Tue May 14, 2013 5:59 pm    Post subject: Reply with quote

Try this

Code:

# 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"
   }
}

_________________
https://github.com/MadaliNTCL - To chat with me: https://tawk.to/MadaliNTCL
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
true_life
Voice


Joined: 14 May 2013
Posts: 11

PostPosted: Tue May 14, 2013 6:30 pm    Post subject: Reply with quote

working fine except.. posting 2 replies.

i did,

.all testing final.


reply,

[03:29:20] <+bot1> test final
[03:29:22] <+bot1> final
Back to top
View user's profile Send private message
Madalin
Master


Joined: 24 Jun 2005
Posts: 310
Location: Constanta, Romania

PostPosted: Tue May 14, 2013 6:33 pm    Post subject: Reply with quote

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

Set text [join ......]
_________________
https://github.com/MadaliNTCL - To chat with me: https://tawk.to/MadaliNTCL
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Tue May 14, 2013 6:36 pm    Post subject: Reply with quote

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:
# 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.
_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Wed May 15, 2013 12:53 am    Post subject: Reply with quote

Code:

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.
Back to top
View user's profile Send private message
Madalin
Master


Joined: 24 Jun 2005
Posts: 310
Location: Constanta, Romania

PostPosted: Wed May 15, 2013 5:22 am    Post subject: Reply with quote

Instead of

Quote:

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:

if {$chan != $chn} { ... }

_________________
https://github.com/MadaliNTCL - To chat with me: https://tawk.to/MadaliNTCL
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Wed May 15, 2013 9:48 am    Post subject: Reply with quote

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:

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.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber