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
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

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

thanks
Oww... I assumed that was your test that the one setting the .ib not only has the o flag inside the bot, but also has @ on the channel. Additionally you said the bindings were not triggered (?)
E
EEggy
Op
Posts: 122
Joined: Thu Sep 26, 2002 11:46 pm

Post by EEggy »

Egghead, thank you so much for your kind inputs, suggestions, questions and everything, i have learned a lot. oh yeah bindings were not triggered, but after fixing that line and after cleaning more codes, it worked fine.
just one more questions like you had mentioned
# 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]
so what should i use for dcc command, i mean best choice for these
set nick [hand2nick $handle] ??
set host [getchanhost $nick] ??


thanks again
EEggy
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

EEggy wrote:Egghead, thank you so much for your kind inputs, suggestions, questions and everything, i have learned a lot. oh yeah bindings were not triggered, but after fixing that line and after cleaning more codes, it worked fine.
just one more questions like you had mentioned
# 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]
so what should i use for dcc command
set nick [hand2nick $handle] ??
set host [getchanhost $nick] ??
This part was used in the procedure related to the command from the partyline (DCC). Why would you want to look up the nick and the host of someone on the partyline? Even for logging purposes you already know the handle.

It is even possible that the person on the partyline is not on IRC. He/she just joined through telnet or joined through normal DCC CHAT and left IRC but kept the partyline open.

So, these two variables are not needed and can be left out, because the one doing the .ib from the partyline is already known by its handle.

In the second code you pasted there is even no need for these two variables anymore.

Note that if you really want to reuse code, it is of course possible to write a mutually used proc that will do the bansetting. Both the public triggered proc and the proc triggered through the partyline, then can call this mutually used proc.
E
EEggy
Op
Posts: 122
Joined: Thu Sep 26, 2002 11:46 pm

Post by EEggy »

thanks Egghead, so if i like to use public n partyline, i can do something like this

proc p_identban {nick uhost hand chan arg} {
......
.....

}

