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 

New regular user alert

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
BigToe
Halfop


Joined: 30 Dec 2010
Posts: 99

PostPosted: Wed Jan 23, 2013 7:26 am    Post subject: New regular user alert Reply with quote

hi - i am looking for a script that for each user it will count the total amount of time he was in that certain channel, it can also be viewed with
!timespent <nickname> <#channel>

Every time a user has spent more than a certain amount of time in a channel (set by the user), the script will send a message to that channel stating:

*Nickname* has spent over 10 hours (the certain amount of time set by the user) in this channel and is now considered a regular user and is added to the db

the user is added to the db.

the script will never alert about that user again.

an initial database of regular users can be added manually by the user
Back to top
View user's profile Send private message
Madalin
Master


Joined: 24 Jun 2005
Posts: 310
Location: Constanta, Romania

PostPosted: Sat Jan 26, 2013 3:47 pm    Post subject: Reply with quote

Informations are saved by $chan,$host
if you restart the eggdrop you never loose any informations

Sorry for my bad english (its not my native language so live with it) Smile

set announce(time) "1" ;#in hours

- So if you set it to '1' it will announce (only once for each user) the user that spent atleast that time on the channel

Code:

#### ++++ Author: MadaliN <madalinmen28@yahoo.com>
### ++++ TCL Name: Timespent
## ++++
# Commands:
#   !timespent activate         (local or global owner)
#   !timespent deactivate         (local or global owner)
#   !timespent <$nickname> <$chan>      (local or global owner)
#

####
# +++ Created: 1/26/2013
####

bind TIME - * egghelp:timespent

bind PUB - !timespent timespent:pub

set announce(time) "1" ;#setting is in hours

setudef flag timespent

proc egghelp:timespent {min hour day month year} {
   global timespent announce noa

   set list ""
   foreach chan [channels] {
      if {[channel get $chan timespent]} {
         foreach u [chanlist $chan] {

            set host [lindex [split [getchanhost $u $chan] @] 1]

            if {![info exists timespent($chan,$host)]} {
               set timespent($chan,$host) "60 $u"
               timespent:save
            } else {
               set timespent($chan,$host) "[expr [lindex [split $timespent($chan,$host)] 0] + 60] $u"
               timespent:save

               if {$announce(time) != ""} {
                  if {[lindex [split $timespent($chan,$host)] 0] > [expr $announce(time) * 3600]} {
                     if {![info exists noa($chan,$host)]} {
                        set noa($chan,$host) "[unixtime]"
                        timespent:save

                        lappend list "\00303[lindex [split $timespent($chan,$host)] 1]\003"
                     }
                  }
               }
            }
         }
         if {$list != ""} {
            putserv "PRIVMSG $chan :Users who spent more than \00312$announce(time)\003 hour    on \00304$chan\003 are: [join $list "\002,\002 "]"
         }
      }
   }
}

proc timespent:pub {nick uhost hand chan arg} {
   global timespent

   set host [lindex [split [getchanhost [lindex [split $arg] 0] $chan] @] 1]

   switch -exact -- [lindex [split $arg] 0] {
      activate {
         if {[matchattr $hand n] || [matchattr $hand |N $chan]} {
            channel set $chan +timespent

            putserv "PRIVMSG $chan :\002$nick\002 - TIMESPENT script \00312activated\003 succesfully"
         }
      }
      deactivate {
         if {[matchattr $hand n] || [matchattr $hand |N $chan]} {
            channel set $chan -timespent

            putserv "PRIVMSG $chan :\002$nick\002 - TIMESPENT script \00304deactivated\003 succesfully"
         }
      }
      default {
         if {[matchattr $hand n] || [matchattr $hand |N $chan]} {

            if {[string match -nocase "#*" [lindex [split $arg] 1]]} {
               if {![info exists timespent([lindex [split $arg] 1],$host)]} {
                  putserv "PRIVMSG $chan :\002$nick\002 - Nickname \00303[lindex [split $arg] 0]\003 has no info on \00312[lindex [split $arg] 1]"
               } else {
                  putserv "PRIVMSG $chan :\002$nick\002 - Nickname \00303[lindex [split $arg] 0]\003 idled on \00312[lindex [split $arg] 1]\003 for \00303[duration [lindex [split $timespent([lindex [split $arg] 1],$host)] 0]]"
               }
            } else {
               if {![info exists timespent($chan,$host)]} {
                  putserv "PRIVMSG $chan :\002$nick\002 - Nickname \00303[lindex [split $arg] 0]\003 has no info on this channel"
               } else {
                  putserv "PRIVMSG $chan :\002$nick\002 - Nickname \00303[lindex [split $arg] 0]\003 idled on \00312$chan\003 for \00303[duration [lindex [split $timespent($chan,$host)] 0]]"
               }
            }
         }
      }
   }
}

proc timespent:save {} {
   global timespent

   set ofile [open timespent w]
   puts $ofile "array set timespent [list [array get timespent]]"
   close $ofile
}

catch {source timespent}

putlog "+++ Succesfully loaded: \00312Timpespent TCL Script"

_________________
https://github.com/MadaliNTCL - To chat with me: https://tawk.to/MadaliNTCL


Last edited by Madalin on Sat Jan 26, 2013 6:14 pm; edited 5 times in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
BigToe
Halfop


Joined: 30 Dec 2010
Posts: 99

PostPosted: Sat Jan 26, 2013 5:00 pm    Post subject: Reply with quote

What you mean by first version?
Back to top
View user's profile Send private message
Madalin
Master


Joined: 24 Jun 2005
Posts: 310
Location: Constanta, Romania

PostPosted: Sat Jan 26, 2013 5:01 pm    Post subject: Reply with quote

Well it is the first version maybe it has some bugs maybe it will need some more commands to be added etc Smile thats why is the first version. Just test this (i know i did) and see if it works.
_________________
https://github.com/MadaliNTCL - To chat with me: https://tawk.to/MadaliNTCL
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
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