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.

Simple Channel Manager

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
G
GRapple5
Voice
Posts: 3
Joined: Mon Jan 18, 2010 8:51 pm

Simple Channel Manager

Post by GRapple5 »

Hi,

I have a very simple issue, I have 2 channels #hunters and #hunters.priv. I want to make the following commands work in the #hunters.priv channel:
- !ban [NICK] (optional reason displayed in kickmessage)
- !unban [NICK]
- !op [NICK]
- !voice [NICK]

I want all these commands to only work for the channels local banlist so not for them to get placed on the bots internal banlist. I must stress that I want all these commands to be send FROM the .priv channel and to be executed in the standard (#hunters) channel. So an admin in #hunters.vip can type "!ban IdiotNick Generally being an idiot" and it will remove him from the #hunters channel. I am fully aware there are channel management scripts out there however they seem too advanced and almost do "too much" I just want a basic script that can do the stated commands and when I improve my TCL skills I can easily edit it laster as once I have a core to work from I am sure I will easily be able to add other commands such as !limit etc.

Cheers guys! :P
User avatar
TCL_no_TK
Owner
Posts: 509
Joined: Fri Aug 25, 2006 7:05 pm
Location: England, Yorkshire

Post by TCL_no_TK »

is [nick] optional? i.e if someone uses !op in the admin channel, it will op them in the "normal" channel?
G
GRapple5
Voice
Posts: 3
Joined: Mon Jan 18, 2010 8:51 pm

Post by GRapple5 »

No the nick should always be there, the only optional text should be the !ban reason, I had the idea that of someone wants to op themself they can just use "!op their own nick"
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

 # Private Ops Channel where the commands can be used from
 set private_channel "#hunters.priv"
 # Main Channel where the commands will be sent to
 set main_channel "#hunters"

 bind pub -|- !op pub:op
 bind pub -|- !voice pub:voice
 bind pub -|- !ban pub:ban
 bind pub -|- !unban pub:unban

 proc pub:op {nick uhost hand chan text} {
  global private_channel main_channel
   set chan [string tolower $chan]
   set target [lindex [split $text] 0]
    if {($chan == $private_channel)&&($target != "")&&([onchan "$target" "$main_channel"])} {
       pushmode $main_channel +o $target
    }
 }

 proc pub:voice {nick uhost hand chan text} {
  global private_channel main_channel
   set chan [string tolower $chan]
   set target [lindex [split $text] 0]
    if {($chan == $private_channel)&&($target != "")&&([onchan "$target" "$main_channel"])} {
       pushmode $main_channel +v $target
    }
 }

 proc pub:ban {nick uhost hand chan text} {
  global private_channel main_channel tmp3
   set chan [string tolower $chan]
   set target [lindex [split $text] 0]
   set reason [lrange [split $text] 1 end]
   if {$reason == ""} {
    set reason "requested"
   }
    if {($chan == $private_channel)&&($target != "")&&(![isbotnick $target])&&([onchan $target "$main_channel"])} {
     if {![info exists tmp3($target)]} {
      set tmp3($target) "[getchanhost $target $main_channel]"
     }
     putserv "KICK $main_channel $target :$reason"
     putserv "MODE $main_channel +b *!*@[lindex [split [getchanhost $target $main_channel] @] 1]"
    }
 }

 proc pub:unban {nick uhost hand chan text} {
  global private_channel main_channel tmp3
   set chan [string tolower $chan]
   set target [lindex [split $text] 0]
   if {($chan == $private_channel)&&($target != "")} {
    if {[info exists tmp3($target)]} {
     putserv "MODE $main_channel -b *!*@[lindex [split $tmp3($target) @] 1]"
    } else {
     puthelp "PRIVMSG $chan :I dont remenber banning '$target'"
    }
   }
 }
G
GRapple5
Voice
Posts: 3
Joined: Mon Jan 18, 2010 8:51 pm

Post by GRapple5 »

Worked like a charm, I've just been talking to another clan who is a friend of ours and they would also like to use the bot (my bot) on their set of channels #otlws and #otlws.priv I know I could setup another set of binds such as !ban2, so it will work on their channels too however is their some easy way to make the all the commands !ban, !voice, !op etc work with both our sets of channels (#hunters, #hunters.priv) and (#otlws, #otlws.priv), I presume there is a string search function that will allow you to search the variable to see which set of channels it is supposed to be executing on. I saw this thread (http://forum.egghelp.org/viewtopic.php?t=17513) in the recent threads and that is pretty much exactly what I want to do except obviously for 2 different sets of channels and for it to ban, voice, op people rather than just saying something to the channel. Thanks.
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

 bind pub -|- !op pub:op
 bind pub -|- !voice pub:voice
 bind pub -|- !ban pub:ban
 bind pub -|- !unban pub:unban

 proc pub:op {nick uhost hand chan text} {
   set chan [string tolower $chan]
   if {![regexp {^(#hunters.priv|#otlws.priv)$} "$chan"]} {
    return
   }
   if {$chan == "#hunters.priv"} {
    set dest "#hunters"
   } else {
    set dest "#otlws"
   }
   set target [lindex [split $text] 0]
   if {($target != "")&&([onchan "$target" "$dest"])} {
    pushmode $dest +o $target
   }
 }

 proc pub:voice {nick uhost hand chan text} {
   set chan [string tolower $chan]
   if {![regexp {^(#hunters.priv|#otlws.priv)$} "$chan"]} {
    return
   }
   if {$chan == "#hunters.priv"} {
    set dest "#hunters"
   } else {
    set dest "#otlws"
   }
   set target [lindex [split $text] 0]
   if {($target != "")&&([onchan "$target" "$dest"])} {
    pushmode $dest +v $target
   }
 }

 proc pub:ban {nick uhost hand chan text} {
  global tmp3
   set chan [string tolower $chan]
   if {![regexp {^(#hunters.priv|#otlws.priv)$} "$chan"]} {
    return
   }
   if {$chan == "#hunters.priv"} {
    set dest "#hunters"
   } else {
    set dest "#otlws"
   }
   set target [lindex [split $text] 0]
   set reason [lrange [split $text] 1 end]
    if {$reason == ""} {
     set reason "requested"
    }
    if {($target != "")&&(![isbotnick $target])&&([onchan "$target" "$dest"])} {
     if {![info exists tmp3($target)]} {
      set tmp3($target) "[getchanhost $target $dest]"
     } else {
      # I've added this incase someone's IP or host changes
      if {![string match "$tmp3($target)" "[getchanhost $target $dest]"]} {
       set tmp3($target) "[getchanhost $target $dest]"
      }
     }
      putserv "KICK $dest $target :$reason"
      putserv "MODE $dest +b *!*@[lindex [split [getchanhost $target $dest] @] 1]"
    }
 }

 proc pub:unban {nick uhost hand chan text} {
  global tmp3
   set chan [string tolower $chan]
   if {![regexp {^(#hunters.priv|#otlws.priv)$} "$chan"]} {
    return
   }
   if {$chan == "#hunters.priv"} {
    set dest "#hunters"
   } else {
    set dest "#otlws"
   }
   set target [lindex [split $text] 0]
   if {($target != "")} {
    if {[info exists tmp3($target)]} {
     putserv "MODE $dest -b *!*@[lindex [split $tmp3($target) @] 1]"
    } else {
     puthelp "PRIVMSG $chan :I dont remenber banning '$target'"
    }
   }
 }
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Why use hardcoded channel names?

Post by user »

Here's an idea:

Code: Select all

setudef str destchan
Then '.chanset #foo.priv destchan #foo' and use something like this in the procs:

Code: Select all

if {![validchan [set dest [channel get $chan destchan]]]} {return}
This will make the script work on any number of channels.

EDIT: flag->str
Last edited by user on Thu Jan 21, 2010 9:21 am, edited 1 time in total.
Have you ever read "The Manual"?
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

setudef str ...
Probably what i would use if i was using the script, but this way it keeps it simple and give's the user a good base/idea of how to change and modify the script later on to do what he needs it to :)
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Yeah...I meant str :) It's been a while since I did any eggdrop related coding. I don't see how learning to use custom channel settings would be a bad idea, though. It's not much harder to grasp than the logic you use to do the channel name checking IMO. (You could move the 'set' part out of the 'if' to make it more readable)
Have you ever read "The Manual"?
User avatar
TCL_no_TK
Owner
Posts: 509
Joined: Fri Aug 25, 2006 7:05 pm
Location: England, Yorkshire

Post by TCL_no_TK »

Yeah, very agreeable :) would shorted the code alot too in this case.
Post Reply