proc dcc_identban {handle idx arg} {
here instead of
set nick [hand2nick $handle]
set host [getchanhost $nick] <- instead of these i should use the following

set target [lindex [split $arg] 0]
set host [getchanhost $target $chan]
set ident [string trimleft [lindex [split $host "@"] 0] "~"]

thanks again, and sorry for the pain
EEggy
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

EEggy wrote: proc dcc_identban {handle idx arg} {
here instead of
set nick [hand2nick $handle]
set host [getchanhost $nick] <- instead of these i should use the following

set target [lindex [split $arg] 0]
set host [getchanhost $target $chan]
set ident [string trimleft [lindex [split $host "@"] 0] "~"]
Yes, that's right. But right after extracting the channel and the target, include an [onchan $target $chan] 8)
E
EEggy
Op
Posts: 122
Joined: Thu Sep 26, 2002 11:46 pm

Post by EEggy »

Hi again, it was working fine, but don't know why this happening when i type -> .identban target in the partyline, its kicksbans ok except in a kick message its shows target nick for example
ebot sets mode: +b *!*badident@*
*** test was kicked by ebot (banned: Nov 02 test: bad ident...)
it suppose to show the person kicked like
*** test was kicked by ebot (banned: Nov 02 EEggy: bad ident...)

i will really appreciate for your help.
thanks
regards


proc p_identban {nick host hand chan arg} {
set target [lindex [split $arg] 0]
set date [clock format [clock seconds] -format "%b %d"]
if {[lindex [split $arg] 1] != ""} {
set reason "$date $nick: [lrange [split $arg] 1 end]"
} else {
set reason "$date $nick: bad ident..."
}

if {![onchan $target $chan]} {
puthelp "NOTICE $nick :$target is not on $chan."
return 0
}
set uhost [getchanhost $target $chan]
set ident [string trimleft [lindex [split $uhost "@"] 0] "~"]
newchanban $chan *!*$ident@* $::botnick $reason 120
return 1

}

bind pub o|o .identban p_identban

proc dcc_identban {hand idx arg} {
set chan [lindex [console $idx] 0]
set target [lindex [split $arg] 0]
set uhost [getchanhost $target $chan]
return [p_identban $target $uhost $hand $chan $arg]

}
bind dcc o|o identban dcc_identban
EEggy
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

EEggy wrote:Hi again, it was working fine, but don't know why this happening when i type -> .identban target in the partyline, its kicksbans ok except in a kick message its shows target nick for example
ebot sets mode: +b *!*badident@*
*** test was kicked by ebot (banned: Nov 02 test: bad ident...)
it suppose to show the person kicked like
*** test was kicked by ebot (banned: Nov 02 EEggy: bad ident...)

[snip]

proc dcc_identban {hand idx arg} {
set chan [lindex [console $idx] 0]
set target [lindex [split $arg] 0]
set uhost [getchanhost $target $chan]
return [p_identban $target $uhost $hand $chan $arg]

}
bind dcc o|o identban dcc_identban
You didn't type ".identban target" as you said, but you typed ".identban test" on the partyline.

Now, if you type ".identban test" on the partyline, what is "target" set to in the proc "proc dcc_identban {hand idx arg}"?

This argument $target is then handed over as the "nick" (!) argument to the procedure "proc p_identban {nick host hand chan arg}".

And in that proc, $nick is used in constructing the kick reason.
E
EEggy
Op
Posts: 122
Joined: Thu Sep 26, 2002 11:46 pm

Post by EEggy »

thanks egghead, yes i typed .identban test, sorry - is there anyway to fix it??

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

Post by EEggy »

so in proc p_identban {nick host hand chan arg}, should i chnage "nick" to "target"?

thanks
regards
EEggy
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

EEggy wrote:so in proc p_identban {nick host hand chan arg}, should i chnage "nick" to "target"?

thanks
regards
In "return [p_identban $target $uhost $hand $chan $arg]" you change $target to $hand.
E
EEggy
Op
Posts: 122
Joined: Thu Sep 26, 2002 11:46 pm

Post by EEggy »

Thanks again egghead..but $hand is alredy there...
return [p_identban $target $uhost $hand $chan $arg]

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

Post by EEggy »

In "return [p_identban $target $uhost $hand $chan $arg]" you change $target to $hand.

oh u mean in return procedure , i change $target to $hand, i did that, but same thing.

thanks
regards
EEggy
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

EEggy wrote:In "return [p_identban $target $uhost $hand $chan $arg]" you change $target to $hand.

oh u mean in return procedure , i change $target to $hand, i did that, but same thing.

thanks
regards
So did you:

1. locate the line [p_identban $target $uhost $hand $chan $arg]?

2. in that line, change $target to $hand?

3. restart the bot?

The script you present has some other odd things in it. In the procedure proc dcc_identban, you extract an uhost like: "set uhost [getchanhost $target $chan]". This uhost you then send to the procedure p_identban. Why do that?

The p_identban requires 5 arguments:
1. The nick typing ".identban"
2. The user@host of the nick typing the ".identban" (not of the one being banned).
3. The handle of the nick typing ".identban". There must be handle since the binding flags are "o|o"
4. The channel where nick typed ".identban". There must be a channel, since the binding is a PUB binding.
5. The text the nick typed after ".identban".

So, all arguments of the p_identban procedure pertain to the nick typing the command, and not to the target that is going to be banned.
Subsequently, when calling the p_identban procedure from the partyline, all the arguments you give with that call must pertain to the person typing .identban on the partyline. So, you'll have to come up with 5 arguments:

1. nick??? There is no nick, since the user typed it from the partyline. Either you see if that user is on one of the channels the bot is monitoring using [hand2nick], or you just use the handle.

2. host??? In principle it is possible to retrieve the host of the user typing it from the partyline, but it is not used. Either you retrieve it from the DCC information or you set it to something like $hand!$hand@*. Why did you set it to the uhost of the target?

3. handle. This one you have, since the DCC connection gives a handle.

4. channel. The channel you indeed can retrieve from the console information.

5. text?!? As the 5th argument you can indeed use the text the user typed in the partyline. The p_identban will retrieve the target and the banreason from it.

Code: Select all

proc dcc_identban {hand idx arg} { 
   set chan [lindex [console $idx] 0] 
   set uhost $hand!$hand@*
   return [p_identban $hand $uhost $hand $chan $arg] 
}
Now the weird part comes here. You call the procedure p_identban from the partyline. Anything you want to return to that user, MUST be returned to the $idx!
But instead, if something goes wrong you do: "puthelp "NOTICE $nick :$target is not on $chan." This assumes that the person using the partyline is also on irc, on the channel and using the same nick as his/her handle. In fact your return values are 0 and 1. So a user types an identban from the partyline and gets as a result a "0". ????

Another weird thing is, is that in the p_identban procedure, you first construct a reason using [date], [clock] etc.... and after that you are going to check if the victim is on the channel. Why first constructing the reason and then find out the $target is not on the channel?

Since your procedure is an identban, I can see a reason for setting a ban like "*!*$ident@". This is appearantly what you are after. But suppose your nuhost is like eeggy!eeggy@host.com. The only thing I have to do is come online as egghead!~y@eggheadshost.com, bug you a while and get a .identban egghead. The bot will set a ban like *!*y@*.

And, your script also doesnt test for who gets banned. The bot will happily set bans on itself, its owner, its master anyone when requested.
E
EEggy
Op
Posts: 122
Joined: Thu Sep 26, 2002 11:46 pm

Post by EEggy »

egghead:Thanks again for the detail reply, appreciate it

so i come up with these codes, but now i don't get any error, even restarted the bot, but no luck.... i put a check if person is "mnob"...
plus i have tried my best to follow your advise and your kind suggestions..., now i am checking target before reason...but don't know how to i check the last part u have suggested..
Since your procedure is an identban, I can see a reason for setting a ban like "*!*$ident@". This is appearantly what you are after. But suppose your nuhost is like eeggy!eeggy@host.com. The only thing I have to do is come online as egghead!~y@eggheadshost.com, bug you a while and get a .identban egghead. The bot will set a ban like *!*y@*.

And, your script also doesnt test for who gets banned. The bot will happily set bans on itself, its owner, its master anyone when requested
thank again, n sorry for being the pain
regards


proc p_identban {nick host hand chan arg} {
set target [lindex [split $arg] 0]

if {![onchan $target $chan]} {
puthelp "NOTICE $nick :$target is not on $chan."
return 0
}

if {[matchattr $hand mnob|mno $chan]} {
return 0
}

set date [clock format [clock seconds] -format "%b %d"]
if {[lindex [split $arg] 1] != ""} {
set reason "$date $nick: [lrange [split $arg] 1 end]"
} else {
set reason "$date $nick: bad ident."
}

set uhost [getchanhost $target $chan]
set ident [string trimleft [lindex [split $uhost "@"] 0] "~"]
newchanban $chan *!*$ident@* $::botnick $reason 120
return 1

}

bind pub o|o .ib p_identban

proc dcc_identban {hand idx arg} {
set chan [lindex [console $idx] 0]
set uhost $hand!$hand@*
return [p_identban $hand $uhost $hand $chan $arg]

}
bind dcc o|o ib dcc_identban
EEggy
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

Eeggy, it is a bit cumbersome to point out errors in your code. Additionally, the test you added on the flags, tests the flags of the user who typed the ".identban" and not of the $target.

I don't want to force you in any direction, but let me make a suggestion:

1. write 3 procedures.

2. The first and most important procedure is something like shown below. At the ..... locations you can invent the required code.

Code: Select all

proc identban { nick chan text } {
  
   # Split the text in a list ([split])
   .....
   # Originally there was a [scan] line here but many eggdrop 
   # scripters only use split/lindex/lrange stuff.
   # Determine the length of the list ([llength])
   # and put in variable "listcount"
   .....
   # no text given? (listcount == 0)
   ..... { return "No target given." }
   # get target from the list ([lindex])
   .....
   # target was given, target is on channel? ([onchan])
   ..... { return "$target is not on $chan" }
   # target is known and has flags? ([matchattr])
   set targethand [nick2hand $target $chan]
   if {.....} {
      return "Can't identban: $nick ($targethand) has good flags."
    }
   # target is on channel and has no flags, construct the reason
   if { $listcount == 1 } { 
      set reason "bad ident..."
   } else {
      set reason [lrange $textlist 1 end]
   }
   set date [clock format [clock seconds] -format "%b %d"] 
   set reason "$date $nick: $reason"
   # set the identban (?? copied from eeggy's code ??)
   set uhost [getchanhost $target $chan] 
   set ident [string trimleft [lindex [split $uhost "@"] 0] "~"] 
   newchanban $chan *!*$ident@* $::botnick $reason 120 
   # return succes
   return "Added identban on *!*$ident@* ($reason)"
}
3. The public proc is something like:

Code: Select all

bind pub o|o .identban pub_identban 

proc pub_identban {nick host hand chan text} { 
   puthelp "NOTICE $nick :[identban $nick $chan $text]"
   return 1 
} 
4. And the DCC proc is something like:

Code: Select all

bind dcc o|o identban dcc_identban

proc dcc_identban {hand idx text} { 
   # extract channel name 
   set chan [lindex [console $idx] 0] 
   putidx $idx [identban $hand $chan $text] 
   return 1 
} 
5. Of course you can also stick with your code. But do read, write and test for 2 days anything you can come up with. Use putlog statements to follow what is going on. Scream at your computer when your bot crashes. And if after 2 days, it still doesn't work, scream at this forum and post how far you got.
Locked