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 

Modify TCL code for my need (other chan cmd)

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


Joined: 07 May 2008
Posts: 138

PostPosted: Mon May 19, 2008 5:29 am    Post subject: Modify TCL code for my need (other chan cmd) Reply with quote

This code bans somone with the !ban command:

<Me> !ban Nick test
*** Bot sets mode: +b *!*@host.com
*** Nick was kicked by Bot (test, by Me)

Code:
bind pub o|o [string trim $lol(cmdchar)]ban pub_lol_ban
bind pub o|o +b pub_lol_ban

### !BAN <nick|mask> [time] [reason]

proc pub_lol_ban {nick host hand chan arg} {
   set arg [charfilter $arg]
   global lol botnick
   if {![check $hand $nick $host]} {
      if {$lol(silent) == 1 || [checksilent $hand]} {return 0}
            puthelp "NOTICE $nick :You need to be identified to use this function. Type .identhelp in the partyline for more info. : \002/msg $botnick id <password>\002 or \002/msg $botnick silent <password>\002 to no more receive this warning."
      return 0
   }
   if {[llength $arg] < 1} {
      puthelp "NOTICE $nick :\002Usage:\002 [string trim $lol(cmdchar)]ban <nick|mask> \[time\] \[reason\]"
      return 0
   }
   set who [lindex $arg 0]
   if {[strlwr $who] == [strlwr $botnick]} {
      puthelp "NOTICE $nick :Yeah right, like I'm going to let you ban ME!"
      return 0
   }
   
   set ti [lindex $arg 1]
   if {[isnumber $ti]} {
      set reason [lrange $arg, 2 end]
   } {
      set ti ""
      set reason [lrange $arg, 1 end]
   }

   if {$reason == ""} { set reason "Requested," }
   
   if {[onchan $who $chan]} {
      if { $lol(bantype) == 0 } {
         set ipmask [lindex [split [maskhost $who![getchanhost $who $chan]] "@"] 1]
         set usermask [lindex [split [getchanhost $who $chan] "@"] 0]      
         set banmask *!*$usermask@$ipmask
      } else {
         set banmask [getchanhost $who $chan]
                 set banmask "*!*[string range $banmask [string first @ $banmask] e]"
      }   
   } else {        
      set banmask [lindex $arg 0]
      if {[string first "!" $banmask] == -1 && [string first "@" $banmask] == -1} {
         if {[isnumber [string index $banmask 0]]} {
            set banmask *!*@$banmask
         } else {
             set banmask $banmask*!*@*
         }
      }
      if {[string first "!" $banmask] == -1} { set banmask *!*$banmask }
      if {[string first "@" $banmask] == -1} { set banmask $banmask*@* }
   }
                  
   if {![botisop $chan]} { return 0 }
   putserv "MODE $chan +b $banmask"

     foreach chanuser [chanlist $chan] {
         if {[string match [strlwr $banmask] [strlwr "$chanuser![getchanhost $chanuser $chan]"]] && $chanuser != $botnick } {
         if {[nick2hand $chanuser $chan] != "*"} {
            if {$hand != [nick2hand $chanuser $chan]} {
               if {[matchattr [nick2hand $chanuser $chan] o|o $chan] && ![matchattr $hand o|o $chan]} {
                                 puthelp "NOTICE $nick :Sorry, you must be an operator to ban an operator."
                  return 0
               }
               if {([matchattr [nick2hand $chanuser $chan] m|m $chan] || [matchattr [nick2hand $who $chan] b]) && ![matchattr $hand m|m $chan]} {
                                 puthelp "NOTICE $nick :Sorry, you must be a master to ban a master or a bot."
                  return 0
               }
            }
         }
                putkick $chan $chanuser [join [lappend reason "by $nick"]]
      }
       }   

   switch $ti {
      ""
      {
         newchanban $chan $banmask $nick [join [lappend reason "by $nick"]]
         puthelp "NOTICE $nick :New mask added : $banmask"
      }
      0
      {
         newchanban $chan $banmask $nick [join [lappend reason "by $nick"]] $ti
         puthelp "NOTICE $nick :New mask added permanently : $banmask"
      }
      default
      {
         newchanban $chan $banmask $nick [join [lappend reason "by $nick"]] $ti
         puthelp "NOTICE $nick :New mask added for $ti minutes : $banmask"
      }
   }
   return 0
}



I need the same thing but for the "!dr" command it should have a predifined reason with permident (0) ban.

Example:

<Me> !dr Dronenick
*** Bot sets mode: +b *!*@host.net
*** [Banned]: Dronenick
*** Dronenick was kicked by Bot (You are infected join /join #DMSetup for help!, by Me)

This ban should have this reason "You are infected join /join #DMSetup for help!" and ban for ever (permident).

Waiting for replies, thanks in advance.
Back to top
View user's profile Send private message
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Mon May 19, 2008 11:44 pm    Post subject: Reply with quote

You have made attempts to contact the original author?

If not, please do so.
_________________
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Back to top
View user's profile Send private message Visit poster's website
edu
Voice


Joined: 29 Oct 2006
Posts: 31

PostPosted: Thu May 22, 2008 12:57 am    Post subject: Reply with quote

this aint your script
_________________
Seek the truth
Back to top
View user's profile Send private message
eXtremer
Op


Joined: 07 May 2008
Posts: 138

PostPosted: Thu May 22, 2008 3:29 am    Post subject: Reply with quote

edu wrote:
this aint your script


I know, I didn't said that this is mine, is taken from LoL's TooLz !
Back to top
View user's profile Send private message
Nor7on
Op


Joined: 03 Mar 2007
Posts: 185
Location: Spain - Barcelona

PostPosted: Thu May 22, 2008 5:57 am    Post subject: Search Reply with quote

Search in the forum Smile
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
eXtremer
Op


Joined: 07 May 2008
Posts: 138

PostPosted: Thu May 22, 2008 7:04 am    Post subject: Re: Search Reply with quote

Nor7on wrote:
Search in the forum Smile


Search what ? Smile
Back to top
View user's profile Send private message
Nor7on
Op


Joined: 03 Mar 2007
Posts: 185
Location: Spain - Barcelona

PostPosted: Thu May 22, 2008 7:17 am    Post subject: Reply with quote

look here:

http://forum.egghelp.org/viewtopic.php?p=81077&highlight=#81077
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
eXtremer
Op


Joined: 07 May 2008
Posts: 138

PostPosted: Thu May 22, 2008 7:24 am    Post subject: Reply with quote

Nor7on wrote:
look here:

http://forum.egghelp.org/viewtopic.php?p=81077&highlight=#81077


k, 10x!
Back to top
View user's profile Send private message
eXtremer
Op


Joined: 07 May 2008
Posts: 138

PostPosted: Thu May 22, 2008 10:30 am    Post subject: Reply with quote

I've modified a little bit the code it bans with !dr command and has a predifined reason, but I don't know where to set the ban time, I need it to be permident !
Help...
Back to top
View user's profile Send private message
Nor7on
Op


Joined: 03 Mar 2007
Posts: 185
Location: Spain - Barcelona

PostPosted: Thu May 22, 2008 10:50 am    Post subject: Reply with quote

Code:

#set the ban time in minutes. (0 = permban)
set bantime "60"

bind pub o .b pub:ban

proc pub:ban {nick uhost hand chan text} {
  global bantime
  if {[botisop $chan]} {
    if {[string length $text] > 0} {
      set tnick [lindex $text 0]
      if {[onchan $tnick $chan]} {
        if {[string length [lindex $text 1]] == 0} { set reason banned } else { set reason [lrange $text 1 end] }
        newchanban $chan *!*@[lindex [split [getchanhost $tnick $chan] @] 1] $nick $reason $bantime
        [putserv "KICK $chan $tnick :Ban: $reason"]
      } else { puthelp "notice $nick :no such nick on channel!" }
    } else { puthelp "NOTICE $nick :usage !kb <nick> reason - kicks and bans a nick" }
  } else { puthelp "NOTICE $nick :algo falla" }
}


Smile
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
Nor7on
Op


Joined: 03 Mar 2007
Posts: 185
Location: Spain - Barcelona

PostPosted: Thu May 22, 2008 11:15 am    Post subject: Reply with quote

sorry.

change

Code:

[putserv "KICK $chan $tnick :Ban: $reason"]


for
Code:

putserv "KICK $chan $tnick :Ban: $reason"
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Fri May 23, 2008 12:24 pm    Post subject: Reply with quote

You should be splitting $text (clearly a string variable) when combining it with list commands (lindex/lrange). The consequence of forgetting this is that curly bracings and other special characters will crash your script whenever used as part of $text. To turn strings into lists use split, to turn lists into strings use join. To forget to do either will only work on predetermined things, user input into $text is anything but predetermined...
Back to top
View user's profile Send private message
eXtremer
Op


Joined: 07 May 2008
Posts: 138

PostPosted: Sat May 24, 2008 6:10 am    Post subject: Reply with quote

The issue solved, the code posted by me was succesfuly modified!
Back to top
View user's profile Send private message
strikelight
Owner


Joined: 07 Oct 2002
Posts: 708

PostPosted: Sat May 24, 2008 1:47 pm    Post subject: Reply with quote

Looks like you are missing the "charfilter" proc, and I somehow doubt that it returns a list, in which case, you are still improperly using list commands on a string.
Back to top
View user's profile Send private message Visit poster's website
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