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 

Help With .adduser this shud be simple to most

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
masheen
Voice


Joined: 28 Apr 2007
Posts: 28

PostPosted: Tue Jun 12, 2007 5:53 am    Post subject: Help With .adduser this shud be simple to most Reply with quote

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:
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. Smile
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
Back to top
View user's profile Send private message
masheen
Voice


Joined: 28 Apr 2007
Posts: 28

PostPosted: Tue Jun 12, 2007 7:29 am    Post subject: Reply with quote

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

Code:
Added [ashe]*!kyde@203.111.232.* with no password.

this is his original IP:
Code:
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:
adduser $anick [maskhost [getchanhost $anick $chan]]

pls help a begginer like me Smile
_________________
let he who is without stone cast the first sin
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Tue Jun 12, 2007 8:55 am    Post subject: Reply with quote

First off, change this:
Code:
set anick [lindex $text 0]

into
Code:
set l_text [split $text]
set anick [lindex $l_text 0]


Next, this is dangerous and pointless:
Code:
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:
   if {[validuser $anick]} {
      putserv "PRIVMSG $chan :ERROR: $anick is already in my userlist."
          return 0
   }
   
   if {![validuser $anick]} {
      ...

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


Joined: 28 Apr 2007
Posts: 28

PostPosted: Tue Jun 12, 2007 10:55 am    Post subject: Reply with quote

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

have tried the following with not much success:

Code:
adduser $anick

&
Code:
adduser $anick [gethost $anick $chan]


i even tried this one
Code:
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:
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:
[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.
_________________
let he who is without stone cast the first sin


Last edited by masheen on Tue Jun 12, 2007 11:05 am; edited 1 time in total
Back to top
View user's profile Send private message
masheen
Voice


Joined: 28 Apr 2007
Posts: 28

PostPosted: Tue Jun 12, 2007 10:59 am    Post subject: Reply with quote

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

Code:
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:
       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
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Tue Jun 12, 2007 1:08 pm    Post subject: Reply with quote

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

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


Joined: 28 Apr 2007
Posts: 28

PostPosted: Wed Jun 13, 2007 5:26 am    Post subject: Reply with quote

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:
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
Back to top
View user's profile Send private message
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Wed Jun 13, 2007 9:49 am    Post subject: Reply with quote

Quote:
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
Back to top
View user's profile Send private message Visit poster's website
masheen
Voice


Joined: 28 Apr 2007
Posts: 28

PostPosted: Thu Jun 14, 2007 11:10 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Fri Jun 15, 2007 9:26 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message 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
Page 1 of 1

 
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