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.

Check if someone is the founder of a channel

Help for those learning Tcl or writing their own scripts.
Post Reply
j
jackyyll
Voice
Posts: 1
Joined: Fri Jul 17, 2009 4:59 pm

Check if someone is the founder of a channel

Post by jackyyll »

When someone executes a command on my eggdrop bot, say "remove #channel" I need the bot to check if the person executing that command is the owner of #channel... How would i go about doing this? I can't really think of a good way.
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

You could send an ACC request to chanserv services and interpret the response using a NOTC bind. However, things like this tend to be network specific. Unfortunately I don't know a better way that is reliable accross many networks.

This is a script I wrote for DALnet. I would not for a minute suggest it will work unmodified on other networks.

There is also a FLUD bind in the script to prevent the bot from ignoring messages from the network or network services. This is obviously network specific.

Code: Select all

# eggtcl-snippet-csacc.txt
# send a /cs ACC by public command and capture/interpret the response

# syntax
# !csacc <#channel> <nick>

bind FLUD - * prcCsaccFludServices
bind PUB - !csacc prcCsaccPubCommand
bind NOTC - * prcCsaccNotcReceive

proc prcCsaccFludServices {nick uhost hand type channel} {
  scan $uhost {%[^@]@%s} user host
  if {[string match -nocase "*dal.net" $host]} {return 1}
}

proc prcCsaccPubCommand {nick uhost hand channel txt} {
  global varCsaccSourceChan varCsaccSourceNick varCsaccTargetChan varCsaccTargetNick
  set arguments [string trim $txt]
  if {[llength [split $arguments]] == 2} {
    set tchan [lindex [split $arguments] 0]
    set tnick [lindex [split $arguments] 1]
    if {[regexp {^#} $tchan]} {
      if {[regexp -- {^[\x41-\x7D][-\d\x41-\x7D]*$} $tnick]} {
        set varCsaccSourceChan $channel
        set varCsaccSourceNick $nick
        set varCsaccTargetChan $tchan
        set varCsaccTargetNick $tnick
        putserv "PRIVMSG chanserv@services.dal.net :ACC $varCsaccTargetChan $varCsaccTargetNick"
      } else {putserv "PRIVMSG $channel :-error - ($nick) - $tnick is not in the format of a valid nick"}
    } else {putserv "PRIVMSG $channel :-error- ($nick) - $tchan is not in the format of a valid channel name"}
  } else {putserv "PRIVMSG $channel :-error- ($nick) - correct syntax is !csacc <#channel> <nick>"}
  return 0
}

proc prcCsaccNotcReceive {nick uhost hand txt dest} {
  global varCsaccSourceChan varCsaccSourceNick varCsaccTargetChan varCsaccTargetNick
  if {[string equal -nocase $nick chanserv]} {
    if {[info exists varCsaccSourceChan]} {
      set arguments [stripcodes bcruag $txt]
      if {([string match -nocase "*$varCsaccTargetChan*" $arguments]) || ([string match -nocase "*$varCsaccTargetNick*" $arguments])} {
        if {![string match -nocase "*the user*is not online*" $arguments]} {
          if {![string match -nocase "*the channel*is not registered*" $arguments]} {
            if {![string match -nocase "*you do not have enough access on*to perform that command*" $arguments]} {
              if {([llength [split $arguments]] == 4) || ([llength [split $arguments]] == 5)} {
                set target [lindex [split $arguments] 0]
                set type [lindex [split $arguments] 1]
                set channel [lindex [split $arguments] 2]
                set access [lindex [split $arguments] 3]
                if {[string equal -nocase $type acc ]} {
                  if {([string equal -nocase $target $varCsaccTargetNick]) && ([string equal -nocase $channel $varCsaccTargetChan])} {
                    switch -- $access {
                      -2 {set output "channel frozen or closed"}
                      -1 {set output "akicked from the channel"}
                       0 {set output "basic"}
                       1 {set output "aop"}
                       2 {set output "sop"}
                       3 {set output "founder via a nickserv access list mask"}
                       4 {set output "founder via identification to nickserv"}
                       5 {set output "founder via identification to chanserv"}
                    }
                    putserv "PRIVMSG $varCsaccSourceChan :$varCsaccTargetNick has chanserv access level $access in $varCsaccTargetChan ($output)"
                    unset varCsaccSourceChan
                    unset varCsaccSourceNick
                    unset varCsaccTargetChan
                    unset varCsaccTargetNick
                  }
                }
              }
            } else {putserv "PRIVMSG $varCsaccSourceChan :-error- ($varCsaccSourceNick) - I have insufficient access in $varCsaccTargetChan to carry out that command"}
          } else {putserv "PRIVMSG $varCsaccSourceChan :-error- ($varCsaccSourceNick) the channel $varCsaccTargetChan is not registered"}
        } else {putserv "PRIVMSG $varCsaccSourceChan :-error- ($varCsaccSourceNick) - the user $varCsaccTargetNick is not online"}
      }
    }
  }
  return 0
}

putlog "<eggTCL> eggtcl-snippet-csacc.txt loaded"
I must have had nothing to do
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

Sorry, maybe I should have enquired first.

I was assuming you meant IRC channel and not a partyline chat channel.

In any event, if my assumption is correct, I would suggest you make the IRC channels static by setting them in the bot's .conf file. That way they cannot be removed by others.
I must have had nothing to do
Post Reply