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 .adduser this shud be simple to most

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
masheen
Voice
Posts: 28
Joined: Sat Apr 28, 2007 1:14 pm

Help With .adduser this shud be simple to most

Post by masheen »

the following code merely executes .adduser <nick> when i type !auser <nick> my problem is dat i wanted it to add the hostmask along with the nick. i know it can be done using !auser <nick> <host> but is it possible to just use !auser <nick> and then a code will just add the hostmask for the bot to register the nick with? thanks for anyone who can help. anyway heres the simple code i made...its working already but minus the <hostmask>.

Code: Select all

proc pub:adduser {nick uhost hand chan text} {
        set anick [lindex $text 0]
        set nlist [countusers]

        if {![matchattr $nick n|n $chan]}  {
               putserv "PRIVMSG $chan :ERROR: this is a botowner command."
	       return 0
        }
	if {![onchan $anick $chan]} {
		putserv "PRIVMSG $chan :ERROR: $anick is not on $chan. aborting command."
		return 0
	}
	if {$anick == ""}   {
               putserv "PRIVMSG $chan :ERROR: usage is !auser <handle/nick>."
               return 0
        }
	if {[validuser $anick]} {
		putserv "PRIVMSG $chan :ERROR: $anick is already in my userlist."
	       return 0
	}
	
	if {![validuser $anick]} {
		adduser $anick
	       putserv "PRIVMSG $chan :$anick has been added to my userlist. i now have ($nlist) on my database."
	       return 0
	} 
        putcmdlog "#$nick# added $nick on userlist"
}
and if anyone can improve the above code pls help too. :)
by the way my purpose for this is for me to be able to add nicks on my botlist without having to dcc all the time. i just identity to the bot and i can add and del users on public command. some eggdrop begginers like me may find the code a bit usefull for their bots too i hope.
let he who is without stone cast the first sin
User avatar
masheen
Voice
Posts: 28
Joined: Sat Apr 28, 2007 1:14 pm

Post by masheen »

by the way the host attached to the nick shud be in this form:

Code: Select all

Added [ashe]*!kyde@203.111.232.* with no password.
this is his original IP:

Code: Select all

Address : ~kyde@203.111.232.98
i tried using this code by the way and it doesnt work cos if u notice the host has to be trimmed and take away the '~' and trim .98 from the host part to get 203.111.232.* as the host. and that i do not know how to do:

Code: Select all

adduser $anick [maskhost [getchanhost $anick $chan]]
pls help a begginer like me :)
let he who is without stone cast the first sin
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

First off, change this:

Code: Select all

set anick [lindex $text 0]
into

Code: Select all

set l_text [split $text]
set anick [lindex $l_text 0]
Next, this is dangerous and pointless:

Code: Select all

