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.

Help with Command

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

nml375 wrote:Splitting a second time?
I think you are abit confused 'bout splitting...
Split converts a string to a list, $t is a string since it originates from the binding. Hence it should (must) be splitted prior being used with any commands expecting a list as a parameter. Using your code with a "reason" such as "evil user typing {" would illustrate how your script was broken, and how split is necessary.

A bad habit, in my opinion, is not bothering to keep track whether the content of a variable is a string or a list (always considder user input to be a string, never a list).
you seem a bit confused about how lrange works
[lrange $x 0 end] may be used to force x to have list (as opposed to string) representation - this enhances performance in some situations.
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

DragnLord wrote:
nml375 wrote:Splitting a second time?
I think you are abit confused 'bout splitting...
Split converts a string to a list, $t is a string since it originates from the binding. Hence it should (must) be splitted prior being used with any commands expecting a list as a parameter. Using your code with a "reason" such as "evil user typing {" would illustrate how your script was broken, and how split is necessary.

A bad habit, in my opinion, is not bothering to keep track whether the content of a variable is a string or a list (always considder user input to be a string, never a list).
you seem a bit confused about how lrange works
[lrange $x 0 end] may be used to force x to have list (as opposed to string) representation - this enhances performance in some situations.
NAME
lrange - Return one or more adjacent elements from a list
SYNOPSIS
lrange list first last
DESCRIPTION
List must be a valid Tcl list. This command will return a new list consisting of elements first through last, inclusive. First or last may be end (or any abbreviation of it) to refer to the last element of the list. If first is less than zero, it is treated as if it were zero. If last is greater than or equal to the number of elements in the list, then it is treated as if it were end. If first is greater than last then an empty string is returned. Note: ``lrange list first first'' does not always produce the same result as ``lindex list first'' (although it often does for simple fields that aren't enclosed in braces); it does, however, produce exactly the same results as ``list [lindex list first]''
just so we are clear here, both lrange and lindex work with lists, and want to have lists given to them, hence they begin with l.

Now, the difference between a string and a list is what is at issue here more than the commands. Because sure, anyone can use list commands on strings and string commands on lists. The problem is this isn't natural to do, so unexpected problems always arise, and must be compensated for.

Keep in mind, lists use curly bracing to denote list elements and fields. Strings do not. So any time you mistakenly give a list command a string with any curly braces in it, expect dilemma. Instead use [split $string] (this will protect the curly braces within the string from being interpreted as list elements or fields).

Instead of being arrogant and refusing to see that while your way is faster (not needing to split, indeed you save clock cycles). You need to see that it introduces more work later, extraneous filters and work arounds...
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

DragnLord wrote:
nml375 wrote:Splitting a second time?
I think you are abit confused 'bout splitting...
Split converts a string to a list, $t is a string since it originates from the binding. Hence it should (must) be splitted prior being used with any commands expecting a list as a parameter. Using your code with a "reason" such as "evil user typing {" would illustrate how your script was broken, and how split is necessary.

A bad habit, in my opinion, is not bothering to keep track whether the content of a variable is a string or a list (always considder user input to be a string, never a list).
you seem a bit confused about how lrange works
[lrange $x 0 end] may be used to force x to have list (as opposed to string) representation - this enhances performance in some situations.
I considder myself quite well-versed when it comes to list operations, and would call the above a very ugly hack, that will only work with specially crafted strings. And even in this case, the output would be similar to split. split however, expects the input to be a string, and can handle any case, such as the one below:

Code: Select all

% set string "ad {dwer fva{ aer"
ad {dwer fva{ aer
% lrange $string 0 end
unmatched open brace in list
% lindex $string 2
unmatched open brace in list
% split $string
ad \{dwer fva\{ aer
%
NML_375
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

This has strayed far enough off topic.
As I have stated more then once in this topic already, coding before coffee is bad.
The entire idea behind this script is bad.
I never said the script was perfect, nothing ever is (or eggdrop and TCL would have both stopped at version 1.0).
I simply stated the script worked in my testing (at least I tested it).

While nicknames may contain braces (and/or other special characters), IP addresses may NOT contain those. And my script allows for using *@IP as a fall back target for nicknames with odd characters.

The "proper" answer to the original issue should be;
"If you trust your abuse team 100%, give them operator status that restricts them to banning commands (kline. gline, etc.). This can be done easily enough by creating a single oper and having the abuse team all use that single oper. Remember to carefully set exemptions."
C
CyberWar
Voice
Posts: 36
Joined: Mon Feb 04, 2008 4:49 am

Post by CyberWar »

Ok DragnLord

Well thank you to all here nice support now i know more about scripts and errors etc.

i will test it the script from DragnLord i think it works fine :wink:
C
CyberWar
Voice
Posts: 36
Joined: Mon Feb 04, 2008 4:49 am

Post by CyberWar »

Hi guys i have a script where works fine

One question when i make a gline i want that the bot write: Requested by $nick

this is my script

set eggver 1

Code: Select all

bind pub - !gline holm-pub_gline
proc holm-pub_gline {nick uhost hand chan text} {
  set bantime "360m"
  set knick [lindex $text 0]
  set reason [lrange $text 1 end]
  if ![matchattr $hand G|G $chan] {
  putserv "NOTICE $nick :Access Denied"
  return 0
  }
  if {$knick == ""} {
		     putserv "notice $nick :Usage: !gline <nick> <reason>"
		     return 0
  } else {
          putserv "gline $knick $bantime :$reason ([strftime %d-%m-%Y/%H:%M:%S])"
          return 0
  if {$reason == ""} {
		     putserv "PRIVMSG $chan :Requested by $nick"
	}
  }
 }
Look at the line: putserv "PRIVMSG $chan :Requested by $nick"
whats wrong?

i want the follow result e.g.
[ ° ] Quits: root ( root@ps-C2EA4D2A.server4you.de ) has left irc [ User has been banned from blanet (test (14-03-2008/20:23:09)) ]

« Area51 » Requested by $nick
the Bot write atm nothing about: Requested by $nick
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

Hopefully this is what your after:

Code: Select all

bind pub G|G !gline pub:gline

proc pub:gline {nick host hand chan text} {
    global lastbind
    if {[set who [lindex [split $text] 0]] == ""} {
        putserv "NOTICE $nick :Syntax: $lastbind <nick|host> ?bantime? ?reason?."
    } else {
        if {![regexp {[\d]{1,}(m|h|d|w|y)} [lindex [split $text] 1]]} {
            set bantime "360m"
        }
        if {[set reason [lrange $text [expr {[regexp {[\d]{1,}(m|h|d|w|y)} [lindex [split $text] 1]] ? "2" : "1"}] end]]} {
            set reason "Requested by $nick"
        }
        set time [strftime %d-%m-%Y/%H:%M:%S]
        putquick "GLINE $who $bantime :$reason ($time)"
        putserv "PRIVMSG $chan :Requested by $nick"
    }
}
r0t3n @ #r0t3n @ Quakenet
C
CyberWar
Voice
Posts: 36
Joined: Mon Feb 04, 2008 4:49 am

Post by CyberWar »

This script does not work. My script version works fine, but he dont make a msg to the channel when i make a gline. i want that my script make a msg to the channel when i maked a gline.

e.g.: BotNick: Requested by $nick
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

You want the message to go to the channel that the script is called from, or do you want the message to go to a specific channel regardless of where it's called from?
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

I think this script will do what you want. If it doesn't, let me know.
Post Reply