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.

DCC ban proc need help...desperate newbie

Old posts that have not been replied to for several years.
Locked
S
Shoshana
Voice
Posts: 7
Joined: Sun Dec 05, 2004 6:01 am

DCC ban proc need help...desperate newbie

Post by Shoshana »

Why do all newbies say this, "I am a newbie"? Well, I am. I have the following proc.

When I do .tempban <nick> it works and will not ban ops/op'd bots.
When I do .tempban <ident@host> or any part, it bans Ops which I don't want it to do.
I can see it needs to check the victim mask against flags but I don't know how to do it.
I have read almost every related post on this site. I've also looked at some 10-20 other scripts for clues, tried this and that and every time I change something, I get that there is no value for a variable, or no variable, no command or whatever. Seached most if not all of the other eggdrop/tcl sites and I am just plain stuck. I don't know enough.

The other thing is that I would prefer it bans *!*ident@*.host something like that.
set tempbantime 10
bind dcc V|V tempban temp_ban

### .TEMPBAN <nick|mask> [reason]

proc temp_ban { handle idx victim } {
global tempbantime
set channel [lindex [console $idx] 0]
set victim "$victim "
if {[matchattr [strlwr $victim] o|o $channel]} {
putdcc $idx "\002You cannot ban Ops or Bots!\002"
return 0
}
set mask "[string range $victim 0 [expr [string first " " $victim] -1]]"
set reason "[string trimleft $victim $mask]"
if { $mask == "" } {
putdcc $idx ".tempban - bans a users <nick|mask> for $tempbantime minutes"
putdcc $idx "How to use it: .tempban <nick|mask> <reason> <time>"
return 0
}
newban $mask "$reason" $tempbantime
}
The bot is 1.6.4 on Dalnet. Any and all help would be appreciated so much, I couldn' tell you in words. I am exhausted after 4 days of trying to make this work.
If electricity comes from electrons, does morailty come from morons?
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

you check given hostmask against the userlist using [finduser], for example:

Code: Select all

if [matchattr [finduser $nick!$user@$host] of|of $chan] {
# there is a user with that hostmask who is global/channel op or friend
} else {
# no match
}
use [maskhost] to get the ban in the form you want:

Code: Select all

newchanban $chan [maskhost $nick!$user@$host] $creator $reason
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

also, use this to split nick|mask from the reason:

Code: Select all

proc tempban {hand idx text} {
  set victim [lindex [split $text] 0]
  set reason [join [lrange [split $text] 1 end]]
  ...
S
Shoshana
Voice
Posts: 7
Joined: Sun Dec 05, 2004 6:01 am

Post by Shoshana »

Thank you for answering. Maybe there is a basic something I don't understand about all of this.
if [matchattr [finduser $nick!$user@$host] of|of $chan] {
How would this check the victim's mask for Op flags?

Something else I need to learn. Whenever I use any other variable than what I originally posted, I get "no value given for parameter". I put the variable, lets say, 'user' with the other variables, { handle idx victim user } and I thought that $user is the value. I guess not? So, how do I add variables and 'define' their value. This seems to be different with DCC procs.

I have read so many docs and sites and nothing helps me understand this.
Thanks again.
If electricity comes from electrons, does morailty come from morons?
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Shoshana wrote:How would this check the victim's mask for Op flags?
In the Command Console type ".help whois" and you'll get a full list of all flags used by the bot and also see that o is the Op flag.
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
S
Shoshana
Voice
Posts: 7
Joined: Sun Dec 05, 2004 6:01 am

Post by Shoshana »

Ok, right.

Now, when I added the variable 'user'
if [matchattr [finduser $nick!$user@$host] of|of $chan] {


to my proc, I got "can't read "user": no such variable".

How do I add the $user variable and define its value in my proc?
If electricity comes from electrons, does morailty come from morons?
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

in my example, $user is the IRC username

in your case, you need to check whether the argument supplied is nick or hostmask and if it's a nick, to append its corresponding channel user@host, using [getchanhost]:

Code: Select all

proc tempban {hand idx text} { 
  set victim [lindex [split $text] 0] 
  set reason [join [lrange [split $text] 1 end]] 
  if ![string match *!*@* $victim] {
    if ![onchan $victim] return ;# not on channel, nothing to do
    append victim ![getchanhost $victim]
  }
  if ![matchattr [finduser $victim] of|of] {
  # not an op or friend, proceed with ban...

  }
}
S
Shoshana
Voice
Posts: 7
Joined: Sun Dec 05, 2004 6:01 am

its starting to make sense

Post by Shoshana »

What you showed is starting to make sense to me but after
if ![matchattr [finduser $victim] of|of] }
whatever I put after to make the ban,

if ![matchattr [finduser $victim] of|of] } {
newban $victim $hand "Banned: $reason" $tempbantime
return 1
}
}

I get "Tcl error [temp_ban]: invalid command name "temp_ban"" now. So, I am still not understanding or doing it right, am I?