if {![matchattr $nick n|n $chan]}  {
You should only test the handle, not the nickname.

Also, this could be changed to use an else-clause:

Code: Select all

   if {[validuser $anick]} {
      putserv "PRIVMSG $chan :ERROR: $anick is already in my userlist."
          return 0
   }
   
   if {![validuser $anick]} {
      ...
ie:

Code: Select all

 if {[validuser $anick]} {
  putserv "PRIVMSG $chan :ERROR: $anick is already in my userlist."
 } else {
  ...
As for your second request, removing ~ would be a matter of applying string trimleft to trim off any leading ~.
As for removing the last number of an IP-host, this is alittle more cumbersome. One way of doing it would be to split the hostmask using . as separator, then use lrange to select a sublist from the splitted hostmask (range should be 0 end-1), and then finally join it back into a string (using . as joinstring). Of course, for this to work relyable, you'll first have to make sure it really is an IP-host and nothing else.
NML_375
User avatar
masheen
Voice
Posts: 28
Joined: Sat Apr 28, 2007 1:14 pm

Post by masheen »

have done the changes thanks :) uv bin helpful...now on to my last problem which concerns .adduser

have tried the following with not much success:

Code: Select all

adduser $anick
&

Code: Select all

adduser $anick [gethost $anick $chan]
i even tried this one

Code: Select all

set l_text [split $text]
set anick [lindex $l_text 0]
set gethost [lindex $l_text 1]
and when i type !auser Gothix *!kyde@203.111.232.* which triggers the following:

Code: Select all

if {![validuser $anick]} {
		adduser $anick $gethost
		putserv "PRIVMSG $chan :$anick has been added to my userlist. database updated."
	       return 0
		}
and on my DCC console i typed: .whois Gothicx the bots internal list cud not find him, so its obvious that it wasnt stored.

Code: Select all

[10:46] <Masheen> .whois Gothix
[10:46] <(bioman)> [09:46] #Masheen# whois Gothix
[10:46] <(bioman)> Can't find anyone matching that.
anything you cud add or advice for the adduser to work? are there any chanset settings or conf settings i missed? thanks thanks a lot for the trouble. this adduser is giving me nightmares lols...but m learning thanks to you guys.
Last edited by masheen on Tue Jun 12, 2007 11:05 am, edited 1 time in total.
let he who is without stone cast the first sin
User avatar
masheen
Voice
Posts: 28
Joined: Sat Apr 28, 2007 1:14 pm

Post by masheen »

for the sake of making it clear heres the code with some of the changes you mentioned

Code: Select all

bind pub -|- !auser pub:adduser

proc pub:adduser {nick uhost hand chan text} {
        set l_text [split $text]
	set anick [lindex $l_text 0]
	set gethost [lindex $l_text 1]

        if {![matchattr $nick n|m $chan]}  {
               putserv "PRIVMSG $chan :ERROR: this is a botowner command."
	       return 0
        }
	if {![onchan $anick $chan]} {
		putserv "PRIVMSG $chan :ERROR: $anick is not on $chan. aborting command."
		return 0
	}
	if {$anick == ""}   {
               putserv "PRIVMSG $chan :ERROR: usage is !auser <handle/nick>."
               return 0
        }
	if {[validuser $anick]} {
		putserv "PRIVMSG $chan :ERROR: $anick is already in my userlist."
	       return 0
	} else {
		if {![validuser $anick]} {
		adduser $anick $gethost
		putserv "PRIVMSG $chan :$anick has been added to my userlist. database updated."
	       return 0
		}
	} 
}
dont wori bout this one, il change this later

Code: Select all

       if {![matchattr $nick n|m $chan]}  {
my main concern really is to make the adduser work. thanks again.
let he who is without stone cast the first sin
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

This section is.. well... goofed up:

Code: Select all

 if {[validuser $anick]} {
  putserv "PRIVMSG $chan :ERROR: $anick is already in my userlist."
  return 0
 } else {
  if {![validuser $anick]} {
   adduser $anick $gethost
   putserv "PRIVMSG $chan :$anick has been added to my userlist. database updated."
   return 0
  }
 }
Since we're using an else-clause, doing a second test on the same conditional is pretty pointless, drop the "if {![validuser $anick]} {"...

As for user not being added to your userlist, do you get any error messages on your partyline console or logs?
NML_375
User avatar
masheen
Voice
Posts: 28
Joined: Sat Apr 28, 2007 1:14 pm

Post by masheen »

ok fixed the redundant validuser check on else clause thanks. as for the error, i dont have any on both telnet and on dcc everytime the .adduser is being triggered... as well as on the logs. nada! any ideas left? i am sure the adduser is triggered cos i put these lines to make sure that the adduser is triggered and amazingly produces no errors on logs, and both DCC and telnet console:

Code: Select all

if {[...]} {
     puthelp "PRIVMSG $chan:1st msg before execute"
     adduser [getchanhost $anick $chan]
     puthelp "PRIVMSG $chan:2nd msg after execute"

}
just to make sure i am indeed executing the adduser command. but no luck.
let he who is without stone cast the first sin
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

adduser <handle> [hostmask]
Description: creates a new user entry with the handle and hostmask given
(with no password and the default flags)
Returns: 1 if successful; 0 if the handle already exists
Module: core
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
masheen
Voice
Posts: 28
Joined: Sat Apr 28, 2007 1:14 pm

Post by masheen »

not really my best trait to give up but i have tried everything my brain has to offer to solve this problem but i could not get the adduser to work as nided..gues i have no choice but to post on the script request section. haha. thanks guys for the help. really appreciate it.
let he who is without stone cast the first sin
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

If you bothered to actually read the syntax (posted above) and compared it to what you're not actually doing you'd figure it out.
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Post Reply