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.

{SOLVED} Getting user modes for chan owners and admins

Help for those learning Tcl or writing their own scripts.
Post Reply
A
AK49BWL
Voice
Posts: 7
Joined: Thu Sep 02, 2010 6:24 pm

{SOLVED} Getting user modes for chan owners and admins

Post by AK49BWL »

Here's what I'm trying to do.. I'm attempting to show owners and admins on my livestats channel pages for my website, rather than them showing up as just OP users (which is how the livestats script was originally written). On my channel currently, there are 6 users:

~AK49BWL, +qo
&GOD, +ao
&The_Wolf, +ao
@badSol, +o
@roadlet_411, +o
Player5

when I use !usermodes to activate, I get this on the output:

q=1 a=0 o=4 h=0 v=0 n=1 total=6

So the admins are seemingly being ignored by the script, or I did something wrong... I'm quite new to scripting so the latter is probably the case. But the owner is being detected, so I did something correct there.

The script works in the sense that it runs and throws no errors, but it doesn't work like I had hoped. My script as it sits currently:

Code: Select all

#test.tcl - BWL's always-on TCL script testing

bind pub - !usermodes pum

proc pum {nick uhost hand channel arg} {
  set users [llength [chanlist $channel]]
  set user_total  $users
  set user_q      0
  set user_a      0
  set user_o      0
  set user_h      0
  set user_v      0
  set user_n      0    
  foreach user [chanlist $channel] {
    if { [matchattr $user q $channel] } {
      incr user_q
    } elseif { [matchattr $user a $channel] } {
      incr user_a
    } elseif { [isop $user $channel] } {
      incr user_o
    } elseif { [ishalfop $user $channel] } {
      incr user_h
    } elseif { [isvoice $user $channel] } {
      incr user_v
    } else {
      incr user_n
    }
  }
  putserv "PRIVMSG $channel :q=$user_q a=$user_a o=$user_o h=$user_h v=$user_v n=$user_n total=$user_total"
}


putlog "BWL's Testing TCL Script loaded."
EDIT:::

Well I did some further messing around but eventually put the script back the way it is up there... But I also did this: I made user AK49BWL just a regular user and tried !usermodes again, and it gave me the exact same result of q=1 a=0 o=4 h=0 v=0 n=1 total=6..... When there is no +qo! So I really don't know what's going on here.
Last edited by AK49BWL on Fri Sep 24, 2010 5:27 pm, edited 1 time in total.
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

1) First of all, it isn't clear whether you want bot user modes or irc channel user modes or a mixture. At the moment you are using a mixture. For example you use matchattr for bot mode a (autovoice) but isop for irc channel op mode.

2) An if - else-if - else code block means that code stops at the first test passed. For example, if a user had BOT modes qa then user_q would be incremented because this is the first test passed, but user_a would not.
I must have had nothing to do
A
AK49BWL
Voice
Posts: 7
Joined: Thu Sep 02, 2010 6:24 pm

Post by AK49BWL »

The latter is what I'm going for. I'm the chanowner so I should only show on +q status, not +o as well. The bot is +ao, and as such should only show under +a. That is the intent, anyway, if any of that actually worked at all.

I guess my question is, is there anything similar to isop (ishalfop, isvoice) for chanadmins and chanowners? I thought maybe matchattr was something I could sub for that but apparently not.. I didn't realize that was a bot-only deal.

So, to answer question 1, I want IRC channel user modes, for all of them.
+q = chanowner, +a = chanadmin, +o = op.... the rest is known...
t
thommey
Halfop
Posts: 76
Joined: Tue Apr 01, 2008 2:59 pm

Post by thommey »

http://thommey.tclhelp.net/?page=scripts has a script (arbitrary chanmodes) that provides you with [isowner] and [isadmin] for unrealircd which is what I assume you're using. If you don't, you might need to alter the mode parsing there, what I would need to do that is the CHANMODE= and PREFIX= information that comes on connect. If you're using unrealircd it will work fine
A
AK49BWL
Voice
Posts: 7
Joined: Thu Sep 02, 2010 6:24 pm

Post by AK49BWL »

thommey wrote:http://thommey.tclhelp.net/?page=scripts has a script (arbitrary chanmodes) that provides you with [isowner] and [isadmin] for unrealircd which is what I assume you're using. If you don't, you might need to alter the mode parsing there, what I would need to do that is the CHANMODE= and PREFIX= information that comes on connect. If you're using unrealircd it will work fine

You rock. No joke. Had to figure out that the user modes needed to be re-set on the channel before the script would detect everything correctly but it very well worked!! Yes, I use UnrealIRCd, and no modifications were needed. Thanks a ton!
Post Reply