Also, do I need to set the mask to be banned? I really appreciate this help, sincerely. I think if I see the whole thing, I will understand the parts as a whole better.
If electricity comes from electrons, does morailty come from morons?
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

well, here you go:

Code: Select all

bind dcc o|o tempban temp_ban
proc temp_ban {hand idx text} {
  set chan [lindex [console $idx] 0]
  set victim [lindex [split $text] 0] 
  set reason [join [lrange [split $text] 1 end]] 
  if {$victim == "" || $reason == ""} {
    putdcc $idx "usage: .$::lastbind <nick|hostmask> <reason>"
    return
  }
  if {![botonchan $chan] || ![botisop $chan]} return
  if ![matchattr $hand o|o $chan] return  ;#not +o for that channel
  if ![string match *!*@* $victim] {         ;# nick specified
    if ![onchan $victim $chan] return        ;# not on channel, nothing to do 
    append victim ![getchanhost $victim]  ;# construct the hostmask
  } 
  if ![matchattr [finduser $victim] of|of $chan] {  ;# victim not +o or +f
    newchanban $chan [maskhost $victim] script $reason
    foreach nick [chanlist $chan -of&-of] {
      if [string match $victim $nick![getchanhost $nick]] {
        append kicklist $nick ,
      } 
    }
    if [info exists kicklist] {
      putkick $chan $kicklist $reason
    }
    return 1
  } 
} 
S
Shoshana
Voice
Posts: 7
Joined: Sun Dec 05, 2004 6:01 am

Post by Shoshana »

Again, thank you demond. After reading a few times, almost 75% makes sense to me now and that is a big help no matter what. I did try it and it doesn't get past usage: <nick|hostmask> <reason>.

No matter what I enter after the command, I get the idx message. It gets stuck there.
If electricity comes from electrons, does morailty come from morons?
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

Code: Select all

bind dcc o|o tempban temp_ban 
proc temp_ban {hand idx text} { 
  set chan [lindex [split $text] 0] 
  set victim [lindex [split $text] 1] 
  set reason [join [lrange [split $text] 2 end]] 
  if {$victim == "" || $reason == ""} { 
    putdcc $idx "usage: .$::lastbind <nick|hostmask> <reason>" 
    return 
  } 
  if {![botonchan $chan] || ![botisop $chan]} return 
  if ![matchattr $hand o|o $chan] return  ;#not +o for that channel 
  if ![string match *!*@* $victim] {         ;# nick specified 
    if ![onchan $victim $chan] return        ;# not on channel, nothing to do 
    append victim ![getchanhost $victim]  ;# construct the hostmask 
  } 
  if ![matchattr [finduser $victim] of|of $chan] {  ;# victim not +o or +f 
    newchanban $chan [maskhost $victim] script $reason 
    foreach nick [chanlist $chan -of&-of] { 
      if [string match $victim $nick![getchanhost $nick]] { 
        append kicklist $nick , 
      } 
    } 
    if [info exists kicklist] { 
      putkick $chan $kicklist $reason 
    } 
    return 1 
  } 
} 
I just edited the variable but it should work like

.tempban <channel> <nick|host> <reason>
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

Shoshana wrote:Again, thank you demond. After reading a few times, almost 75% makes sense to me now and that is a big help no matter what. I did try it and it doesn't get past usage: <nick|hostmask> <reason>.

No matter what I enter after the command, I get the idx message. It gets stuck there.
it works on my bot as intended
S
Shoshana
Voice
Posts: 7
Joined: Sun Dec 05, 2004 6:01 am

Less stuck....

Post by Shoshana »

Again, thanks to all three of you!!!!!!

It still gets hung up for me on my bot. At least no bot crashes and it sends the idx message. But it keeps doing that for whatever I enter. I know I set it exactly as you coded it.

But MOST IMPORTANT.... I learned a lot from you guys and actually applied some to another tcl and that one WERKS! So, from here on, I need to play with this and add the missing (maybe bot version specific, maybe something else) ingredient that will get me past that stuck place. And, I will. :) I'll keep you posted in a few days.

Thank you for your precious skill and mostly, your patience with me.
If electricity comes from electrons, does morailty come from morons?
S
Shoshana
Voice
Posts: 7
Joined: Sun Dec 05, 2004 6:01 am

Less stuck....

Post by Shoshana »

Again, thanks to all three of you!!!!!!

It still gets hung up for me on my bot. At least no bot crashes and it sends the idx message. But it keeps doing that for whatever I enter. I know I set it exactly as you coded it.

But MOST IMPORTANT.... I learned a lot from you guys and actually applied some to another tcl and that one WERKS! So, from here on, I need to play with this and add the missing (maybe bot version specific, maybe something else) ingredient that will get me past that stuck place. And, I will. :) I'll keep you posted in a few days.

Thank you for your precious skill and mostly, your patience with me. And thanks for taking the time to code it and even test it. You guys are totally, the nicest I've found on many forums.
If electricity comes from electrons, does morailty come from morons?
Locked