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.

Checking every xx Minutes channel and Count Users

Help for those learning Tcl or writing their own scripts.
Post Reply
e
erderiko
Voice
Posts: 2
Joined: Tue Feb 16, 2016 2:23 pm

Checking every xx Minutes channel and Count Users

Post by erderiko »

Hello I want to create a TCL Script for my eggodrop 1.6.

I want to create a timer that every xx minutes loop over nicks in channel
and count users with specific realname and write it to a file.

Code: Select all

foreach nick [chanlist $chan] {
  if {match nick!REALNAME "mibbit"}{
		count++
  }
};
How can I do this i readed some documents and found nothing about realname. I can count on host but how can I do this on realname?
e
erderiko
Voice
Posts: 2
Joined: Tue Feb 16, 2016 2:23 pm

Post by erderiko »

Code: Select all

bind time - "?5 *" checknicks ; #every 10 min
bind RAW - 311 checkrealname


set mibbit 0
set total 0


proc checknicks {args} {     
	global mibbit  total
    set chan "#chan"  
	set file "stats.txt"
	set time_now		[clock seconds]
	set time_formated	[clock format $time_now -format {%Y-%m-%d %H:%M:%S} -gmt true]
	set fs [open $file a+] 
	puts $fs "$time_formated;$mibbit;$total" 
	close $fs
	set mibbit 0

	
	putlog "perform checknick"
	foreach nick [chanlist $chan] {
		putquick "WHOIS $nick $nick"
	}          
    return 1                           
}

proc checkrealname { from keyword arguments } {
	global  mibbit total
	set fullname [string range [join [lrange $arguments 5 end]] 1 end]

	set realname3 "*www.mibbit.com*"

	if {[string match $realname3 $fullname]} {		
		incr kiwi
	}

	incr total
}


putlog "CheckNicks is loaded"
I'v solved by the above code but It only counts 300 nicknames how can I increase the queue?
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

Wow, you have a channel with over 300 users?
GoodJob on the channel:)
Not so much with the script...
erderiko wrote:I'v solved by the above code but It only counts 300 nicknames how can I increase the queue?
The short answer is: Increase the time between each of the calls to proc checknicks

The longer explanation is:
The default for sending lines to the server from all eggdrop queues is "every 2 seconds".
10 minutes is 600 seconds (10 * 60 = 600)....
300 sends from queue is also 600 seconds (300 * 2 = 600)...

At that point, the 10 minutes expires, the proc checknicks runs again, the file is saved with the current count (300) and the count is reset to zero (0).
The counting then starts incrementing from 0 again, as the putquick queue grows in size some (it never has a chance to empty before filling it again).

Some notes about this entire script idea...
Any bot running this script will have no time to do anything else as its putquick queue will always be full/overfull.
After the script runs for a while, the putquick queue will get bigger with every new 10 minute call to proc checknicks, and the bot will probably die.

And what's this line of code all about?

Code: Select all

      incr kiwi
judging by the rest of the code, you mean

Code: Select all

      incr mibbit
Also looks like $total never gets reset back to 0 and would just keep getting larger with every new write to the file.

There may be other scripting issues I haven't noticed yet...

Closing thoughts: I don't think it's a good idea to have a bot pounding the server every 2 seconds for the entire time it's connected.
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Why don't you use /WHO #channel instead of whois-ing each individual user?

You get a reply in raw 352 with results and raw 315 is triggered when the list ends.
Once the game is over, the king and the pawn go back in the same box.
Post Reply