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.

Auto-Add on Channel Registration

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
J
JC^
Voice
Posts: 4
Joined: Fri May 25, 2007 1:43 pm

Auto-Add on Channel Registration

Post by JC^ »

Hi. I'd like to make a script where the eggdrop can join and add itself to a channel as soon as its created.

I've got a channel where every command is outputted and so when a channel is created and registered, the channel says:

Code: Select all

<Global> ChanServ: Channel '#Cottage-by-the-Sea' registered by Dorian
I'd like the bot to be able to listen for that or a similar string, then automatically perform a +chan automatically so it joins the channel, then saves it all the next time it does the chansave.

Can someone assist me?
User avatar
TCL_no_TK
Owner
Posts: 509
Joined: Fri Aug 25, 2006 7:05 pm
Location: England, Yorkshire

Post by TCL_no_TK »

Code: Select all

proc pub:global:chanreg {nick host handle channel text} {
global botnick
 set type [lindex $text 0]
  if {$type == "Channel"} {
   set newchan [lindex [split [lindex $text 1] "'"] 1]
    if {![validchan $newchan]} {
     channel add $newchan
      puthelp "PRIVMSG ChanServ :SOP $newchan ADD $botnick"
       return 1
    }
  }
}

bind pub -|- "ChanServ:" pub:global:chanreg
let me know if there are any problems, errors or things ya want changing. :)
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

That script will cause problems if you use it like that.
This version should be much more secure.

Also, you should note that the bot will use alot of resources if it has to join alot of channels like this.
You're better off using a network service for these kind of things.

[untested]

Code: Select all

# Make sure you set the full hostname here. (this is to make sure it's not spoofed)
set chanserv(source) "Global!user@hostname"
# This is the message that's sent by the service (don't change it)
set chanserv(pattern) "ChanServ: Channel '*' registered by *"
# The channel in which the service sends the message.
set chanserv(channel) "#servicechannel"

bind pub -|- "ChanServ:" pub:global:chanreg

proc pub:global:chanreg {nick host handle channel text} {
    global chanserv
    if {[string equal -nocase $channel $chanserv(channel)] && [string equal -nocase $nick!$host $chanserv(source)] && [string match -nocase $chanserv(pattern) $text]} {
        set text [string map [list ' ""] $text]
        set channel [lindex [split $text] 2]

        if {![validchan $channel]} {
            channel add $channel
        }
    }
}
User avatar
TCL_no_TK
Owner
Posts: 509
Joined: Fri Aug 25, 2006 7:05 pm
Location: England, Yorkshire

Post by TCL_no_TK »

It would be difficult to make this type of script secure. I'm sure the person that owns the bot/network would of increased security my means such as locking the channel ...etc as this tends to be strongly adviced when having services log to a channel. On a scripting note, Is it even possible to check the hostmask of Global in this situation, since it wouldn't be on the channel (unless you use a module to do this*). I assumed this type of thing would be the same as a server sending msg's to a channel. :)
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

TCL_no_TK wrote:It would be difficult to make this type of script secure. I'm sure the person that owns the bot/network would of increased security my means such as locking the channel ...etc as this tends to be strongly adviced when having services log to a channel. On a scripting note, Is it even possible to check the hostmask of Global in this situation, since it wouldn't be on the channel (unless you use a module to do this*). I assumed this type of thing would be the same as a server sending msg's to a channel. :)
Actually, regardless of if the sender is on the channel or not, the nickname and user@hostname are still sent with the PRIVMSG.

Also _YOUR_ script was so insecure it would allow any user to add channels regardless of who said the line.
Since the eggdrop would be on alot of channels it would allow any user to spam the bot by adding it to dozens if not hundreds of channels.

Not to sound smug or arrogant but if you don't know about the IRC protocol then please don't tell me that my script is pointless.
My script is pretty much as secure as it can get whilst yours is an open book to any user.
User avatar
TCL_no_TK
Owner
Posts: 509
Joined: Fri Aug 25, 2006 7:05 pm
Location: England, Yorkshire

Post by TCL_no_TK »

... regardless of if the sender is on the channel or not, the nickname and user@hostname are still sent with the PRIVMSG.
Thanks, good to know. Was thinking of server's :)
Also _YOUR_ script was so insecure it would allow any user to add channels regardless of who said the line.
Since the eggdrop would be on alot of channels it would allow any user to spam the bot by adding it to dozens if not hundreds of channels.
I was aware of this but as i stated, it would be difficult to make this type of script secure. As you said i think it would be better to use network services such as BotServ for this type of thing.
Not to sound smug or arrogant but if you don't know about the IRC protocol then please don't tell me that my script is pointless.
My script is pretty much as secure as it can get whilst yours is an open book to any user.
These comments would be better off left for private message, since i cant see them being constructive/relivant to this topic. :roll: I like giving my input and asking questions about scripting on differant posts as long as i dosen't disrupt it. I dont think it would appropriate to pick out "security holes" in each others code like this. :(
Post Reply