| View previous topic :: View next topic |
| Author |
Message |
cache Master
Joined: 10 Jan 2006 Posts: 306 Location: Mass
|
Posted: Wed May 07, 2008 7:10 am Post subject: Command - only function by my nick |
|
|
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 |
|
 |
DragnLord Owner

Joined: 24 Jan 2004 Posts: 711 Location: C'ville, Virginia, USA
|
Posted: Wed May 07, 2008 11:31 am Post subject: Re: Command - only function by my nick |
|
|
| 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 |
|
 |
DragnLord Owner

Joined: 24 Jan 2004 Posts: 711 Location: C'ville, Virginia, USA
|
Posted: Wed May 07, 2008 11:37 am Post subject: |
|
|
| 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 |
|
 |
Papillon Owner

Joined: 15 Feb 2002 Posts: 724 Location: *.no
|
Posted: Wed May 07, 2008 12:15 pm Post subject: |
|
|
...unless he/she want to showoff by doing the command and have everyone else try it aswell ..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 |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Wed May 07, 2008 1:27 pm Post subject: |
|
|
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 |
|
 |
Papillon Owner

Joined: 15 Feb 2002 Posts: 724 Location: *.no
|
Posted: Wed May 07, 2008 1:34 pm Post subject: |
|
|
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
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 |
|
 |
cache Master
Joined: 10 Jan 2006 Posts: 306 Location: Mass
|
Posted: Wed May 07, 2008 2:10 pm Post subject: |
|
|
| 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 |
|
 |
cache Master
Joined: 10 Jan 2006 Posts: 306 Location: Mass
|
Posted: Wed May 07, 2008 2:42 pm Post subject: |
|
|
| 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  |
|
| Back to top |
|
 |
|