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.

looking for this word counting script that auto voices.

Old posts that have not been replied to for several years.
Locked
M
Mystery-X
Voice
Posts: 10
Joined: Sun Apr 25, 2004 5:49 pm

looking for this word counting script that auto voices.

Post by Mystery-X »

Hi i'm looking for a script that counts the words that a chatter says
like this : Hello i'm john
this would give an count of 3
When it reaches 500 words not sentenses it rewards the user with an +voice.
And including an commands so i can request how many words remaining beforce +voice.
And including an anti idle script so if an user idles 10min it will lose it's +voice

Anyone that can help me?
Sorry for my bad english

Greetz Mystery-X
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

I was bored, so I gave it a shot...I tested it once, so I guess it'll work :P
The script keeps track of people by their complete user@host, so it may become a bit confused if the people competing for voice are clones ;P

Code: Select all

namespace eval talkIsCheap {

	# When a person has spoken 500 words without being idle
	# for more than 10 minutes, he/she is rewarded a voice.
	# The voice is lost if idle for more than 10 minutes.
	# - Unless you change the following settings:
	variable limit 500;# words
	variable idle 10;# minutes
	
	# change the mask or add more binds if you need it to
	# work in other channels:
	bind pubm - "#get_clue *" [namespace current]::count
	
	# public command to get the number of words left for
	# yourself or the given person:
	bind pub - !wordsLeft [namespace current]::wordsLeft

	# the timer checking for idlers
	bind time - * [namespace current]::devoice
	
	# variable for keeping track of user counts
	variable count
	
	# the counting proc (called when someone speaks)
	proc count {n u h c s} {
		variable limit
		variable count
		if {[isvoice $n $c]||[isop $n $c]} {
			if {[info exists count($c,$u)]} {set count($c,$u) [clock sec],$limit}
			return
		}
		if {[info exists count($c,$u)]} {scan $count($c,$u) %*i,%i a} {set a 0}
		set a [expr {$a+1+[regexp -all {[ \t,]+} $s]}]
		if {$a>=$limit} {
			set count($c,$u) [clock sec],$limit
			pushmode $c +v $n
		} {
			set count($c,$u) [clock sec],$a
		}
	}
	
	# the devoice proc (run once every minute)
	proc devoice args {
		variable idle
		variable count
		set t [expr {[clock sec]-$idle*60}]
		foreach {e v} [array get count] {
			if {[scan $v %i]<$t} {
				unset count($e)
				scan $e {%[^,],%s} c u
				if {![validchan $c]} continue
				foreach n [chanlist $c] {
					if {[getchanhost $n $c]==$u&&[isvoice $n $c]&&![isop $n $c]} {
						pushmode $c -v $n
					}
				}
			}
		}
	}
	
	# the public counter display (by user request)
	proc wordsLeft {n u h c a} {
		if {$a!=""} {
			if {[onchan $a $c]} {
				set n $a
				set u [getchanhost $n $c]
			} else return
		}
		variable count
		if {![isvoice $n $c]&&[info exists count($c,$u)]} {
			variable limit
			set words [expr {$limit-[scan $count($c,$u) %*i,%i]}]
			set s [expr {$words==1?"":"s"}]
			puthelp "PRIVMSG $c :$n has to speak $words more word$s to get voiced."
		}
	}

}
Last edited by user on Tue May 04, 2004 2:50 am, edited 1 time in total.
Have you ever read "The Manual"?
M
Mystery-X
Voice
Posts: 10
Joined: Sun Apr 25, 2004 5:49 pm

Post by Mystery-X »

thx for this script, only one question.
i've got this error

[07:49] <[myteddy]> [07:49] Tcl error [::talkIsCheap::count]: missing close-bracket

i don't got a clue what it is :$

Greetz Mystery-X
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

there was a missing ] (fixed now)
Have you ever read "The Manual"?
M
Mystery-X
Voice
Posts: 10
Joined: Sun Apr 25, 2004 5:49 pm

Post by Mystery-X »

i used !wordsLeft but don't seems to work?
my channel is myteddy and is there a way to change command?
what i'm i doing wrong?

