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 

Command - only function by my nick

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
cache
Master


Joined: 10 Jan 2006
Posts: 306
Location: Mass

PostPosted: Wed May 07, 2008 7:10 am    Post subject: Command - only function by my nick Reply with quote

am trying to make a command only work by my nickname

I did this but no results or errors

Code:
set 123owner "cache"
set 123activatecmd "!test"

   proc proc_thisatest {nick uhost hand cmd} {
    if {[string tolower $command] == [string tolower $123activatecmd]} {
      if {[string tolower $nick] == [string tolower $123owner]} {
        putquick "PRIVMSG $chan :xx blah"
        } else {
        putquick "NOTICE $nick :Only $132owner can use this command."
      }
}
}


Does anyone have one I can edit? I do want to make one that can work by 2 nicks.

Thanks
Back to top
View user's profile Send private message
DragnLord
Owner


Joined: 24 Jan 2004
Posts: 711
Location: C'ville, Virginia, USA

PostPosted: Wed May 07, 2008 11:31 am    Post subject: Re: Command - only function by my nick Reply with quote

cache wrote:
am trying to make a command only work by my nickname

I did this but no results or errors

Code:
set 123owner "cache"
set 123activatecmd "!test"

   proc proc_thisatest {nick uhost hand cmd} {
    if {[string tolower $command] == [string tolower $123activatecmd]} {
      if {[string tolower $nick] == [string tolower $123owner]} {
        putquick "PRIVMSG $chan :xx blah"
        } else {
        putquick "NOTICE $nick :Only $132owner can use this command."
      }
}
}


Does anyone have one I can edit? I do want to make one that can work by 2 nicks.

Thanks
This is why eggdrop has user flags.
Set the user flag "9" [example: .chattr cache 9] to who you want to be able to use the command and set that also in the bind.
Code:
bind msg 9 $123activatecmd proc_thisatest

The bind has to come after the sets.
Back to top
View user's profile Send private message
DragnLord
Owner


Joined: 24 Jan 2004
Posts: 711
Location: C'ville, Virginia, USA

PostPosted: Wed May 07, 2008 11:37 am    Post subject: Reply with quote

Code:
set 123activatecmd "!test"
bind pub 9 $123activatecmd proc_thisatest

proc proc_thisatest {nick uhost hand chan text} {
        putquick "PRIVMSG $chan :xx blah"
}
Back to top
View user's profile Send private message
Papillon
Owner


Joined: 15 Feb 2002
Posts: 724
Location: *.no

PostPosted: Wed May 07, 2008 12:15 pm    Post subject: Reply with quote

...unless he/she want to showoff by doing the command and have everyone else try it aswell Smile ..and then you have to tell them that they cannot offcourse
Code:
set 123owner "cache nick2"
set 123activatecmd "!test"

bind pub - $123activatecmd proc_thisatest
proc proc_thisatest {nick uhost hand chan text} {
   if {[lsearch [list $::123owner] $nick ] != -1} {
      putquick "PRIVMSG $chan :xx blah"
   } else {
      set niceoutputthingie [join [split $::132owner] " and "]
      putquick "NOTICE $nick :Only $niceoutputthingie can use this command."
   }
}

would not recommend this method though, atleast to execute any "dangerous" commands, anyone stealing your nick would be able to execute it..
_________________
Elen sila lúmenn' omentielvo
Back to top
View user's profile Send private message MSN Messenger
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Wed May 07, 2008 1:27 pm    Post subject: Reply with quote

Papillon:
That code is unfortunately flawed, as the list you search using lsearch contains one single item, being the full content of ::123owner. Were you thinking of using split perhaps?

=====
I would advocate the use of user-records and flags, and replace the test with something like this:
Code:
if {[matchattr $hand 9|9 $chan]} {...

In this case, the binding would be similar to that one posted by DragnLord, except the flag would be - instead of 9.
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Papillon
Owner


Joined: 15 Feb 2002
Posts: 724
Location: *.no

PostPosted: Wed May 07, 2008 1:34 pm    Post subject: Reply with quote

it's 3-4 years since the last time i touched anything with tcl so I'm abit "rusty"... yes, I was thinking about split, thought I'd added it Smile

as said in the last post, I recommend using user-flags instead of nick-matching along with nml375 and DragnLord
_________________
Elen sila lúmenn' omentielvo
Back to top
View user's profile Send private message MSN Messenger
cache
Master


Joined: 10 Jan 2006
Posts: 306
Location: Mass

PostPosted: Wed May 07, 2008 2:10 pm    Post subject: Reply with quote

DragnLord wrote:
Code:
set 123activatecmd "!test"
bind pub 9 $123activatecmd proc_thisatest

proc proc_thisatest {nick uhost hand chan text} {
        putquick "PRIVMSG $chan :xx blah"
}


Thanks for the input, im trying to do this without having to setup a flag in the bot, so I see I left off pub -|- somewhere
Back to top
View user's profile Send private message
cache
Master


Joined: 10 Jan 2006
Posts: 306
Location: Mass

PostPosted: Wed May 07, 2008 2:42 pm    Post subject: Reply with quote

nml375 wrote:
Papillon:
That code is unfortunately flawed, as the list you search using lsearch contains one single item, being the full content of ::123owner. Were you thinking of using split perhaps?

=====
I would advocate the use of user-records and flags, and replace the test with something like this:
Code:
if {[matchattr $hand 9|9 $chan]} {...

In this case, the binding would be similar to that one posted by DragnLord, except the flag would be - instead of 9.


Not for anything dangerous/excutable so I am just doing this without flags Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests 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