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.

[SOLVED] A little UserMRG.tcl script...

Help for those learning Tcl or writing their own scripts.
R
Riddler
Halfop
Posts: 60
Joined: Sun May 20, 2007 10:20 pm
Location: Brasov, Romania
Contact:

[SOLVED] A little UserMRG.tcl script...

Post by Riddler »

Hello all, I need some help with a little script I`m trying to make.... it's a UserMRG type a script, and I can`t get it to work. :(

Code: Select all

# Set here levels for accesses
set dj(l1) "Voice Access"
set dj(l2) "OP Access"
set dj(l3) "Test DJ Access"
set dj(l4) "DJ Access"
set dj(l5) "Senior DJ Access"
set dj(l6) "Administrator Access"
set dj(l7) "Manager Access"

bind pub n|MAS .adduser s:adduser
bind pub n|MAS .addacc s:addacc
bind pub n|MAS .delacc s:delacc
bind pub n|MAS .deluser s:deluser
bind pub n|MAS .chuser s:chuser

setudef flag djtools

proc s:adduser {nick uhost hand chan text} {
  global botnick dj
   if {(![channel get $chan djtools]) && ($nick != $botnick)} {
   if {$text == ""} {
     puthelp "NOTICE $nick :SYNTAX: .adduser <Xuser>"
     } elseif {![validuser $text]} {
     puthelp "NOTICE $nick :\002$text \002is allready added to the database"
     } else {
     adduser $text
     .+host $text *!*@$text.users.undernet.org
     puthelp "NOTICE $nick :Added new user\002 $text \002with host\002 *!*@$text.users.undernet.org \002"
    }
  }
}

proc s:addacc {nick uhost hand chan text} {
  global botnick dj
   if {(![channel get $chan djtools]) && ($nick != $botnick)} {
   if {$text == ""} {
     puthelp "NOTICE $nick :SYNTAX: .addacc <voice|op|test|dj|senior|admin|manager> <Xuser>"
     } elseif {$text == "voice"} {
     chattr $hand - $chan
     chattr $hand +loV $chan
     puthelp "NOTICE $nick :User\002 $hand \002added with $dj(l1) on $chan"
     } elseif {$text == "op"} {
     chattr $hand - $chan
     chattr $hand +loO $chan
     puthelp "NOTICE $nick :User\002 $hand \002added with $dj(l2) on $chan"
     } elseif {$text == "test"} {
     chattr $hand - $chan
     chattr $hand +loT $chan
     puthelp "NOTICE $nick :User\002 $hand \002added with $dj(l3) on $chan"
     } elseif {$text == "dj"} {
     chattr $hand - $chan
     chattr $hand +loD $chan
     puthelp "NOTICE $nick :User\002 $hand \002added with $dj(l4) on $chan"
     } elseif {$text == "senior"} {
     chattr $hand - $chan
     chattr $hand +loS $chan
     puthelp "NOTICE $nick :User\002 $hand \002added with $dj(l5) on $chan"
     } elseif {$text == "admin"} {
     chattr $hand - $chan
     chattr $hand +loA $chan
     puthelp "NOTICE $nick :User\002 $hand \002added with $dj(l6) on $chan"
     } elseif {$text == "manager"} {
     chattr $hand - $chan
     chattr $hand +loM $chan
     puthelp "NOTICE $nick :User\002 $hand \002added with $dj(l7) on $chan"
     }
   }
}

proc s:delacc {nick uhost hand chan text} {
  global botnick dj
   if {(![channel get $chan djtools]) && ($nick != $botnick)} {
   if {$text == ""} {
     puthelp "NOTICE $nick :SYNTAX: .delacc <Xuser>"
     } else {
     chattr $hand - $chan
     chattr $hand +lo $chan
     puthelp "NOTICE $nick :Deleted access for \002 $text \002 on $chan"
   }
}

proc s:deluser {nick uhost hand chan text} {
  global botnick dj
   if {(![channel get $chan djtools]) && ($nick != $botnick)} {
   if {$text == ""} {
     puthelp "NOTICE $nick :SYNTAX: .deluser <Xuser>"
     } elseif {![validuser $text]} {
     puthelp "NOTICE $nick :\002$text \002is not in the database. Use:\002 .userlist \002"
     } else {
     deluser $text 
     puthelp "NOTICE $nick :User\0002 $text \002has been deleted."
    }
  }
}

proc s:chuser {nick uhost hand chan text} {
  global botnick
   if {(![channel get $chan djtools]) && ($nick != $botnick)} {
     set n1 [lindex $text 0]
     set n1 [lindex $text 1]
     set handl [chhandle $n1 $n2]
        chhandle $n1 $n2
        if {$handl == 1} {
        puthelp "NOTICE $nick :Successfully changed\002 $n1 \002username to\002 $n2 \002"
        } else {
        puthelp "NOTICE $nick :SYNTAX: .chuser <old-Xuser> <new-Xuser>"
        }
}

putlog "Loaded: usermrg.tcl"
I`m a bit of a beginner :? , and I don`t know if the code that I`ve writed is the good one...
I wanted someting like this to be work: :arrow:
---
<me> .adduser
-|EGG- error. Use .adduser <Xuser>
---
<me> .adduser test
-|EGG- Added new user test with host *!*@test.users.undernet.org
---
<me> .addacc op test
-|EGG- User test added with OP Access on #chan
---
...and so on for the rest of the levels...
---
<me> .delacc test
-|EGG- Deleted access from user test on #chan
---
<me> .deluser test
-|EGG- User test has been deleted.
---
<me> .chuser test test1
-|EGG- Successfully changed test username to test1
---
I will appreciate a little help with this type a script :shock: , thanks
Last edited by Riddler on Sat Nov 28, 2009 8:09 pm, edited 2 times in total.
I am a man of few words, but many riddles
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

First off,

Code: Select all

chattr $hand -
will not remove any flags for the user, you'll have to specify any and all flags you wish to remove, such as

Code: Select all

chattr $hand -V
Also, you can mix + and - modes in the same string..

Further, in a few places you are using lindex in a dangerous manner. That is, you're using it on simple strings, and not proper tcl-lists. If you have a string you need to convert to a list, use the split-command.

Also, this will generate an error

Code: Select all

     .+host $text *!*@$text.users.undernet.org
.+host is a dcc-partyline command, not a tcl-command. See doc/tcl-commands.doc for commands available for scripting.
NML_375
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Ok, lets check out this proc:

Code: Select all

proc s:adduser {nick uhost hand chan text} {
  global botnick dj
   if {(![channel get $chan djtools]) && ($nick != $botnick)} {
   if {$text == ""} {
     puthelp "NOTICE $nick :SYNTAX: .adduser <Xuser>"
     } elseif {![validuser $text]} {
     puthelp "NOTICE $nick :\002$text \002is allready added to the database"
     } else {
     adduser $text
     .+host $text *!*@$text.users.undernet.org
     puthelp "NOTICE $nick :Added new user\002 $text \002with host\002 *!*@$text.users.undernet.org \002"
    }
  }
}
First mistake is considering $text as a single word/element. You only need the first word from $text, so use

Code: Select all

set username [lindex [split $text] 0]
Second mistake is that you're checking if a user is not valid, and if it is not valid you tell the command issuer that the user already exists. It should be otherwise:

Code: Select all

} elseif {[validuser $username]} {
 # username already exists
}
Ok, now where did you find a command called .+host? If it works via DCC that doesn't mean it's a valid Tcl-command :P So the correct proc should look like:

Code: Select all

proc s:adduser {nick uhost hand chan text} {
 if {![channel get $chan djtools] && ![isbotnick $nick]} {
  set username [lindex [split $text] 0]
  if {$username == ""} {
   puthelp "NOTICE $nick :SYNTAX: .adduser <Xuser>"
  } elseif {[validuser $username]} {
   puthelp "NOTICE $nick :\002$username\002 is already added to the database"
  } {
   adduser $username *!*@$username.users.undernet.org
   puthelp "NOTICE $nick :Added new user \002$username\002 with host \002*!*@$username.users.undernet.org\002"
  }
 }
}
Note that if {![channel get $chan djtools]} means if the channel does NOT have +djtools set, if that's not what you meant then remove the ! character.

Read Tcl-commands.doc to know about Eggdrop's Tcl-commands (see adduser, setuser, getuser).
R
Riddler
Halfop
Posts: 60
Joined: Sun May 20, 2007 10:20 pm
Location: Brasov, Romania
Contact:

Post by Riddler »

ok, so Sir_Fz, the .adduser comannd is working very good, the .deluser and .chuser give's a little error, something like this
<me> .deluser
-|EGG- SYNTAX: .deluser <user>
<me> .deluser t3ste
-|Egg- User t3ste has been deleted.
....
<me> .whois t3ste
<|EGG> [02:42] #me# whois t3ste
<|EGG> Can't find anyone matching that.
....
<me> .deluser t3st
-|EGG- User t3st doesn't exist! User .userlist
....
<me> .whois t3st
<|EGG> [02:43] #me# whois t3st
<|EGG> HANDLE PASS NOTES FLAGS LAST
<|EGG> t3st no 0 hp never (nowhere)
<|EGG> HOSTS: *!*@t3st.users.undernet.org
....
same thing happens on .chuser command as well, but this is a little error, I`ll search in tcl commands for the good code type....the only problem that I want to solve is the .addacc .delacc part of this script....
nml375 wrote:First off, Code:

Code: Select all

chattr $hand - 
will not remove any flags for the user, you'll have to specify any and all flags you wish to remove, such as Code:

Code: Select all

chattr $hand -V 
Also, you can mix + and - modes in the same string..
...ok I understad, but a little example, after I added the user to the eggdrops userlist, the give him with .addacc test Xuser ( chattr $hand +T $chan ) the Test DJ Access, all is well till now, but after 4 week's I decide that I would like to give him Administrator Access ... i type .addacc admin Xuser ( to change his access level ) ....the bot will have to do a chattr $hand -curent_flag $chan and then leave him with the flags +lo on that channel... after that the bot will give him the +A flag ( chattr $hand +A $chan ) so that he will have the +A flag along with the +lo flags ( already given) and NOT give him the +A along with the +T ( from the first start ) and along with the +lo flags ( default ) makeing the user to have 2 type's of flags ( +loTA ) ... the bot will be confused when that user will type some public comands.... :(

I don`t know if you understand what I`m trying to say here, but this is how I think this script will work

So, a little advice/suggestion ?!

thank you.

P.S.: Excuse my way of saying out this problem, but I`m a new around here and public commands are a little difficult :shock:
I am a man of few words, but many riddles
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

I'd suggest something like this:

Code: Select all

chattr $hand "+olT-VODSAM"
It will remove all but the desired flags of your userdefined ones, along with making sure ol is set aswell.

As for your problems with t3st, you do not trim any "extra" spaces or such, which could cause problems. That is, ".deluser t3st" would work, yet ".deluser t3st " would not. Could you confirm wether this might be the case?
NML_375
R
Riddler
Halfop
Posts: 60
Joined: Sun May 20, 2007 10:20 pm
Location: Brasov, Romania
Contact:

Post by Riddler »

nml375 wrote:I'd suggest something like this:

Code: Select all

chattr $hand "+olT-VODSAM"
It will remove all but the desired flags of your userdefined ones, along with making sure ol is set aswell.

As for your problems with t3st, you do not trim any "extra" spaces or such, which could cause problems. That is, ".deluser t3st" would work, yet ".deluser t3st " would not. Could you confirm wether this might be the case?
I understand nml375, so...I`ve changed a little of the tcl code....

Code: Select all

# Set here levels for accesses
set dj(l1) "Voice Access"
set dj(l2) "OP Access"
set dj(l3) "Test DJ Access"
set dj(l4) "DJ Access"
set dj(l5) "Senior DJ Access"
set dj(l6) "Administrator Access"
set dj(l7) "Manager Access"

bind pub n|MAS .adduser s:adduser
bind pub n|MAS .addacc s:addacc
bind pub n|MAS .delacc s:delacc

setudef flag djtools

proc s:adduser {nick uhost hand chan text} {
 global botnick dj
   if {[channel get $chan djtools] && ![isbotnick $nick]} {
     set username [lindex [split $text] 0]
     if {$username == ""} {
     puthelp "NOTICE $nick :SYNTAX:\002 .adduser <Xuser> \002"
     } elseif {[validuser $username]} {
     puthelp "NOTICE $nick :User \002$username\002 is already added. Add another!"
     } {
     adduser $username *!*@$username.users.undernet.org
     puthelp "NOTICE $nick :Added new user \002$username\002 with host \002*!*@$username.users.undernet.org\002"
    }
  }
}

proc s:addacc {nick uhost hand chan text} {
  global botnick dj
   if {[channel get $chan djtools] && ![isbotnick $nick]} {
     set auseracc [lindex [split $text] 0]
     set uhand [lindex [split $text] 1]
     if {$auseracc == ""} {
     puthelp "NOTICE $nick :SYNTAX: .addacc <voice|op|test|dj|senior|admin|manager> <user>"
     } elseif {$auseracc == "voice"} {
     chattr $uhand -VODSAM $chan
     chattr $uhand +loV $chan
     puthelp "NOTICE $nick :User\002 $uhand \002added with $dj(l1) on $chan"
     } elseif {$auseracc == "op"} {
     chattr $uhand -VODSAM $chan
     chattr $uhand +loO $chan
     puthelp "NOTICE $nick :User\002 $uhand \002added with $dj(l2) on $chan"
     } elseif {$auseracc == "test"} {
     chattr $uhand -VODSAM $chan
     chattr $uhand +loT $chan
     puthelp "NOTICE $nick :User\002 $uhand \002added with $dj(l3) on $chan"
     } elseif {$auseracc == "dj"} {
     chattr $uhand -VODSAM $chan
     chattr $uhand +loD $chan
     puthelp "NOTICE $nick :User\002 $uhand \002added with $dj(l4) on $chan"
     } elseif {$auseracc == "senior"} {
     chattr $uhand -VODSAM $chan
     chattr $uhand +loS $chan
     puthelp "NOTICE $nick :User\002 $uhand \002added with $dj(l5) on $chan"
     } elseif {$auseracc == "admin"} {
     chattr $uhand -VODSAM $chan
     chattr $uhand +loA $chan
     puthelp "NOTICE $nick :User\002 $uhand \002added with $dj(l6) on $chan"
     } elseif {$auseracc == "manager"} {
     chattr $uhand -VODSAM $chan
     chattr $uhand +loM $chan
     puthelp "NOTICE $nick :User\002 $uhand \002added with $dj(l7) on $chan"
     } else {
     puthelp "NOTICE $nick :Error,\002 $uhand \002doesn't exists! Use:\002 .userlist \002"
     }
   }
}

proc s:delacc {nick uhost hand chan text} {
  global botnick dj
   if {[channel get $chan djtools]&& ![isbotnick $nick]} {
     set duseracc [lindex [split $text] 0]
     if {$duseracc == ""} {
     puthelp "NOTICE $nick :SYNTAX: .delacc <user>"
     } else {
     chattr $duseracc -VODSAM $chan
     chattr $duseracc +lo $chan
     puthelp "NOTICE $nick :Deleted access for\002 $duseracc \002on $chan"
    }
  }
}

putlog "Loaded: usermrg.tcl"
and now the commands work, but not as I want :( ... instead of giveing that user the access on the channel ( +lo and one of the V, O, etc ).... it give's him global access...
<me> .addacc
-|EGG- SYNTAX: .addacc <voice|op|test|dj|senior|admin|manager> <user>
----
<me> .addacc voice t3st3
-|EGG- User t3st3 added with Voice Access on #channel
----
and now the .whois looks like this

Code: Select all

.whois t3st3
[18:40] #me# whois t3st3
HANDLE       PASS NOTES FLAGS           LAST
t3st3        no       0 hlopV          never (nowhere)
     #channel           -             never
  HOSTS: *!*@t3st3.users.undernet.org
----

strange ....normaly this is the way that it shoud look like on the .whois command..

Code: Select all

.whois t3st3
[18:40] #me# whois t3st3
HANDLE       PASS NOTES FLAGS           LAST
t3st3        no       0 hp          never (nowhere)
     #channel           loV            never
  HOSTS: *!*@t3st3.users.undernet.org
... what shoud I do ?

P.S.: nml375, I`m still working on the .deluser and .chuser commands, after I will test them, I`ll include them in this script...
I am a man of few words, but many riddles
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

doc/tcl-commands.doc wrote: chattr <handle> [changes [channel]]
Description: changes the attributes for a user record, if you include any.
Changes are of the form '+f', '-o', '+dk', '-o+d', etc. If changes are
specified in the format of |<changes> <channel>, the channel-specific
flags for that channel are altered. You can now use the +o|-o #channel
format here too.
Returns: new flags for the user (if you made no changes, the current
flags are returned). If a channel was specified, the global AND the
channel-specific flags for that channel are returned in the format of
globalflags|channelflags. "*" is returned if the specified user does
not exist.
Module: core
To make changes channel-speciffic, you'll have to do something like this:

Code: Select all

chattr |+Tol-VODSAM $chan
chattr |+Vol-TODSAM $chan
etc
Also, I really don't see why you modify the flags for a single handle multiple times. Especially in the cases where you first remove a flag just to add it right back again...

A hint while we're at it, when you build large blocks of if-ifelse-ifelse..., you might considder using switch instead. Yields cleaner code and slightly faster execution.
NML_375
R
Riddler
Halfop
Posts: 60
Joined: Sun May 20, 2007 10:20 pm
Location: Brasov, Romania
Contact:

Post by Riddler »

nml375 wrote:(...) Also, I really don't see why you modify the flags for a single handle multiple times. Especially in the cases where you first remove a flag just to add it right back again...
Ok, thanks for the hint, I`ll include them and see if it works :D :wink:
nml375 wrote:A hint while we're at it, when you build large blocks of if-ifelse-ifelse..., you might considder using switch instead. Yields cleaner code and slightly faster execution.
.... easy for you to say, but hard to do ( for me :cry: )... because I`m not a excellent coder...I`m new in public commands, and I`m still learning :) :P
I am a man of few words, but many riddles
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Hence a hint :)
NML_375
R
Riddler
Halfop
Posts: 60
Joined: Sun May 20, 2007 10:20 pm
Location: Brasov, Romania
Contact:

Post by Riddler »

ok, so, this is the code ..

Code: Select all

# Set here levels for accesses
set dj(l1) "Voice Access"
set dj(l2) "OP Access"
set dj(l3) "Test DJ Access"
set dj(l4) "DJ Access"
set dj(l5) "Senior DJ Access"
set dj(l6) "Administrator Access"
set dj(l7) "Manager Access"

bind pub n|MAS .adduser s:adduser
bind pub n|MAS .addacc s:addacc
bind pub n|MAS .delacc s:delacc
bind pub n|MAS .deluser s:deluser
bind pub n|MAS .chuser s:chuser

setudef flag djtools

proc s:adduser {nick uhost hand chan text} {
  global botnick dj
   if {[channel get $chan djtools] && ![isbotnick $nick]} {
     set username [lindex [split $text] 0]
     if {$username == ""} {
     puthelp "NOTICE $nick :SYNTAX:\002 .adduser <Xuser> \002"
     } elseif {[validuser $username]} {
     puthelp "NOTICE $nick :User \002$username\002 is already added. Add another!"
     } {
     adduser $username *!*@$username.users.undernet.org
     puthelp "NOTICE $nick :Added new user \002$username\002 with host \002*!*@$username.users.undernet.org\002"
    }
  }
}

proc s:addacc {nick uhost hand chan text} {
  global botnick dj
   if {[channel get $chan djtools] && ![isbotnick $nick]} {
     set auseracc [lindex [split $text] 0]
     set uhand [lindex [split $text] 1]
     if {$auseracc == ""} {
     puthelp "NOTICE $nick :SYNTAX: .addacc <voice|op|test|dj|senior|admin|manager> <user>"
     } elseif {$auseracc == "voice"} {
     chattr $uhand -|-VOTDSAM $chan
     chattr $uhand -|+loV $chan
     puthelp "NOTICE $nick :User\002 $uhand \002added with $dj(l1) on $chan"
     } elseif {$auseracc == "op"} {
     chattr $uhand -|-VOTDSAM $chan
     chattr $uhand -|+loO $chan
     puthelp "NOTICE $nick :User\002 $uhand \002added with $dj(l2) on $chan"
     } elseif {$auseracc == "test"} {
     chattr $uhand -|-VOTDSAM $chan
     chattr $uhand -|+loT $chan
     puthelp "NOTICE $nick :User\002 $uhand \002added with $dj(l3) on $chan"
     } elseif {$auseracc == "dj"} {
     chattr $uhand -|-VOTDSAM $chan
     chattr $uhand -|+loD $chan
     puthelp "NOTICE $nick :User\002 $uhand \002added with $dj(l4) on $chan"
     } elseif {$auseracc == "senior"} {
     chattr $uhand -|-VOTDSAM $chan
     chattr $uhand -|+loS $chan
     puthelp "NOTICE $nick :User\002 $uhand \002added with $dj(l5) on $chan"
     } elseif {$auseracc == "admin"} {
     chattr $uhand -|-VOTDSAM $chan
     chattr $uhand -|+loA $chan
     puthelp "NOTICE $nick :User\002 $uhand \002added with $dj(l6) on $chan"
     } elseif {$auseracc == "manager"} {
     chattr $uhand -|-VOTDSAM $chan
     chattr $uhand -|+loM $chan
     puthelp "NOTICE $nick :User\002 $uhand \002added with $dj(l7) on $chan"
     }
   }
}

proc s:delacc {nick uhost hand chan text} {
  global botnick dj
   if {[channel get $chan djtools] && ![isbotnick $nick]} {
     set duseracc [lindex [split $text] 0]
     if {$duseracc == ""} {
     puthelp "NOTICE $nick :SYNTAX: .delacc <user>"
     } else {
     chattr $duseracc -|-VOTDSAM $chan
     chattr $duseracc -|+lo $chan
     puthelp "NOTICE $nick :Deleted access for\002 $duseracc \002on $chan"
    }
  }
}

proc s:deluser {nick uhost hand chan text} {
  global botnick dj
   if {[channel get $chan djtools] && ![isbotnick $nick]} {
     set username [lindex [split $text] 0]
     if {$username == ""} {
     puthelp "NOTICE $nick :SYNTAX:\002 .deluser <user> \002"
     } elseif {[validuser $username]} {
     puthelp "NOTICE $nick :User \002$username\002 doesn't exist! User\002 .userlist \002"
     } {
     deluser $username
     puthelp "NOTICE $nick :User \002$username\002 has been deleted."
    }
  }
}

proc s:chuser {nick uhost hand chan text} {
  global botnick dj
   if {[channel get $chan djtools] && ![isbotnick $nick]} {
     set username [lindex [split $text] 0]
     if {$username == ""} {
     puthelp "NOTICE $nick :SYNTAX:\002 .chuser <olduser> <newuser> \002"
     } elseif {[validuser $username]} {
     puthelp "NOTICE $nick :Error,\002 $username \002is not a valid user. Use:\002 .userlist \002"
     } {
     set n1 [lindex $text 0]
     set n2 [lindex $text 1]
     chhandle $n1 $n2
     puthelp "NOTICE $nick :Successfully changed\002 $n1 \002username to\002 $n2 \002"
    }
  }
}

putlog "Loaded: usermrg.tcl"
I`ve tested it, and here are the results:

.adduser = working great ( thanks to Sir_Fz's help :D )
.addacc = working ( thanks to nml375 :D )
.delacc = working ( thanks to nml375 :D )
.deluser = error ->
<me> .deluser
-|EGG- SYNTAX: .deluser <user>
<me> .deluser t3st3
-|EGG- User t3st3 doesn't exist! User .userlist
<me> .deluser lol
-|EGG- User lol has been deleted.


user "t3st3" exists... but it says that it dosen't ! :?:

user "lol" dosen't exist ....but the bot deleted it ( How can you delete nothing :?: ) ...

.chuser = error ->

approximately the same type of error as the .deluser command :arrow:
<me> .chuser
-|EGG SYNTAX: .chuser <olduser> <newuser>
<me> .chuser t3st3 test1
-|EGG- Error, t3st3 is not a valid user. Use: .userlist
<me> .chuser lol test1
-|EGG- Successfully changed lol username to test1
user "t3st3" exists... but it says that it's not a valid one... :shock:

user "lol" dosen't exist ....but the bot say's that it successfully changed him .... :shock:

...uofff ...my head aches .... :x :x
I am a man of few words, but many riddles
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Code: Select all

proc s:deluser {nick uhost hand chan text} {
  global botnick dj
   if {[channel get $chan djtools] && ![isbotnick $nick]} {
     set username [lindex [split $text] 0]
     if {$username == ""} {
       puthelp "NOTICE $nick :SYNTAX:\002 .deluser <user> \002"
     } elseif {[validuser $username]} {

       # The username was valid, do some stuff here...
       puthelp "NOTICE $nick :User \002$username\002 doesn't exist! User\002 .userlist \002"
     } {

      # The username was not valid, do some other stuff here...
      deluser $username
      puthelp "NOTICE $nick :User \002$username\002 has been deleted."
    }
  }
} 
Think added comments should shed some light on the typo/bug..
Same thing goes with "chuser".

Hint, to negate an expression (turn true into false, and false into true; use ! )
Ie: if {!$true} {...
NML_375
R
Riddler
Halfop
Posts: 60
Joined: Sun May 20, 2007 10:20 pm
Location: Brasov, Romania
Contact:

Post by Riddler »

That`s it nml375 :D it works, at last it works... :D cheers mate
Now all I need to add is a .userlist command to show the users on the bot ...

I`ve try to code something....

Code: Select all

proc s:userlist {nick uhost hand chan text} {
  global botnick dj
   if {[channel get $chan djtools] && ![isbotnick $nick]} {
     set listu [lindex [split $text] 0]
     if {$listu == ""} {
     puthelp "NOTICE $nick :SYNTAX:\002 .userlist all|voice|op|test|dj|senior|admin|manager|suspend|none|bot \002"
     } elseif {$listu == "all"} {
     foreach allu [userlist -|MASDTOV $chan] {
     puthelp "NOTICE $nick :All Users on $chan:\002 $allu \002" }
    }
  }
}
it works, but not like I desire...when I type .userlist all, the reply is :
<me> .userlist
-|EGG- SYNTAX: .userlist all|voice|op|test|dj|senior|admin|manager|suspend|none|bot
<me> .userlist all
-|EGG- All Users on #channel: user1
-|EGG- All Users on #channel: user2
-|EGG- All Users on #channel: user3
-|EGG- All Users on #channel: user4
etc...
....I`ve like to show the list like this :
<me> .userlist
-|EGG- SYNTAX: .userlist all|voice|op|test|dj|senior|admin|manager|suspend|none|bot
<me> .userlist all
-|EGG- All Users on #channel: user1 user2 user3 user4 etc...
It save's the time and I don`t get flooded by the but, or the but can go offline with the "Excess Flood" reason ...

.... a little hint :roll:
I am a man of few words, but many riddles
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Check the join-command to see how to easily convert a list of items (such as handles) into a string..
And skip the foreach-loop :p
NML_375
R
Riddler
Halfop
Posts: 60
Joined: Sun May 20, 2007 10:20 pm
Location: Brasov, Romania
Contact:

Post by Riddler »

Huh, nml375 your one in a million :D the syntax code was

Code: Select all

set allu [lindex [userlist -|MASDTOV $chan]]
Thank you :D... cheers again mate 8)
I am a man of few words, but many riddles
R
Riddler
Halfop
Posts: 60
Joined: Sun May 20, 2007 10:20 pm
Location: Brasov, Romania
Contact:

Post by Riddler »

I`ve neglected something to ask you and everyone else... I`ve gone forth with a nother set of commands, and at the .delhost command I get a little error

Code:

Code: Select all

proc s:delhost {nick uhost hand chan text} {
  global botnick dj
   if {[channel get $chan djtools] && ![isbotnick $nick]} {
     set dhuser [lindex [split $text] 0]
     set dhost [lindex [split $text] 1]
     if {$dhuser == ""} {
     puthelp "NOTICE $nick :SYNTAX:\002 .delhost <user> <*!*@host>\002"
     } elseif {![validuser $dhuser]} {
     puthelp "NOTICE $nick :Error\002 $dhuser \002is not a valid user. Check\002 .userlist \002"
     } elseif {![string match -nocase *!*@* $dhost]} {
     puthelp "NOTICE $nick :Error\002 $dhost \002is not a valid host."
     } elseif {![string match -nocase $dhost $dhuser]} {
     puthelp "NOTICE $nick :Error\002 $dhost \002is not added as host for user\002 $dhuser \002"
     } else {
     delhost $dhuser $dhost
     puthelp "NOTICE $nick :Deleted host\002 $dhost \002from user\002 $dhuser \002"
    }
  }
}
and the Error:
<me> .delhost
-|EGG- SYNTAX: .delhost <user> <*!*@host>
<me> .delhost lol
-|EGG- Error lol is not a valid user. Check .userlist
<me> .delhost user1 34787
-|EGG- Error 34787 is not a valid host.
<me> .delhost user1 *!*@1.1.1.1
-|EGG- Error *!*@1.1.1.1 is not added as host for user user1
<me> .delhost user1 *!*@user1.users.undernet.org
-|EGG- Error *!*@user1.users.undernet.org is not added as host for user user1



The host *!*@1.1.1.1 dosen`t exists... but the host *!*@user1.users.undernet.org exists, it`s the default one... and the bot reply's that it dosen`t .. :?: :!:

This is the way it should answer:
<me> .delhost
-|EGG- SYNTAX: .delhost <user> <*!*@host>
<me> .delhost lol
-|EGG- Error lol is not a valid user. Check .userlist
<me> .delhost user1 34787
-|EGG- Error 34787 is not a valid host.
<me> .delhost user1 *!*@1.1.1.1
-|EGG- Error *!*@1.1.1.1 is not added as host for user user1
<me> .delhost user1 *!*@user1.users.undernet.org
-|EGG- Deleted host *!*@user1.users.undernet.org from user user1


any suggestion/hints ?! :?
I am a man of few words, but many riddles
Post Reply