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.

need help with ident ban tcl

Old posts that have not been replied to for several years.
E
EEggy
Op
Posts: 122
Joined: Thu Sep 26, 2002 11:46 pm

need help with ident ban tcl

Post by EEggy »

Hi all,

Can someone please help me to write an identban tcl, i am new in tcl
i am looking an identbabn.tcl for public and partyline both, if i type at main channel .identban nick reason (if no reason then default reason), and it should work in partyline too... please help

thank you
EEggy
EEggy
P
Photon
Op
Posts: 170
Joined: Wed Aug 28, 2002 8:00 am
Location: Liverpool, England

Post by Photon »

A good place to start may well be lols toolz (see tcl libarary on this site)

This is a complete channel management script with public triggers. If you dont want to use this script, then its a good place to look for examples.
E
EEggy
Op
Posts: 122
Joined: Thu Sep 26, 2002 11:46 pm

Post by EEggy »

thank photon, but i want it to use public and dcc, still no luck :(

thanks
EEggy
d
darko``
Op
Posts: 121
Joined: Sun Sep 08, 2002 5:33 pm
Location: Malta

Post by darko`` »

You said:
Can someone please help me to write an identban tcl, i am new in tcl
and not: Can someone do all the work for me and email it back. So heat that chair a bit, write a few lines, and post a specific question regarding a certain part of code that you wrote. Otherwise, noone can help you, except to write it for you.
Ignorant and lazy people will save 30 minutes by chosing simple config file. Smart ones will save 3000 minutes of *everyone's* time by opting for complete config file.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

don't be so lazy, just show that you are tryng to solve your problem and someone will come with an sugestion, one.. to .. or more. just try your best :)
E
EEggy
Op
Posts: 122
Joined: Thu Sep 26, 2002 11:46 pm

Post by EEggy »

sorry guys, i am very new in tcl, but i was reading tcl-commands document and was checking some other kickban scripts and i have tried my best, but it doesn't work at all, and no errors as well, please help me.
here are my codes.
Thanks again.


proc p_identban {nick uhost hand chan arg} {

set chan [string tolower $chan]
if {![isop $nick $chan] || ![botisop $chan]} {return 0}

set target [string tolower [lindex $arg 0]]
if {$target == ""} {
puthelp "NOTICE $nick :try .ib nick reason"
return 0
}

if {[lindex $arg 1] != ""} {
set reason [lrange $arg 1 end]
} else {
set reason "bad ident..."
}
set uhost [getchanhost $target $chan]
set uident [string trimleft [lindex [split $uhost "@"] 0]]
putserv "MODE $chan +b *!$uident@*"
putserv "KICK $chan $target :$reason"
newchanban $chan *!$uident@* $reason 60

}
bind pub o|o .ib p_identban

proc dcc_identban {handle idx arg} {
set chan [lindex [console $idx] 0]
set nick [hand2nick $handle]
set host [getchanhost $nick]
return [p_identban $nick $uhost $hand $chan $arg]
}
bind dcc o|o .ib dcc_identban
EEggy
E
EEggy
Op
Posts: 122
Joined: Thu Sep 26, 2002 11:46 pm

Post by EEggy »

Hi, i will appreciate if someone can help me with this script

thanks
EEggy
E
EEggy
Op
Posts: 122
Joined: Thu Sep 26, 2002 11:46 pm

Post by EEggy »

Hi again,

hmm i think no one likes to help me :( , when i didn't have codes, i got 3 replies that try it, when i have tried and spent 4,5 hours and posted here now no one likes to help, heh so its ok i guess, since i am new and trying to learn..
thanks everyone
EEggy
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

Hi EEggy, your attempt was quite good. Below you will find some minor comments, questions and putlogs in your tcl.

What I got when typing ".ib hello" (hello being a nick NOT on the channel):
[17:56] #egghead: mode change '+b *!*@*' by Eggheadsbot!egghead@eggheadsip
[17:56] Uh, banned myself on #egghead, reversing...
You need to include a check if the nick you are trying to ban is on the channel :)

Code: Select all

proc p_identban {nick uhost hand chan arg} { 

   # why?
   set chan [string tolower $chan] 

   # why testing if the bot is op or not?
   # if the bot is not op, it is still capable of adding newchanbans
   # to its ban list. Once the bot gets opped, it can enforce those bans :)

   if {![isop $nick $chan] || ![botisop $chan]} {return 0} 

   # "arg" is a string, lindex is a list function. 
   # Use split first, or use a scan.
   # Also see the TCL FAQ on this forum.
   # why the string tolower?

   set target [string tolower [lindex $arg 0]] 

   putlog "ARG: $arg"
   putlog "TARGET: $target"

   if {$target == ""} { 
      puthelp "NOTICE $nick :try .ib nick reason" 
      return 0 
   } 

   # again, arg is a string, lindex is a list function.
   # not good.

   if {[lindex $arg 1] != ""} { 
      # and again: arg is a string, lrange a list function. not good.
      set reason [lrange $arg 1 end] 
   } else { 
      set reason "bad ident..." 
   } 

   # why not check if the target is on the channel?!
   # this may lead to bans like *!*@*
   # Insert this check here.

   # Note that the use of "uhost" is extremely confusing.
   # This procedure is also called with "uhost"!
   # Use another name.

   set uhost [getchanhost $target $chan] 
   putlog "UHOST: $uhost"

   # why trimming the string on the left?
   set uident [string trimleft [lindex [split $uhost "@"] 0]] 
   putlog "UIDENT: $uident"

   # why sending a ban, a kick and setting a newchanban?
   # only setting a newchanban and having the correct settings
   # will make eggdrop send out the kick and ban by itself.

   putserv "MODE $chan +b *!$uident@*" 
   putserv "KICK $chan $target :$reason" 

   # read up tcl-commands.doc on the syntax for newchanban.
   # not good.
   newchanban $chan *!$uident@* $reason 60 

   # Since previously all returns were explicit, nothing to 
   # return here? Returning "1" logs the command. 

} 

bind pub o|o .ib p_identban 

proc dcc_identban {handle idx arg} { 
   set chan [lindex [console $idx] 0]

   # use hand2nick like this? 
   # huh? not good! read tcl-commands.doc!
   # Note that a partyline user may not be on IRC at all!
   # This will make the test "isop" in the proc p_identban fail!
   # as well as the puthelps to the nick
   set nick [hand2nick $handle] 

   # subsequently not good!
   set host [getchanhost $nick] 

   # What does "p_identban" return if all works well?
   return [p_identban $nick $uhost $hand $chan $arg] 
} 

bind dcc o|o .ib dcc_identban
E
EEggy
Op
Posts: 122
Joined: Thu Sep 26, 2002 11:46 pm

Post by EEggy »

Thanks Egghead, i have tried as u have suggested... but still no luck at all, even tried putlog display stuff..but no luck..don't know what's wrong with codes, spend a lot of time..
here are the latest codes, i'll appreciate for your help
Thanks a lot

bind dcc o|o .ib dcc_identban
bind pub o|o .ib p_identban

proc p_identban {nick uhost hand chan arg} {

if {![isop $nick $chan]} {return 0}
set target [lindex [split $arg] 0]

if {$target == ""} {
puthelp "NOTICE $nick :Try .ib nick reason."
return 0
}

if {[lindex [split $arg] 1] != ""} {
set reason [lrange [split $arg] 1 end]
} else {
set reason "bad ident..."
}
if {[onchan $target $chan]} {
set host [getchanhost $target $chan]
set ident [string trimleft [lindex [split $host "@"] 0] "~"]
newchanban $chan *!*$ident@* $::botnick $reason 60
return 1
}
}

proc dcc_identban {hand idx arg} {
if {![isop $nick $chan]} {return 0}
set target [lindex [split $arg] 0]
if {$target == ""} {
putdcc $idx "Try .ib nick reason."
return 0
}
if {[lindex [split $arg] 1] != ""} {
set reason [lrange [split $arg] 1 end]
} else {
set reason "bad ident..."
}
if {[onchan $target $chan]} {
set host [getchanhost $target $chan]
set ident [string trimleft [lindex [split $host "@"] 0] "~"]
newchanban $chan *!*$ident@* $::botnick $reason 60
return 1
}
}
EEggy
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

EEggy wrote: [snip]... but still no luck at all ...[snip]
Perhaps you can tell step by step what you try and what fails? Did you issue an ".ib" from the partyline and did that fail, or did you issue it from the chanel and did it fail? Are the bindings at least triggered?

Look for example at this piece:

Code: Select all

proc dcc_identban {hand idx arg} { 
  if {![isop $nick $chan]} {return 0}
First of all, only "hand", "idx" and "arg" are passed to this proc. Where do "nick" and "chan" come from? And once again, a partyline user is not necessarily on the channel. There is no reason to put a test like [isop] in there.

Additionally, there is no point of including a point in the DCC binding command .ib :)
E
EEggy
Op
Posts: 122
Joined: Thu Sep 26, 2002 11:46 pm

Post by EEggy »

Thanks again Egghead, yes i have tried in the partyline and at channel, in partyline when i tried .ib nick it says what? you need help...
when i tried at channel, .ib nick , no respond at all, then i used putlog....to debug..but nothing....bindings didn't trigger at all, even i have restarted a bot few times as well....i am using eggdrop1.6.12, and other scripts are working fine.
Thanks
regards

bind dcc o|o ib dcc_identban
bind pub o|o .ib p_identban

proc p_identban {nick uhost hand chan arg} {

if {![isop $nick $chan]} {return 0}
set target [lindex [split $arg] 0]

if {$target == ""} {
puthelp "NOTICE $nick :Try .ib nick reason."
return 0
}

if {[lindex [split $arg] 1] != ""} {
set reason [lrange [split $arg] 1 end]
} else {
set reason "bad ident..."
}
if {[onchan $target $chan]} {
set host [getchanhost $target $chan]
set ident [string trimleft [lindex [split $host "@"] 0] "~"]
newchanban $chan *!*$ident@* $::botnick $reason 60
return 1
}
}

proc dcc_identban {hand idx arg} {
set target [lindex [split $arg] 0]
if {$target == ""} {
putdcc $idx "Try .ib nick reason."
return 0
}
if {[lindex [split $arg] 1] != ""} {
set reason [lrange [split $arg] 1 end]
} else {
set reason "bad ident..."
}
if {[onchan $target $chan]} {
set host [getchanhost $target $chan]
set ident [string trimleft [lindex [split $host "@"] 0] "~"]
newchanban $chan *!*$ident@* $::botnick $reason 60
return 1
}
}
EEggy
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

EEggy wrote:Thanks again Egghead, yes i have tried in the partyline and at channel, in partyline when i tried .ib nick it says what? you need help...
when i tried at channel, .ib nick , no respond at all, then i used putlog....to debug..but nothing....bindings didn't trigger at all, even i have restarted a bot few times as well....i am using eggdrop1.6.12, and other scripts are working fine.
Do you have the o flag? (.help whois)
E
EEggy
Op
Posts: 122
Joined: Thu Sep 26, 2002 11:46 pm

Post by EEggy »

Hi, yes i have a +o flag, but i was using a diff ip to test it, with a diff ident

Thanks
EEggy
E
EEggy
Op
Posts: 122
Joined: Thu Sep 26, 2002 11:46 pm

Post by EEggy »

ok finally, this line was a killer -> if {![isop $nick $chan]} {return 0}
should be -> if {[isop $nick $chan]} {return 0}

thanks
EEggy
Locked