Greetz Mystery-X
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Did you change the bind before loading the script? (to "#myteddy *") Did you talk before doing '!wordsLeft'? (doing the command doesn't count as talking) Changing the command is as easy as changing the bind and restarting your bot.

The script doesn't answer if there's no record of you speaking in the last X minutes. And it only keeps track of words spoken in channels matching the bind mask. I was under the impression this was for a particular channel, but you can change the mask to "*" if you want the script to work in all channels or add more binds if you want several channels but not all.
Have you ever read "The Manual"?
M
Mystery-X
Voice
Posts: 10
Joined: Sun Apr 25, 2004 5:49 pm

Post by Mystery-X »

I made this of it:

Code: Select all

namespace eval talkIsCheap { 

   # When a person has spoken 500 words without being idle 
   # for more than 10 minutes, he/she is rewarded a voice. 
   # The voice is lost if idle for more than 10 minutes. 
   # - Unless you change the following settings: 
   variable limit 500;# words 
   variable idle 10;# minutes 
    
   # change the mask or add more binds if you need it to 
   # work in other channels: 
   bind pubm - "*" [namespace current]::count 
    
   # public command to get the number of words left for 
   # yourself or the given person: 
   bind pub - !words [namespace current]::wordsLeft 

   # the timer checking for idlers 
   bind time - * [namespace current]::devoice 
    
   # variable for keeping track of user counts 
   variable count 
    
   # the counting proc (called when someone speaks) 
   proc count {n u h c s} { 
      variable limit 
      variable count 
      if {[isvoice $n $c]||[isop $n $c]} { 
         if {[info exists count($c,$u)]} {set count($c,$u) [clock sec],$limit} 
         return 
      } 
      if {[info exists count($c,$u)]} {scan $count($c,$u) %*i,%i a} {set a 0} 
      set a [expr {$a+1+[regexp -all {[ \t,]+} $s]}] 
      if {$a>=$limit} { 
         set count($c,$u) [clock sec],$limit 
         pushmode $c +v $n 
      } { 
         set count($c,$u) [clock sec],$a 
      } 
   } 
    
   # the devoice proc (run once every minute) 
   proc devoice args { 
      variable idle 
      variable count 
      set t [expr {[clock sec]-$idle*60}] 
      foreach {e v} [array get count] { 
         if {[scan $v %i]<$t} { 
            unset count($e) 
            scan $e {%[^,],%s} c u 
            if {![validchan $c]} continue 
            foreach n [chanlist $c] { 
               if {[getchanhost $n $c]==$u&&[isvoice $n $c]&&![isop $n $c]} { 
                  pushmode $c -v $n 
               } 
            } 
         } 
      } 
   } 
    
   # the public counter display (by user request) 
   proc wordsLeft {n u h c a} { 
      if {$a!=""} { 
         if {[onchan $a $c]} { 
            set n $a 
            set u [getchanhost $n $c] 
         } else return 
      } 
      variable count 
      if {![isvoice $n $c]&&[info exists count($c,$u)]} { 
         variable limit 
         set words [expr {$limit-[scan $count($c,$u) %*i,%i]}] 
         set s [expr {$words==1?"":"s"}] 
         puthelp "PRIVMSG $c :$n has to speak $words more word$s to get voiced." 
      } 
   } 

}
even setting bind pubm - "*" [namespace current]::count
to bind pubm - "#myteddy *" [namespace current]::count
didn't work, what i'm i doing wrong.

loading the script in eggdrop on shell with
source scripts/talkIsCheap.tcl



Greetz Mystery-X
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

<snip>
XplaiN but think of me as stupid
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

No error?

Post by user »

I tried the script once more now and it seems to work just fine. Are you running any other scripts that might be blocking the messages? Check '.binds pubm' to verify that the bind is created and that the hitcount is over 0. And make sure you speak some words (after loading the script) before trying the trigger. :wink:
Have you ever read "The Manual"?
M
Mystery-X
Voice
Posts: 10
Joined: Sun Apr 25, 2004 5:49 pm

Post by Mystery-X »

This is what i do and what i get :

Code: Select all

[07:42] <[Sp4wn]> testing 1 2 3
[07:42] <[Sp4wn]> testing 1 2 3
[07:42] <[Sp4wn]> bla bla bla
[07:42] <[Sp4wn]> !words [Sp4wn]
[07:42] <[Sp4wn]> !words
[07:44] <[Sp4wn]> !words
[07:44] <[Sp4wn]> !words
[07:44] <[Sp4wn]> !words
[07:44] <[Sp4wn]> !words
[07:45] <[Sp4wn]> bla bla bla
[07:45] <[Sp4wn]> bla bla bla
[07:45] <[Sp4wn]> bla bla bla
[07:45] <[Sp4wn]> bla bla bla
[07:47] <[Sp4wn]> bla bla bla
[07:47] <[Sp4wn]> bla bla bla
[07:47] <[Sp4wn]> bla bla bla

Code: Select all

[07:47] <[myteddy]> [07:47] #[Sp4wn]# binds pub*
[07:47] <[myteddy]> Command bindings:
[07:47] <[myteddy]>   TYPE FLGS     COMMAND              HITS BINDING (TCL)
[07:47] <[myteddy]>   pub  -|-      !seen                   0 pub_seen
[07:47] <[myteddy]>   pub  -|-      !asl                    0 asl_search
[07:47] <[myteddy]>   pub  o|-      !asldel                 0 asl_del
[07:47] <[myteddy]>   pub  o|-      !asladd                 0 asl_add
[07:47] <[myteddy]>   pub  -|-      !lijst                  0 pub_list
[07:47] <[myteddy]>   pub  o|o      !zwijg                  0 pub_shutup
[07:47] <[myteddy]>   pub  o|o      !spreek                 0 pub_speak
[07:47] <[myteddy]>   pub  o|o      !vergeet                0 pub_forget
[07:47] <[myteddy]>   pub  o|o      !leer                   0 pub_teach
[07:47] <[myteddy]>   pub  -|-      !words                  6 ::talkIsCheap::wordsLeft
[07:47] <[myteddy]>   pubm -|-      *                       3 pubm_search
[07:47] <[myteddy]>   pubm -|-      *                      10 ::talkIsCheap::count
Loaded scripts are :

Code: Select all

source scripts/alltools.tcl
source scripts/action.fix.tcl
source scripts/teach.tcl
source scripts/asl.tcl
source scripts/seen5.5.4.tcl
# source scripts/mc.idledemode.tcl
# source scripts/count.tcl
source scripts/talkIsCheap.tcl
what am I doing wrong :( do.
I also tried

Code: Select all

source scripts/alltools.tcl
source scripts/action.fix.tcl
# source scripts/teach.tcl
# source scripts/asl.tcl
# source scripts/seen5.5.4.tcl
# source scripts/mc.idledemode.tcl
# source scripts/count.tcl
source scripts/talkIsCheap.tcl
If ya need mor info, just ask ;)
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

I don't get it...it should work. Are you by any chance +v/+o in the channel you're testing it from? The script doesn't count words spoken by +v/+o users.
Have you ever read "The Manual"?
M
Mystery-X
Voice
Posts: 10
Joined: Sun Apr 25, 2004 5:49 pm

Post by Mystery-X »

thx i've go it working :p
It was becaus i was an +o
How can i set it, that the command needs to be said private @ the bot and that the bot answers private?

Greetz Mystery-X
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Replace the wordsLeft proc and add the msg bind:

Code: Select all

bind msg - !words [namespace current]::wordsLeft
bind pub - !words [namespace current]::wordsLeft

proc wordsLeft {n u h args} {
	variable count
	variable limit
	if {[scan [join $args] %s%s c t]<1||![validchan $c]} return
	if {[info exists t]} {set u [getchanhost $t]} {set t $n}
	if {![onchan $t $c]||![info exists count($c,$u)]||[isvoice $t $c]} return
	set i [expr {$limit-[scan $count($c,$u) %*i,%i]}]
	puthelp "PRIVMSG $n :[expr {$n==$t?"You have":"$t has"}] $i word[expr {$i==1?"":"s"}] to go."
}
When requesting the count by private message, the first argument must be a channel name...
'/msg #chan !words ?nick?' or '/msg bot !words #chan ?nick?'
I hate helpful error messages, so, as you've seen, if you screw up, the script will give you the silent treatment :P
Have you ever read "The Manual"?
Locked