| View previous topic :: View next topic |
| Author |
Message |
eXtremer Op
Joined: 07 May 2008 Posts: 138
|
Posted: Mon May 19, 2008 5:29 am Post subject: Modify TCL code for my need (other chan cmd) |
|
|
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 |
|
 |
Alchera Revered One

Joined: 11 Aug 2003 Posts: 3344 Location: Ballarat Victoria, Australia
|
Posted: Mon May 19, 2008 11:44 pm Post subject: |
|
|
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 |
|
 |
edu Voice
Joined: 29 Oct 2006 Posts: 31
|
Posted: Thu May 22, 2008 12:57 am Post subject: |
|
|
this aint your script _________________ Seek the truth |
|
| Back to top |
|
 |
eXtremer Op
Joined: 07 May 2008 Posts: 138
|
Posted: Thu May 22, 2008 3:29 am Post subject: |
|
|
| 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 |
|
 |
Nor7on Op

Joined: 03 Mar 2007 Posts: 185 Location: Spain - Barcelona
|
Posted: Thu May 22, 2008 5:57 am Post subject: Search |
|
|
Search in the forum  |
|
| Back to top |
|
 |
eXtremer Op
Joined: 07 May 2008 Posts: 138
|
Posted: Thu May 22, 2008 7:04 am Post subject: Re: Search |
|
|
| Nor7on wrote: | Search in the forum  |
Search what ?  |
|
| Back to top |
|
 |
Nor7on Op

Joined: 03 Mar 2007 Posts: 185 Location: Spain - Barcelona
|
|
| Back to top |
|
 |
eXtremer Op
Joined: 07 May 2008 Posts: 138
|
Posted: Thu May 22, 2008 7:24 am Post subject: |
|
|
k, 10x! |
|
| Back to top |
|
 |
eXtremer Op
Joined: 07 May 2008 Posts: 138
|
Posted: Thu May 22, 2008 10:30 am Post subject: |
|
|
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 |
|
 |
Nor7on Op

Joined: 03 Mar 2007 Posts: 185 Location: Spain - Barcelona
|
Posted: Thu May 22, 2008 10:50 am Post subject: |
|
|
| 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" }
}
|
 |
|
| Back to top |
|
 |
Nor7on Op

Joined: 03 Mar 2007 Posts: 185 Location: Spain - Barcelona
|
Posted: Thu May 22, 2008 11:15 am Post subject: |
|
|
sorry.
change
| Code: |
[putserv "KICK $chan $tnick :Ban: $reason"]
|
for
| Code: |
putserv "KICK $chan $tnick :Ban: $reason"
|
|
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Fri May 23, 2008 12:24 pm Post subject: |
|
|
| 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 |
|
 |
eXtremer Op
Joined: 07 May 2008 Posts: 138
|
Posted: Sat May 24, 2008 6:10 am Post subject: |
|
|
| The issue solved, the code posted by me was succesfuly modified! |
|
| Back to top |
|
 |
strikelight Owner

Joined: 07 Oct 2002 Posts: 708
|
Posted: Sat May 24, 2008 1:47 pm Post subject: |
|
|
| 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 |
|
 |
|