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.

counting user messages in channel

Old posts that have not been replied to for several years.
J
Jay
Voice
Posts: 7
Joined: Thu Mar 18, 2004 3:44 pm

counting user messages in channel

Post by Jay »

hey,

I totally don't have a clue how to accomplish this.
should I use an array per user that chat's in a channel or a file ?

my goal is, to voice a user who has said eg over the 100 lines since they have joined a channel and the usercount has to be reset when the user leaves the channel.

any idea's ?
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

This should do it not tested it tho

bind on part kick quit and unset wordcount($nick)

and bind on nick and set value to new nick and unset the previous value .. nick changes basicly set and unset not that hard

Code: Select all

bind pub - "*" count:pub

set checkchan "#urchan"

proc count:pub {nick host hand chan arg} {
  global checkchan wordcount
  # could also be onchan but then it would need to be a static channel
  if {[string match -nocase $checkchan $chan]} {
     if {[info exists $nick($counter)]} {
       incr $wordcount($nick)
       if {$wordcount($nick) == "100"} {
         pushmode $chan +v $nick
       }
     } else {
       set wordcount($nick) "1"
     } 
  }
}
XplaiN but think of me as stupid
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

Ofloo wrote: and bind on nick and set value to new nick and unset the previous value .. nick changes basicly set and unset not that hard
Or easier still, use the host as the array index instead of the nick, and then you don't worry about nick changes.

Also, you want the pubm binding, not pub as already recently discussed in another topic.
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

yep true ;) hmm i gues not sur what the difference is .. manual states that its same as msgm and if i check msgm well not realy understandable for me ;) could u tell me what topic it is ??
XplaiN but think of me as stupid
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

Ofloo wrote:yep true ;) hmm i gues not sur what the difference is .. manual states that its same as msgm and if i check msgm well not realy understandable for me ;) could u tell me what topic it is ??
For one thing... pub isn't stackable... another thing, pub doesn't match against a mask....

the thread I was referring to is http://forum.egghelp.org/viewtopic.php?p=34463

BTW, Ofloo: All the news on your site is marked as '2004-04-13'....
How the heck did you get to april when the rest of us are stuck in march still... lol
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

i know its old data i imported to my new still building it ;) hehe so still got to adjust it hehe still not finished my php skills are 0 so .. working on it ..

oh crap i passed a month lol well done that when it was realy late and i hadn't noticed yet lol

and tnx for the info
XplaiN but think of me as stupid
J
Jay
Voice
Posts: 7
Joined: Thu Mar 18, 2004 3:44 pm

Post by Jay »

Tnx for you fast reply's :)

lil error in the code

Code: Select all

     if {[info exists $host{$counter)]} {

should be 

     if {[info exists $host($counter)]} {
lil question, why you use there $counter ?
that var doesn't make sense to me.

one last thing, does tcl considers part the same as quit ?
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

I believe he meant

Code: Select all

if {[info exists $nick($counter)]} { 
to be

Code: Select all

if {[info exists wordcount($nick)]} { 
however you will need to still alter that to whatever method you have now chosen to pursue... be it with the nick or the host...

And no.. part is not the same thing as quit.
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

darn its time for me to get some sleep lol
XplaiN but think of me as stupid
J
Jay
Voice
Posts: 7
Joined: Thu Mar 18, 2004 3:44 pm

Post by Jay »

I used your suggestion to work with the hostname .

I get an error : Tcl error [count:pub]: can't read "1": no such variable

this is my code

Code: Select all

bind pubm - "*" count:pub
bind part - part:pub


set checkchan "#lounge"

proc count:pub {nick host hand chan arg} {
  global checkchan wordcount
  if {[string match -nocase $checkchan $chan]} {
     if {[info exists wordcount($host)]} {
       incr $wordcount($host)
       if {$wordcount($host) == "50"} {
         pushmode $chan +v $nick
       }
     } else {
       set wordcount($host) 1
     }
  }
}

proc part:pub {nick host arg} {
        unset wordcount($host)
}

and how to bind it to a quit?
cause in tcl-documentation in the doc dir of the eggdrop I can't find it.
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

[quote="Jay"] incr $wordcount($host)
[/code]

Is the culprit generating the error... should be:

Code: Select all

incr wordcount($host)
See the tcl-commands.doc that comes with eggdrop for valid bind types.
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

i think part and quit are the same if they aren't then use raw and use string match for quit
bind part <flags> <mask> <proc>
procname <nick> <user@host> <handle> <channel> <msg>
<msg> = i think that refers to the quit msg ..

oh yes btw what does "stackable" mean ?? thats the key word i didn't understand .. hehe
XplaiN but think of me as stupid
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

Ofloo wrote:i think part and quit are the same if they aren't then use raw and use string match for quit
bind part <flags> <mask> <proc>
procname <nick> <user@host> <handle> <channel> <msg>
<msg> = i think that refers to the quit msg ..

oh yes btw what does "stackable" mean ?? thats the key word i didn't understand .. hehe
No, there is a specific binding already for quits.... starts with "s"... see tcl-commands.doc as I stated.

stackable means that the type of bind can be bound to more than once to a single trigger.
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

bind sign <flags> <mask> <proc>
procname <nick> <user@host> <handle> <channel> <reason>
You mean this ??


stackable: sorry just wana make sur hehe

* you mean by more then one bind that u can define more then one bind for the same proc ..? and argument 0 would be the trigger it self ??

ah i think i get it its use full when u make a trigger that has multiple options
XplaiN but think of me as stupid
J
Jay
Voice
Posts: 7
Joined: Thu Mar 18, 2004 3:44 pm

Post by Jay »

I'm getting this error, how to solve ?

Code: Select all

Tcl error [part:pub]: can't read "wordcount(ident@host)": no such element in array
my code

Code: Select all

proc part:pub {nick host handle channel partmsg} {
        global wordcount checkchan
        if {[string match -nocase $checkchan $chan]} {
                putserv "PRIVMSG $checkchan :counter reset of $wordcount($host)"
                unset wordcount($host)
        }
}
BTw the S word ? SIGN ya mean ? looked over it, sorry
Locked