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 

[SOLVED] Ban code error

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
Riddler
Halfop


Joined: 20 May 2007
Posts: 60
Location: Brasov, Romania

PostPosted: Sun Jun 10, 2007 10:05 pm    Post subject: [SOLVED] Ban code error Reply with quote

Hello all, I need some help form you guys...if posibile .
I have a tried to code a ban script and also I`m working one a blacklist script and I`m geting some errors:

The code:

Code:
# ban.tcl

# Set here reason and bantime in minutes for bans
set dj(br) "Banned!"
set dj(bt) 1440

# Activate ban times? [1/0]
set dj(bact) 1

###END CFG ###

bind pub n|MASDTO .b s:b
bind pub n|MAS .bl s:black
bind pub n|MAS .black s:black

setudef flag djtools

proc s:b {nick uhost hand chan text} {
  global botnick dj
   if {[channel get $chan djtools] && ![isbotnick $nick]} {
   if {[matchattr $hand n|MASDTO $chan] || [string tolower $chan]} {
     set bnick [lindex $text 0]
     if {![botisop $chan]} {
     puthelp "NOTICE $nick :Error I don't have OP!"
     } elseif {$bnick == ""} {
     puthelp "NOTICE $nick :SYNTAX\002 .b <nick|*!*@host> \[reason\] \002"
     } elseif {![onchan $bnick]} {
     puthelp "NOTICE $nick :Error\002 $bnick \002is not on\002 $chan \002Check\002 .b \002"
     } else {
     set bhost "*!*@[lindex [split $uhost @] 1]"
     set bres [lindex $text 1 end]
     } else { set bres $dj(br)
        newchanban $chan $bhost ban ($hand) $bres $dj(bt)
        putquick "KICK $chan $bnick :($hand) $bres"
        if {$dj(xb) == 1} {
        putserv "PRIVMSG X :ban $chan $bhost 1 100 ($hand) $bres" -next
        }
       return 1
      }
    }
  }
}


And the errors:

Quote:
<me> .b
-|EGG- SYNTAX .b <nick|*!*@host> [reason]
<me> .b lol
-|EGG- Error lol is not on #channel Check .b
<me> .b test1
* |EGG sets mode: -o+b me *!*@me.users.undernet.org
* test1 was kicked by |EGG ((me) )
* Joins: test1 (identd@127.0.0.0)
* You were kicked by X ((egguser) (me))
* Attempting to rejoin channel #channel
* Unable to join channel (address is banned)
-> *x* unban #channel *!*@me.users.undernet.org
-X- Removed 2 pitchforks that matched *!*@me.users.undernet.org
* Rejoined channel #channel


