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.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Well, this piece confuses me:

Code: Select all

string match -nocase $dhost $dhuser
You're only checking wether the the two parameters you've entered "match" eachother. It does no test whatsoever if the hostmask entered on the commandline is added to the user record.
Easiest, I'd guess, would just to use delhost, and test the returncode to see wether the hostmask was successfully removed...
doc/tcl.commands.doc wrote: delhost <handle> <hostmask>
Description: deletes a hostmask from a user's host list
Returns: 1 on success; 0 if the hostmask (or user) doesn't exist
Module: core
NML_375
R
Riddler
Halfop
Posts: 60
Joined: Sun May 20, 2007 10:20 pm
Location: Brasov, Romania
Contact:

Post by Riddler »

nml375 wrote: Easiest, I'd guess, would just to use delhost, and test the returncode to see wether the hostmask was successfully removed...
doc/tcl.commands.doc wrote: delhost <handle> <hostmask>
Description: deletes a hostmask from a user's host list
Returns: 1 on success; 0 if the hostmask (or user) doesn't exist
Module: core
Well I`ve tried that also and still not the results I want....

The new 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."
     } else {
     delhost $dhuser $dhost
     puthelp "NOTICE $nick :Deleted host\002 $dhost \002from user\002 $dhuser \002"
     return 0 }
     puthelp "NOTICE $nick :Error\002 $dhost \002is not added as host for user\002 $dhuser \002"
     }
}
a nother suggestion/ideea :idea: ? pls :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 »

Skip the string-match completely, and just test wether deleting the host works or not?

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 {![delhost $dhuser $dhost]} {
   puthelp "NOTICE $nick :Error\002 $dhost \002was not added to $dhuser."
  } else {
   puthelp "NOTICE $nick :Deleted host\002 $dhost \002from user\002 $dhuser \002"
  }
 }
}
NML_375
R
Riddler
Halfop
Posts: 60
Joined: Sun May 20, 2007 10:20 pm
Location: Brasov, Romania
Contact:

Post by Riddler »

nml375 wrote:Skip the string-match completely, and just test wether deleting the host works or not?
Thank you :D :D ..it works but it was not necessary to remove the string-match...I`ve replaced the

Code: Select all

{![string match -nocase $dhost $dhuser]} {
with your suggestion ..

Code: Select all

{![delhost $dhuser $dhost]} { 
and the scripts works perfectly 8) :lol:
<me> .delhost
-|EGG- SYNTAX: .delhost <user> <*!*@host>
<me> .delhost lol
-|EGG- Error lol is not a valid user. Check .userlist
<me> .delhost test 34893948
-|EGG- Error 34893948 is not a valid host.
<me> .delhost test *!*@domain.name
-|EGG- Error *!*@domain.name was not added to test.
<me> .delhost test *!*@test.ro
-|EGG- Deleted host *!*@test.ro from user test


Thanks again for the help nml375 :D :wink: :P
I am a man of few words, but many riddles
Post Reply