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.

/names $chan

Help for those learning Tcl or writing their own scripts.
Post Reply
Z
Zio_ruo
Voice
Posts: 4
Joined: Thu Sep 03, 2009 7:23 pm
Location: Italy A__A

/names $chan

Post by Zio_ruo »

Hi all, i wrote this script for make a /names $chan when a user join a specific chan:

Code: Select all

bind join - * join:raw
bind raw - 353 RAW:bla
proc join:raw { nick host hand chan } {
        if { $chan == "humanature" } {
                putserv "NAMES $chan"
                return 1}
                }
proc RAW:bla { from keyword text } {
                putserv "PRIVMSG #humanature :$text"
                }

putlog "\037BlaBOh tcl  by Zio_ruo\037"
But it works only when the bot is joining the chan (i think because the eggdrop make a right /names $chan when it joins a chan)
Pizza Pasta Mandolini e Mafia *ç*.
No :)
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

Your bot is receiving the RAW 353 as an automatic response from the server when joining a channel, and not as a consequence of the code within your join proc. Your join proc does not work for any user INCLUDING the bot.

Code: Select all

if {$chan == "humannature"} {
  # code here
}
In the above statement, there is no # in front of the channel name and in any case it is inadvisable to use such an equality test because it does not allow for differences in case. For example, the bot may know the channel as #Humanature rather than #humanature.

The following equality test is better

Code: Select all

if {[string equal -nocase $chan #humanature]} {
  # code here
}
You might also want to prevent the code from triggering when the bot joins, since it will receive the RAW 353 automatically anyway.

The following code should work

Code: Select all

bind JOIN - * pUserJoin
bind RAW - 353 pRaw353

proc pUserJoin {nick uhost hand chan} {
    if {![isbotnick $nick]} {
        if {[string equal -nocase $chan #humanature]} {
            putserv "NAMES $chan" 
        }
    }
    return 0
}

proc pRaw353 {from keyword text} {
    putserv "PRIVMSG #humanature :$text"
    return 0
} 

putlog "\037BlaBOh tcl  by Zio_ruo\037" 
Alternatively you could have put the channel name in the JOIN bind mask. If I am not mistaken this is not case sensitive. There is good reason for this. The command 'string equal' is from the Core Tcl language where there is no concept of what an IRC channel is. However, a JOIN bind and associated mask is from Eggdrop TCL where the mask is expected to begin with an IRC channel name, for which case is irrelevant.

Code: Select all

bind JOIN - "#humanature *" pUserJoin
bind RAW - 353 pRaw353

proc pUserJoin {nick uhost hand chan} {
    if {![isbotnick $nick]} {
        putserv "NAMES $chan" 
    }
    return 0
}

proc pRaw353 {from keyword text} {
    putserv "PRIVMSG #humanature :$text"
    return 0
} 

putlog "\037BlaBOh tcl  by Zio_ruo\037" 
I must have had nothing to do
Z
Zio_ruo
Voice
Posts: 4
Joined: Thu Sep 03, 2009 7:23 pm
Location: Italy A__A

Post by Zio_ruo »

Thank you so much *_*
It works but there is a little problem:
(21:06:44) [Part] Zio_ruo (-@stfu.omfgwtfbbq.org)
(21:06:44) [Join]: Ora sei in #humanature
(21:06:46) <@Jagannath> Jagannath @ #humanature :@Zio_ruo @Hanky_Panky @Jagannath
(21:06:47) <@Jagannath> Jagannath @ #humanature :@Zio_ruo @Hanky_Panky @Jagannath
However i have stupid domand °°:

Code: Select all

        if {[string equal -nocase $chan #humanature]} { 
Can i find stuff like this in eggdrop /doc or in tcl tutorials ?_?
Last edited by Zio_ruo on Tue Sep 22, 2009 4:50 pm, edited 1 time in total.
Pizza Pasta Mandolini e Mafia *ç*.
No :)
r
raider2k
Op
Posts: 140
Joined: Tue Jan 01, 2008 10:42 am

Post by raider2k »

find it at

http://www.tcl.tk/man/tcl8.5/TclCmd/contents.htm
for tcl 8.5

or
http://www.tcl.tk/man/tcl8.4/TclCmd/contents.htm
for tcl 8.4

nevertheless its almost the same
Z
Zio_ruo
Voice
Posts: 4
Joined: Thu Sep 03, 2009 7:23 pm
Location: Italy A__A

Post by Zio_ruo »

Thank you too ^^
Pizza Pasta Mandolini e Mafia *ç*.
No :)
Post Reply