.... it only kick the nickname I`ve typed, and the chanban and Xban is placed on me.... why ?! Confused Sad

This is the way it should have to work:

Quote:
<me> .b
-|EGG- SYNTAX .b <nick|*!*@host> [reason]
<me> .b lol
-|EGG- Error lol is not on #channel Check .b
<me> .b test1 test-reason
* |EGG sets mode: +b *!*@127.0.0.0
* test1 was kicked by |EGG ((me) test-reason)


and if there is no reason added, the bot will use the defaul reason (in this case $dj(br) )

something like this

Quote:
<me> .b test2
* |EGG sets mode: +b *!*@127.0.0.1
* test2 was kicked by |EGG ((me) Banned!)

_________________
I am a man of few words, but many riddles


Last edited by Riddler on Sat Nov 28, 2009 8:10 pm; edited 4 times in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Mon Jun 11, 2007 9:21 am    Post subject: Reply with quote

The problem is here:
Code:
set bhost "*!*@[lindex [split $uhost @] 1]"

$uhost is the user@host of the command issuer (i.e. you), instead use
Code:
set bhost "*!*@[lindex [split [getchanhost $bnick] @] 1]"

and, as we've repeated ourselves on and on, you must NOT apply [list] commands on strings.
Code:
set bnick [lindex $text 0]

should be
Code:
set bnick [lindex [split $text] 0]

and
Code:
set bres [lindex $text 1 end]

should be
Code:
set bres [join [lindex [split $text] 1 end]]

_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
Riddler
Halfop


Joined: 20 May 2007
Posts: 60
Location: Brasov, Romania

PostPosted: Mon Jun 11, 2007 11:05 am    Post subject: Reply with quote

Thank Sir_Fz...
Ok the code with the changes:

Code:
proc s:b {nick uhost hand chan text} {
  global botnick dj
   if {[channel get $chan djtools] && ![isbotnick $nick]} {
   if {[matchattr $hand n|MASDTO $chan] || [string tolower $chan]} {
     set bnick [lindex [split $text] 0]
     set bhost "*!*@[lindex [split [getchanhost $bnick] @] 1]"
        if {![botisop $chan]} {
        puthelp "NOTICE $nick :Error I don't have OP!"
        } elseif {$bnick == ""} {
        puthelp "NOTICE $nick :SYNTAX\002 .b <nick|*!*@host> \[reason\] \002"
        } elseif {[join [lindex [split $text] 1 end]] == ""} {
        newchanban $chan $bhost ban ($hand) $dj(br) $dj(bt)
        putquick "KICK $chan $bnick :($hand) $dj(br)"
        if {$dj(xb) == 1} {
        putserv "PRIVMSG X :ban $chan $bhost 1 100 ($hand) $dj(br)" -next
        }
        return 1
        } else {
        set bres [join [lrange [split $text] 1 end]]
        newchanban $chan $bhost ban ($hand) $bres $dj(bt)
        putquick "KICK $chan $bnick :($hand) $bres"
        if {$dj(xb) == 1} {
        putserv "PRIVMSG X :ban $chan $bhost 1 100 ($hand) $bres" -next
        }
       return 1
      }
    }
  }
}


and I have this error in dcc-chat with the bot:

Quote:
<|EGG> [16:48] Tcl error [s:b]: invalid option 1440 (must be one of: sticky, none)

...the bot dosen`t do nothing... Sad


also a nother error...

Code:
<me> .b *test*!*@* lol


and also here the bot will NOT reply..
Confused
Idea Question Exclamation

P.S.1: When i place a nickname , like .b Test-nick1 lol , the bot reacts and bans the Test-nick1...but on a hostmask... no react...
P.S.2: Also it bans users who have access to the bot and they are op/voice on the specific channel.... Crying or Very sad ...and it dosen`t have to do that.
_________________
I am a man of few words, but many riddles
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Mon Jun 11, 2007 12:44 pm    Post subject: Reply with quote

Riddler wrote:

Quote:
<|EGG> [16:48] Tcl error [s:b]: invalid option 1440 (must be one of: sticky, none)

...the bot dosen`t do nothing... Sad

That means you're using an invalid switch with the newchanban command.
Riddler wrote:

also a nother error...

Code:
<me> .b *test*!*@* lol


and also here the bot will NOT reply..
Confused
Idea Question Exclamation

P.S.1: When i place a nickname , like .b Test-nick1 lol , the bot reacts and bans the Test-nick1...but on a hostmask... no react...
P.S.2: Also it bans users who have access to the bot and they are op/voice on the specific channel.... Crying or Very sad ...and it dosen`t have to do that.

The bot doesn't figure things out by itself, you have to script it. In your code, you do not check whether bnick is a hostmask or a nick, you always assume it's a nick. So you might want to check if it's a hostmask (something like if {[string match *!*@* $bnick]} {) And to exempt +of users you also need to add a check (i.e. use the [matchattr] command).
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
Riddler
Halfop


Joined: 20 May 2007
Posts: 60
Location: Brasov, Romania

PostPosted: Mon Jun 11, 2007 1:09 pm    Post subject: Reply with quote

Sir_Fz wrote:
Riddler wrote:

Quote:
<|EGG> [16:48] Tcl error [s:b]: invalid option 1440 (must be one of: sticky, none)

...the bot dosen`t do nothing... Sad

That means you're using an invalid switch with the newchanban command.


Ok, I understand this, but if I change the newchanban command to this

