egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[SOLVED] Kick Counter
Goto page 1, 2  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
gasak
Halfop


Joined: 09 Aug 2010
Posts: 45

PostPosted: Thu Jun 28, 2012 3:23 am    Post subject: [SOLVED] Kick Counter Reply with quote

Dear Masters,

I have a huge protection tcl, and i want to add a kick counter on it. Which is it will read the kick counts from a file so that it would be an orderly counts. I tried Sir_Fz suggestion here but its not orderly counts. Different procs then it counts the new one.

Hope you can get what i mean. Thank you very much.
_________________
Learning Knows No Boundaries!!


Last edited by gasak on Fri Jun 29, 2012 12:31 am; edited 1 time in total
Back to top
View user's profile Send private message
doggo
Halfop


Joined: 05 Jan 2010
Posts: 97

PostPosted: Thu Jun 28, 2012 5:06 am    Post subject: Reply with quote

i came up with this.. tested a lil bit seems to work ok Very Happy


Code:
# 28/06/2012
# kickcount function v1.0 for eggdrop
# by doggoo #omgwtfnzbs@EFNET
# http://forum.egghelp.org/viewtopic.php?t=19012
#
# usage:
# just make all your bots KICK msgs look something like this...
# putserv "KICK $chan $who $reason - kick#: [count:kicks]"
#
# returns:
# -kick [slink] test
# * spunky has kicked [slink] from #omgwtfnzbs (test - kick#: 1)
# * [slink] (~bob@omgwtfnzbs.com) has joined #omgwtfnzbs
# -kick [slink] test
# * spunky has kicked [slink] from #omgwtfnzbs (test - kick#: 2)
#
# and so on ect...



proc count:kicks {} {

set increment_count "/path/to/kickcount.db"

if { ![file exists $increment_count] } { putlog "kickcount.db does not exist.";return }

set open_text [open $increment_count "r"]
set KICKCOUNT [read -nonewline $open_text]
close $open_text
incr KICKCOUNT

set re_open_text [open $increment_count "w"]
puts $re_open_text $KICKCOUNT
close $re_open_text

return $KICKCOUNT

}

putlog "kickcount function v1.0 loaded"


_________________
NON geeky!! http://gotcode4u.com/


Last edited by doggo on Thu Jun 28, 2012 12:26 pm; edited 5 times in total
Back to top
View user's profile Send private message Visit poster's website
gasak
Halfop


Joined: 09 Aug 2010
Posts: 45

PostPosted: Thu Jun 28, 2012 5:16 am    Post subject: Reply with quote

Hi doggoo,

What is the testkick proc for? What i need is the kcount script that will work on every kick done by the TCL.

Please advice.

Thanks
_________________
Learning Knows No Boundaries!!
Back to top
View user's profile Send private message
doggo
Halfop


Joined: 05 Jan 2010
Posts: 97

PostPosted: Thu Jun 28, 2012 5:41 am    Post subject: Reply with quote

you load this function then in all the tcl's that you use to kick, edit the kick lines to look something like this..

Code:
putserv "KICK $chan $who $reason - kick#: [count:kicks]"


cant really help you any more than that without knowing what tcl script you want to count kicks in Smile
_________________
NON geeky!! http://gotcode4u.com/
Back to top
View user's profile Send private message Visit poster's website
gasak
Halfop


Joined: 09 Aug 2010
Posts: 45

PostPosted: Thu Jun 28, 2012 5:46 am    Post subject: Reply with quote

ok ill give it a whirl. Will notify after whether work or not Smile
_________________
Learning Knows No Boundaries!!
Back to top
View user's profile Send private message
gasak
Halfop


Joined: 09 Aug 2010
Posts: 45

PostPosted: Thu Jun 28, 2012 8:01 am    Post subject: Reply with quote

Hi doggo

It works perfectly Very Happy But got some question on the kick database "kickcount.db" Why the way it store the kick count is different?

Its like this
Quote:
1340884296
1340884305


So its gonna be a huge file when it reach for example more than 100 kicks. I used to have one that works that it would replace the number on the database as the kick done on particular times. So when the kicks done already 100 so inside the data is the number 100, when 105 and it shown 105, and so on. So its always only 1 line inside since it replace the number equal the kicks done.

Hope you can understand Smile

Please advice. Thanks.
_________________
Learning Knows No Boundaries!!
Back to top
View user's profile Send private message
caesar
Ass Kicker


Joined: 14 Oct 2001
Posts: 3401
Location: Area 51

