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.

Modify TCL code for my need (other chan cmd)

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
e
eXtremer
Op
Posts: 138
Joined: Wed May 07, 2008 5:33 am

Modify TCL code for my need (other chan cmd)

Post by eXtremer »

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: Select all

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.
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

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
e
edu
Voice
Posts: 31
Joined: Sun Oct 29, 2006 2:10 pm

Post by edu »

this aint your script
Seek the truth
e
eXtremer
Op
Posts: 138
Joined: Wed May 07, 2008 5:33 am

Post by eXtremer »

edu wrote:this aint your script
I know, I didn't said that this is mine, is taken from LoL's TooLz !
User avatar
Nor7on
Op
Posts: 185
Joined: Sat Mar 03, 2007 8:05 am
Location: Spain - Barcelona
Contact:

Search

Post by Nor7on »

Search in the forum :)
e
eXtremer
Op
Posts: 138
Joined: Wed May 07, 2008 5:33 am

Re: Search

Post by eXtremer »

Nor7on wrote:Search in the forum :)
Search what ? :)
User avatar
Nor7on
Op
Posts: 185
Joined: Sat Mar 03, 2007 8:05 am
Location: Spain - Barcelona
Contact:

Post by Nor7on »

e
eXtremer
Op
Posts: 138
Joined: Wed May 07, 2008 5:33 am

Post by eXtremer »

e
eXtremer
Op
Posts: 138
Joined: Wed May 07, 2008 5:33 am

Post by eXtremer »

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...
User avatar
Nor7on
Op
Posts: 185
Joined: Sat Mar 03, 2007 8:05 am
Location: Spain - Barcelona
Contact:

Post by Nor7on »

Code: Select all

#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" }
} 
:)
User avatar
Nor7on
Op
Posts: 185
Joined: Sat Mar 03, 2007 8:05 am
Location: Spain - Barcelona
Contact:

Post by Nor7on »

sorry.

change

Code: Select all

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

Code: Select all

putserv "KICK $chan $tnick :Ban: $reason"
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

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...
e
eXtremer
Op
Posts: 138
Joined: Wed May 07, 2008 5:33 am

Post by eXtremer »

The issue solved, the code posted by me was succesfuly modified!
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

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.
Post Reply