Code:
newchanban $chan $bhost ban $dj(br) $dj(bt)


it works, the person gets ban on the channel like this

Quote:
<me> .b TestNick1
* |EGG sets mode: +b *!*@127.0.0.1
* TestNick1 was kicked by |EGG ((test) Banned!)


all is ok, but if I remove the chan ban manualy when the person rejoins the channel ...he gets ban again ( using the internal banlist of the bot ) but the reason has change...

Quote:
* me sets mode: -b *!*@127.0.0.1
* Joins: TestNick1 (identd@127.0.0.1)
* |EGG sets mode: +b *!*@127.0.0.1
* TestNick1 was kicked by |EGG (Banned: Banned!)


.... in the internal banlist of the bot for this specific ban ... the ($hand) is not recorded ( in this case (test) )...

How can I fit the ($hand) code in the reason and make the newchanban command work also ?
To look something like this:

Quote:
* me sets mode: -b *!*@127.0.0.1
* Joins: TestNick1 (identd@127.0.0.1)
* |EGG sets mode: +b *!*@127.0.0.1
* TestNick1 was kicked by |EGG (Banned: (test) Banned!)


....
_________________
I am a man of few words, but many riddles
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Mon Jun 11, 2007 6:20 pm    Post subject: Reply with quote

Change the reason to something like "($hand) $dj(br)" instead of just $dj(br) in the newchanban reason.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
Riddler
Halfop


Joined: 20 May 2007
Posts: 60
Location: Brasov, Romania

PostPosted: Mon Jun 11, 2007 6:51 pm    Post subject: Reply with quote

Ok, done, fixed the bug, it works...thanks Sir_Fz Cool (again Very Happy )

A little problem remains... and that is were/how do you I put the excepts code for ops,voiced and users that have access to the bot ( by the level n|MASDTOV ) so that they don`t get ban by the bot ...
On other scripts ( protection type of scripts ) I use this code for excepting ops, voices and users in the access list of the bot:

Code:
if {[matchattr $hand of|of $chan] || [isop $nick $chan] || [isvoice $nick $chan]}  { return 0 }
if {(([lsearch -exact [string tolower $webadvchan] [string tolower $chan]] != -1) || ($webadvchan == "*")) && (![matchattr $hand b]) && ($nick != $botnick)} {


it works great on those scripts.. but were do I set it in this case ... ?! Question Exclamation Shocked

suggestions ?!
_________________
I am a man of few words, but many riddles
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Mon Jun 11, 2007 6:56 pm    Post subject: Reply with quote

Use [nick2hand $bnick] to get the handle of $bnick (read about it in tcl-commands.doc).
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
Riddler
Halfop


Joined: 20 May 2007
Posts: 60
Location: Brasov, Romania

PostPosted: Mon Jun 11, 2007 9:05 pm    Post subject: Reply with quote

Sir_Fz wrote:
Use [nick2hand $bnick] to get the handle of $bnick (read about it in tcl-commands.doc).


Ok ...let`s see if this idea will work...

Code:
set drhost [nick2hand $drnick]
if {![matchattr $drhost n|MASDTOVU $chan] || [isop $drnick $chan] || [isvoice $drnick $chan] || ![matchattr $drhost b]} {

_________________
I am a man of few words, but many riddles
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Tue Jun 12, 2007 4:59 am    Post subject: Reply with quote

Code:
if {[matchattr $drhost n|MASDTOVU $chan] || [isop $drnick $chan] || [isvoice $drnick $chan] || [matchattr $drhost b]} {
 # do nothing
 return 0
}

or
Code:
if {![matchattr $drhost n|MASDTOVU $chan] && ![isop $drnick $chan] && ![isvoice $drnick $chan] && ![matchattr $drhost b]} {
 # do everything here
}

_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
Riddler
Halfop


Joined: 20 May 2007
Posts: 60
Location: Brasov, Romania

PostPosted: Thu Jun 14, 2007 10:26 pm    Post subject: Reply with quote

Thanks Sir_Fz Very Happy Cool The script works great now Razz
_________________
I am a man of few words, but many riddles
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help 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