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.

Custom userflags

Help for those learning Tcl or writing their own scripts.
Post Reply
k
keung
Voice
Posts: 5
Joined: Mon Apr 30, 2012 8:30 pm

Custom userflags

Post by keung »

I'm in the process of writing a script where I'd like to have custom flags for users on channels. This is a bot where most communication is done on the channels themselves. The users I'd like to have as owners of channels will not be owners in the traditional way where they have access to add more users or alter anyone's flags, but rather have access to more commands than a regular user. To accomplish this I suppose I have to use custom flags, but is there anything I have to manipulate to make the bot recognize these flags?

From what I see on this page (is this the complete set of flags?), the flag i would be available.

.chattr user +i #examplechannel

And then

bind pub "n|i" !ownercommand some_proc_for_channelowners_only

Would this suffice? Also, how could I make sure that the bind only triggers for users that has that specific flag, and not trigger for any global flag?
w
willyw
Revered One
Posts: 1209
Joined: Thu Jan 15, 2009 12:55 am

Re: Custom userflags

Post by willyw »

keung wrote: ...
From what I see on this page (is this the complete set of flags?), the flag i would be available.
It probably is.

Try:
.help whois
in the partyline, to have the bot give you a list of flags.

Note this line, from there:
There are also 26 user-defined channel flags (A-Z).
To conform to that, when I do it, I use an UPPER CASE flag.
.chattr user +i #examplechannel

And then

bind pub "n|i" !ownercommand some_proc_for_channelowners_only

Would this suffice? Also, how could I make sure that the bind only triggers for users that has that specific flag, and not trigger for any global flag?
That would trigger for global owners and also those with channel flag "i".
Reference: http://suninet.the-demon.de/041.htm

I'm not real sure of what you are wanting to do, but it seems that if you did something like
.chattr user +I #channel
for every user, including yourself, that you wanted to be able to use the proc, ... wouldn't that do it?
Then bind like this:
bind -|I "!specialcommand" proc_for_those_with_I
k
keung
Voice
Posts: 5
Joined: Mon Apr 30, 2012 8:30 pm

Post by keung »

Oh, I forgot for a second that flags were case sensitive and that A-Z could be used as well. Knowing this makes it a whole lot easier!

With the bind -|I, wouldn't that mean that anyone who is added to the bot with global flags could run the command? Come to think of it, it shouldn't really matter, I could just do an if statement to exclude anyone who doesn't have the +I flag from executing the command.

But, yes, you got what I meant. .chattr user +I #channel is in essence what I want to do. I was just a little unsure that it would really be that easy!
w
willyw
Revered One
Posts: 1209
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

keung wrote:Oh, I forgot for a second that flags were case sensitive and that A-Z could be used as well. Knowing this makes it a whole lot easier!
:)
With the bind -|I, wouldn't that mean that anyone who is added to the bot with global flags could run the command?
What global flags?
... not sure what you mean...

(Have you examined : http://suninet.the-demon.de/041.htm yet? )
Come to think of it, it shouldn't really matter, I could just do an if statement to exclude anyone who doesn't have the +I flag from executing the command.
umm.... that's the purpose of flags in the bind... so you don't have to do that.
But, yes, you got what I meant. .chattr user +I #channel is in essence what I want to do. I was just a little unsure that it would really be that easy!
Do some experimenting.
Carefully, to be sure you get the results you want.
k
keung
Voice
Posts: 5
Joined: Mon Apr 30, 2012 8:30 pm

Post by keung »

Say that I have

bind -|I "!something" do_something

Doesn't the - imply that anyone can run the command, despite not having the +I flag on the channel? Or does that tell the eggdrop that only users with the flag can run the command?
w
willyw
Revered One
Posts: 1209
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

keung wrote:Say that I have

bind -|I "!something" do_something

Doesn't the - imply that anyone can run the command, despite not having the +I flag on the channel? Or does that tell the eggdrop that only users with the flag can run the command?
willyw wrote: Do some experimenting.
Carefully, to be sure you get the results you want.

Here... try this:

Code: Select all


# May 2, 2012

# http://forum.egghelp.org/viewtopic.php?p=99315#99315


bind pub -|I "!something" do_something 

proc do_something {nick uhost handle chan text} {

	putserv "privmsg $chan :Bind triggered the proc"

}

Load that, and see what you get when you try it.
Experiment with setting global +I on yourself, and removing it.
Experiment with setting channel specific +I on yourself and removing it.

After every attempt to trigger the bind, do:
.binds *something*
in the partyline, and note the hit counter, too.

For myself, I found that I had to have the channel specific +I, to have bind trigger... which is what I expected. :)


I hope this helps.
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

keung wrote:Say that I have

bind -|I "!something" do_something

Doesn't the - imply that anyone can run the command, despite not having the +I flag on the channel? Or does that tell the eggdrop that only users with the flag can run the command?
The - is a placeholder, to tell the interpreter to check for negative flags. But you've given it no flags to -. So basically, all that does is nothing. "-|+o" == "|+o" == "+|+o". Basically you have "GLOBAL|CHANNEL" in regard to flags. If I want to check if someone is owner of the bot itself "n|-" or "n|" or "n|+" would do that. If I want to check if someone is owner of an irc channel "-|n" or "|n" or "+|n" would do that.
k
keung
Voice
Posts: 5
Joined: Mon Apr 30, 2012 8:30 pm

Post by keung »

Thanks for clearing this up! This thread went a little further than I expected. I actually don't have a bot running - yet :oops: - so I haven't been able to play much with bind. I'm just writing a lot of code in a tcl file and running it through a shell to test it before I put it on an actual eggdrop, as I find it much more convenient to bugtest it that way.
Post Reply