PostPosted: Thu Jun 28, 2012 9:33 am    Post subject: Reply with quote

Why not store this info in a user defined channel flag like setudef int kickCount and increment that inside your script upon a kick?
_________________
You may say anything about me, but don't misspell my name.
Back to top
View user's profile Send private message
gasak
Halfop


Joined: 09 Aug 2010
Posts: 45

PostPosted: Thu Jun 28, 2012 10:22 am    Post subject: Reply with quote

caesar wrote:
Why not store this info in a user defined channel flag like setudef int kickCount and increment that inside your script upon a kick?


how caesar?
_________________
Learning Knows No Boundaries!!
Back to top
View user's profile Send private message
doggo
Halfop


Joined: 05 Jan 2010
Posts: 97

PostPosted: Thu Jun 28, 2012 12:21 pm    Post subject: Reply with quote

edited script above to do what you want Very Happy

delete everything out of the kickcount.db and leave just a 0 in there Wink
_________________
NON geeky!! http://gotcode4u.com/
Back to top
View user's profile Send private message Visit poster's website
gasak
Halfop


Joined: 09 Aug 2010
Posts: 45

PostPosted: Thu Jun 28, 2012 12:35 pm    Post subject: Reply with quote

PERFECT!!

Thanks a lot doggo. You're the man!!

Thank you very much!
_________________
Learning Knows No Boundaries!!
Back to top
View user's profile Send private message
caesar
Ass Kicker


Joined: 14 Oct 2001
Posts: 3401
Location: Area 51

PostPosted: Fri Jun 29, 2012 12:27 am    Post subject: Reply with quote

Why do you have to write the kicks count in to a file anyway? You can easily create another kick bind that will monitor and increment the kicks count on a channel made by the bot, like this:
Code:

setudef int kickCount
bind kick * * kick:count

proc kick:count {nick uhost hand chan target reason} {
   if {![isbotnick $nick]} return
   set count [incr [channel get $chan kickCount]]
   channel set $chan kickCount $count
}

then in your script would use something like:
Code:

set count [channel get $chan kickCount]
putserv "KICK $chan $who $reason - kick#: $count"

_________________
You may say anything about me, but don't misspell my name.
Back to top
View user's profile Send private message
gasak
Halfop


Joined: 09 Aug 2010
Posts: 45

PostPosted: Thu Jul 19, 2012 12:21 pm    Post subject: Reply with quote

Hi doggo,

Sorry to bump it again, but i got some minor bugs on the kick count. The counting made is not an order list counted. I put 0 for the first time, but suddenly when the bot kick at the first time its already 13. I try again to make it kick then its correct counting to 14. And after that it jumps again to 21 for the next kick. Please advice about this minor bugs.

Thanks doggo.
_________________
Learning Knows No Boundaries!!
Back to top
View user's profile Send private message
caesar
Ass Kicker


Joined: 14 Oct 2001
Posts: 3401
Location: Area 51

PostPosted: Fri Jul 20, 2012 12:27 am    Post subject: Reply with quote

Code:

setudef int kicksCounter

proc kicks:Counter {chan} {
   set count [incr [channel get $chan kicksCounter]]
   channel set $chan kicksCounter $count
   return $count
}

putlog "kicksCounter function v1.0 loaded"

Here. Now all you have to do is to first enable the kick counter on the channel you wish with .chanset #channel +kicksCounter and instead of:
Code:

putserv "KICK $chan $who $reason - kick#: [count:kicks]"

you would need to pass the channel variable like this:
Code:

putserv "KICK $chan $who $reason - kick #[kicks:Counter $chan]"

and no more reading writing to the disk upon each kick.
_________________
You may say anything about me, but don't misspell my name.
Back to top
View user's profile Send private message
gasak
Halfop


Joined: 09 Aug 2010
Posts: 45

PostPosted: Fri Jul 20, 2012 9:18 am    Post subject: Reply with quote

caesar,

how if afterwards i want to reset the kickcounter from 0 again? What would be the command since it doesnt reading writing into disk?

Thanks.
_________________
Learning Knows No Boundaries!!
Back to top
View user's profile Send private message
caesar
Ass Kicker


Joined: 14 Oct 2001
Posts: 3401
Location: Area 51

PostPosted: Sat Jul 21, 2012 12:11 pm    Post subject: Reply with quote

Simple. Just .chanset #channel kicksCounter 0
_________________
You may say anything about me, but don't misspell my name.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber