egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[SOLVED] A little UserMRG.tcl script...
Goto page 1, 2  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
Riddler
Halfop


Joined: 20 May 2007
Posts: 60
Location: Brasov, Romania

PostPosted: Tue Jun 05, 2007 7:17 pm    Post subject: [SOLVED] A little UserMRG.tcl script... Reply with quote

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. Sad

Code:
# 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 Confused , 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

Quote:
---
<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 Shocked , thanks
_________________
I am a man of few words, but many riddles


Last edited by Riddler on Sat Nov 28, 2009 8:09 pm; edited 2 times in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Tue Jun 05, 2007 7:36 pm    Post subject: Reply with quote

First off,
Code:
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:
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:
     .+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, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Tue Jun 05, 2007 7:42 pm    Post subject: Reply with quote

Ok, lets check out this proc:
Code:
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:
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:
} 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 Razz So the correct proc should look like:
Code:
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).
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
Riddler
Halfop


Joined: 20 May 2007
Posts: 60
Location: Brasov, Romania

PostPosted: Tue Jun 05, 2007 9:06 pm    Post subject: Reply with quote

ok, so Sir_Fz, the .adduser comannd is working very good, the .deluser and .chuser give's a little error, something like this

Quote:
<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:
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:
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.... Sad

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 Shocked
_________________
I am a man of few words, but many riddles
Back to top
View user's profile Send private message Send e-mail Visit poster's website
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Wed Jun 06, 2007 11:18 am    Post subject: Reply with quote

I'd suggest something like this:
Code:
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, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Riddler
Halfop


Joined: 20 May 2007
Posts: 60
Location: Brasov, Romania

PostPosted: Wed Jun 06, 2007 1:28 pm    Post subject: Reply with quote

nml375 wrote:
I'd suggest something like this:
Code:
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:
# 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 Sad ... instead of giveing that user the access on the channel ( +lo and one of the V, O, etc ).... it give's him global access...

Quote:
<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:
.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:
.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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Wed Jun 06, 2007 1:47 pm    Post subject: Reply with quote

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:
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, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Riddler
Halfop


Joined: 20 May 2007
Posts: 60
Location: Brasov, Romania

PostPosted: Wed Jun 06, 2007 2:03 pm    Post subject: Reply with quote

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 Very Happy 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 Crying or Very sad )... because I`m not a excellent coder...I`m new in public commands, and I`m still learning Smile Razz
_________________
I am a man of few words, but many riddles
Back to top
View user's profile Send private message Send e-mail Visit poster's website
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Wed Jun 06, 2007 2:10 pm    Post subject: Reply with quote

Hence a hint Smile
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Riddler
Halfop


Joined: 20 May 2007
Posts: 60
Location: Brasov, Romania

PostPosted: Wed Jun 06, 2007 2:37 pm    Post subject: Reply with quote

ok, so, this is the code ..

Code:
# 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 Very Happy )
.addacc = working ( thanks to nml375 Very Happy )
.delacc = working ( thanks to nml375 Very Happy )
.deluser = error ->

Quote:
<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 ! Question

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

.chuser = error ->

approximately the same type of error as the .deluser command Arrow

Quote:
<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... Shocked

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

...uofff ...my head aches .... Mad Mad
_________________
I am a man of few words, but many riddles
Back to top
View user's profile Send private message Send e-mail Visit poster's website
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Wed Jun 06, 2007 2:52 pm    Post subject: Reply with quote

Code:
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, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Riddler
Halfop


Joined: 20 May 2007
Posts: 60
Location: Brasov, Romania

PostPosted: Wed Jun 06, 2007 6:24 pm    Post subject: Reply with quote

That`s it nml375 Very Happy it works, at last it works... Very Happy 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:
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 :

Quote:
<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 :

Quote:
<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 Rolling Eyes
_________________
I am a man of few words, but many riddles
Back to top
View user's profile Send private message Send e-mail Visit poster's website
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Wed Jun 06, 2007 6:39 pm    Post subject: Reply with quote

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, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Riddler
Halfop


Joined: 20 May 2007
Posts: 60
Location: Brasov, Romania

PostPosted: Thu Jun 07, 2007 2:36 pm    Post subject: Reply with quote

Huh, nml375 your one in a million Very Happy the syntax code was
Code:
set allu [lindex [userlist -|MASDTOV $chan]]


Thank you Very Happy... cheers again mate Cool
_________________
I am a man of few words, but many riddles
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Riddler
Halfop


Joined: 20 May 2007
Posts: 60
Location: Brasov, Romania

PostPosted: Thu Jun 07, 2007 4:44 pm    Post subject: Reply with quote

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:
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:

Quote:
<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 .. Question Exclamation

This is the way it should answer:

Quote:
<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 ?! Confused
_________________
I am a man of few words, but many riddles
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber