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 

Simple Channel Manager

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
GRapple5
Voice


Joined: 18 Jan 2010
Posts: 3

PostPosted: Mon Jan 18, 2010 9:00 pm    Post subject: Simple Channel Manager Reply with quote

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! Razz
Back to top
View user's profile Send private message
TCL_no_TK
Owner


Joined: 25 Aug 2006
Posts: 509
Location: England, Yorkshire

PostPosted: Tue Jan 19, 2010 3:02 am    Post subject: Reply with quote

is [nick] optional? i.e if someone uses !op in the admin channel, it will op them in the "normal" channel?
_________________
TCL the misunderstood
Back to top
View user's profile Send private message Send e-mail
GRapple5
Voice


Joined: 18 Jan 2010
Posts: 3

PostPosted: Tue Jan 19, 2010 11:38 am    Post subject: Reply with quote

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"
Back to top
View user's profile Send private message
TCL_no_TK
Owner


Joined: 25 Aug 2006
Posts: 509
Location: England, Yorkshire

PostPosted: Tue Jan 19, 2010 2:04 pm    Post subject: Reply with quote

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

_________________
TCL the misunderstood
Back to top
View user's profile Send private message Send e-mail
GRapple5
Voice


Joined: 18 Jan 2010
Posts: 3

PostPosted: Tue Jan 19, 2010 3:38 pm    Post subject: Reply with quote

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


Joined: 25 Aug 2006
Posts: 509
Location: England, Yorkshire

PostPosted: Wed Jan 20, 2010 7:55 am    Post subject: Reply with quote

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

_________________
TCL the misunderstood
Back to top
View user's profile Send private message Send e-mail
user
 


Joined: 18 Mar 2003
Posts: 1452
Location: Norway

PostPosted: Thu Jan 21, 2010 4:56 am    Post subject: Why use hardcoded channel names? Reply with quote

Here's an idea:
Code:
setudef str destchan

Then '.chanset #foo.priv destchan #foo' and use something like this in the procs:
Code:
if {![validchan [set dest [channel get $chan destchan]]]} {return}

This will make the script work on any number of channels.

EDIT: flag->str
_________________
Have you ever read "The Manual"?


Last edited by user on Thu Jan 21, 2010 9:21 am; edited 1 time in total
Back to top
View user's profile Send private message
TCL_no_TK
Owner


Joined: 25 Aug 2006
Posts: 509
Location: England, Yorkshire

PostPosted: Thu Jan 21, 2010 6:11 am    Post subject: Reply with quote

Code:
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 Smile
_________________
TCL the misunderstood
Back to top
View user's profile Send private message Send e-mail
user
 


Joined: 18 Mar 2003
Posts: 1452
Location: Norway

PostPosted: Thu Jan 21, 2010 9:20 am    Post subject: Reply with quote

Yeah...I meant str Smile 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"?
Back to top
View user's profile Send private message
TCL_no_TK
Owner


Joined: 25 Aug 2006
Posts: 509
Location: England, Yorkshire

PostPosted: Thu Jan 21, 2010 1:56 pm    Post subject: Reply with quote

Yeah, very agreeable Smile would shorted the code alot too in this case.
_________________
TCL the misunderstood
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
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