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.

Make Join count for ALL users

Old posts that have not been replied to for several years.
Locked
User avatar
Thunderdome
Op
Posts: 187
Joined: Tue Mar 15, 2005 4:42 pm

Make Join count for ALL users

Post by Thunderdome »

Code: Select all

# Join counter by Turbo-
# Version 2.4
# DCC Commands:
# .+join <number> - (Owner) To increase the amount of joins.
# .-join <number> - (Owner) To decrease the amount of joins.
# .joins [nick] - (Friends) To see the current count. And see counts of others
# .countnotice <on/off> - (Masters) To turn the on-join notice on/off.
# Pub Commands:
# !joins [nick] - (Friends) To see the current count. And see counts of others

# EMail milesp@connect.ab.ca, and tell me some bugs or fixes.  hell, send
# comments if ya want. you can find me in #Consortium on EFNet too by the
# way...my bot is proof this script works :P

### Fixed from 1.0:
# -Everything got fixed!  Nothing worked!
### Fixed from 1.1:
# -The conformation didnt work quite right
### Fixed from 1.2:
# -.+join and .-join are fixed
# -Only notices you if you join the channel specified in countchan
### Fixed from 1.3:
# -That annoying can't find 'startcountdate' error
### Changed from 1.4:
# -The conformation looks nicer
### Added from 1.5:
# -Now counts how many times each user has joined
# -Its still only, a single channel TCL =(
### Fixed from 2.0:
# -It used to add 2 joins for the first join, its fixed now
### Added from 2.1:
# -You can use !joins, and .joins to view others join stats
# -The conformation said that version 2.1 was 2.0, its fixed now
### Added from 2.2:
# -You can use the .+join and .-join to change certain users stats
### Fixed from 2.3:
# -The user-get and user-set and all that stuff is fixed

# As far as I've tested, this script works for eggdrop1.0x, eggdrop1.1.x,
# eggdrop1.2.x, and eggdrop1.3.x, I have recently updated it it and made
# v2.4, it works with 1.3.x now, I tested it on a bot owned by george11,
# thanx man.

#### VARIABLES, GO AHEAD, CHANGE EM, BUT READ THE QUOTES ABOVE THEM ####
 
# Your eggdrop's main version.  If your bot is 1.1.5, the ver is 1.1
# 1.1.x is 1.1 --- 1.2.x is 1.2 --- 1.3.x is 1.3
set eggver "1.3"

# File to save the join number too
set what_file "joins.dat"

# If you change 'what_file', make sure that filename is the same in start_var is the same!
set start_var "[open joins.dat r]"

# Wether or not to send a notice with the current count to the person joining
set donotice "on"

# Date you start this script
set startcountdate "April 11th 2004"

# The channel this bot rests on, damn TCL, only one channel tho 
# (NO CAPITALS)
set countchan "#thunderdome"

###### BINDS ## DONT TOUCH ######

bind dcc n -join take_joins
bind dcc n +join add_joins
bind dcc f joins how_many
bind join - "*" counterj
bind pub f !joins pub_many
bind dcc m countnotice on_off_notice

######## ACTUAL SCRIPT! DONT CHANGE! ########

# If you eggdrop1.2 or 1.3, you probably dont have user-get
if {[lsearch -exact [strlwr [info commands]] [strlwr user-get]] == -1} {
proc user-get {handle key} {
  set xtra [getxtra $handle]
  for {set i 0} {$i < [llength $xtra]} {incr i} {
    set this [lindex $xtra $i]
    if {[string compare [lindex $this 0] $key] == 0} {
      return [lindex $this 1]
    }
  }
  return ""   
}
}

# If you are eggdrop1.2 or 1.3, you probably dont have user-set either
if {[lsearch -exact [strlwr [info commands]] [strlwr user-set]] == -1} {
proc user-set {handle key data} {
  set xtra [getxtra $handle]
  # is key already there?
  for {set i 0} {$i < [llength $xtra]} {incr i} {
    set this [lindex $xtra $i]
    if {[string compare [lindex $this 0] $key] == 0} {
      set this [list $key $data]
      setxtra $handle [lreplace $xtra $i $i $this]
      return 
    }
  }
  lappend xtra [list $key $data]
  setxtra $handle $xtra
}
}

# If the join file doesnt exist, make one
if {![file exists $what_file]} {
    set WhatFile [open $what_file w]
    puts $WhatFile "1"
    close $WhatFile
}

# The join section for counting joins
proc counterj {nick uhost hand chan} {
global what_file donotice startcountdate countchan monthj eggver
    # Change the main file
    set joinedchan "[string tolower $chan]"
    if {$countchan != $joinedchan} {
      return 0
    }
    set WhatFile "[open $what_file r]"
    while {![eof $WhatFile]} {
	set joinsnum "[gets $WhatFile]"
    close $WhatFile
    set WhatFile "[open $what_file w]"
    puts $WhatFile "[expr $joinsnum + 1]"
    close $WhatFile
    set WhatFile "[open $what_file r]"
    while {![eof $WhatFile]} {
	set joinsnum "[gets $WhatFile]"
    close $WhatFile
    # Single user statistics
    if {[validuser $hand] == 1} {
     if {$eggver == "1.1" || $eggver == "1.2"} {
      if {[user-get $hand joins] == ""} {
        user-set $hand joins 0
      }}
     if {$eggver == "1.3" } {
      if {[getuser $hand xtra joins] == ""} {
        setuser $hand xtra joins 0
      }}
     }
      if {$eggver == "1.1" || $eggver == "1.2"} {
        if {[user-get $hand date] == ""} {
        # I'm a perfectionist :P  Gotta get that damn date right! =)
        set joindate "[date]"
        set datej "[lindex $joindate 0]"
        set monthj "[lindex $joindate 1]"
        set yearj "[lindex $joindate 2]"
        if {$monthj=="Jan"} { set monthj "January" }
        if {$monthj=="Feb"} { set monthj "February" }
        if {$monthj=="Mar"} { set monthj "March" }
        if {$monthj=="Apr"} { set monthj "April" }
        if {$monthj=="May"} { set monthj "May" }
        if {$monthj=="Jun"} { set monthj "June" }
        if {$monthj=="Jul"} { set monthj "July" }
        if {$monthj=="Aug"} { set monthj "August" }
        if {$monthj=="Sep" || $monthj=="Sept"} { set monthj "September" }
        if {$monthj=="Oct"} { set monthj "October" }
        if {$monthj=="Nov"} { set monthj "November" }
        if {$monthj=="Dec"} { set monthj "December" }
        set jdate "$monthj $datej $yearj"
        }
        if {$eggver == "1.3"} {
        if {[getuser $hand xtra date] == ""} {
        # I'm a perfectionist :P  Gotta get that damn date right! =)
        set joindate "[date]"
        set datej "[lindex $joindate 0]"
        set monthj "[lindex $joindate 1]"
        set yearj "[lindex $joindate 2]"
        if {$monthj=="Jan"} { set monthj "January" }
        if {$monthj=="Feb"} { set monthj "February" }
        if {$monthj=="Mar"} { set monthj "March" }
        if {$monthj=="Apr"} { set monthj "April" }
        if {$monthj=="May"} { set monthj "May" }
        if {$monthj=="Jun"} { set monthj "June" }
        if {$monthj=="Jul"} { set monthj "July" }
        if {$monthj=="Aug"} { set monthj "August" }
        if {$monthj=="Sep" || $monthj=="Sept"} { set monthj "September" }
        if {$monthj=="Oct"} { set monthj "October" }
        if {$monthj=="Nov"} { set monthj "November" }
        if {$monthj=="Dec"} { set monthj "December" }
        }
        if {$eggver == "1.1" || $eggver == "1.2"} {
          user-set $hand date $jdate
        }
        if {$eggver == "1.3"} {
          setuser $hand xtra date $jdate       
        }
      }
      if {$eggver == "1.1" || $eggver == "1.2"} {
      if {[user-get $hand date] != "" && [user-get $hand joins] != ""} {
        set pjoins [user-get $hand joins]
        set njoins [expr $pjoins + 1]
        user-set $hand joins $njoins
        set newjoins [user-get $hand joins]
        set ldate [user-get $hand date]
        if {$donotice=="on"} {
          putserv "NOTICE $nick :5(INFO): 4,5You are gabber number0,5 $joinsnum 4,5to join $chan since $startcountdate, and you've joined0,5 $newjoins 4,5times since $ldate"
          return 0
        }
      }}
      if {$eggver == "1.3"} {
      if {[getuser $hand xtra date] != "" && [getuser $hand xtra joins] != ""} {
        set pjoins [getuser $hand xtra joins]
        set njoins [expr $pjoins + 1]
        setuser $hand xtra joins $njoins
        set newjoins [getuser $hand xtra joins]
        set ldate [getuser $hand xtra date]
        if {$donotice=="on"} {
          putserv "NOTICE $nick :5(INFO): 4,5You are gabber number0,5 $joinsnum 4,5to join $chan since $startcountdate, and you've joined0,5 $newjoins 4,5times since $ldate"
          return 0
        }
      }}
    }
    # Non-user join
    if {$donotice=="on"} {
      putserv "NOTICE $nick :5(INFO): 4,5You are gabber number0,5 $joinsnum 4,5to join $chan since $startcountdate"
      return 0
    }
    return 0
  }
 }
}

# The dcc .joins command section
proc how_many {hand idx arg} {
global what_file countchan startcountdate eggver
if {$arg==""} {
putlog "#$hand# joins"
set WhatFile [open $what_file r]
    while {![eof $WhatFile]} {
        set dccjoinsnum "[gets $WhatFile]"
    close $WhatFile
if {$eggver == "1.1" || $eggver == "1.2"} {
set dccnewjoins [user-get $hand joins]
set dccldate [user-get $hand date]
}
if {$eggver == "1.3"} {
set dccnewjoins [getuser $hand xtra joins]
set dccldate [getuser $hand xtra date]
}
putdcc $idx "There have been $dccjoinsnum joins in $countchan since $startcountdate, and you've joined $dccnewjoins times since $dccldate"
return 0
} }
if {$arg != ""} {
  if {[validuser $arg] == 0} {
    putdcc $idx "$arg is an invalid username"
    return 0
  }
  putlog "#$hand# joins $arg"
  set WhatFile [open $what_file r]
  while {![eof $WhatFile]} {
    set dccjoinsnum "[gets $WhatFile]"
  close $WhatFile
if {$eggver == "1.1" || $eggver == "1.2"} {
set dccnewjoins [user-get $arg joins]
set dccldate [user-get $arg date]
}
if {$eggver == "1.3"} {
set dccnewjoins [getuser $arg xtra joins]
set dccldate [getuser $arg xtra date]
}
putdcc $idx "There have been $dccjoinsnum joins in $countchan since $startcountdate, and $arg has joined $dccnewjoins times since $dccldate"
return 0
} }
}

# The public !joins command section
proc pub_many {nick uhost hand chan rest} {
global what_file startcountdate countchan eggver
    set joinedchan2 [string tolower $chan]
    if {$countchan != $joinedchan2} {
      return 0
    }
if {$rest == ""} {
set WhatFile [open $what_file r]
    while {![eof $WhatFile]} {
        set pubjoinsnum "[gets $WhatFile]"
    close $WhatFile
if {$eggver == "1.1" || $eggver == "1.2"} {
set pubnewjoins [user-get $hand joins]
set publdate [user-get $hand date]
}
if {$eggver == "1.3"} {
set pubnewjoins [getuser $hand xtra joins]
set publdate [getuser $hand xtra date]
}
putserv "NOTICE $nick :There have been $pubjoinsnum joins in $chan since $startcountdate, and you've joined $pubnewjoins times since $publdate"
putcmdlog "<<$nick>> !$hand! !joins"
return 0
} }
if {$rest != ""} {
if {[validuser $rest] == 0} {
putserv "NOTICE $nick :$rest is an invalid username"
return 0
}
set WhatFile [open $what_file r]
    while {![eof $WhatFile]} {
        set pubjoinsnum "[gets $WhatFile]"
    close $WhatFile
if {$eggver == "1.1" || $eggver == "1.2"} {
set pubnewjoins [user-get $rest joins]
set publdate [user-get $rest date]
}
if {$eggver == "1.3"} {
set pubnewjoins [getuser $rest xtra joins]
set publdate [getuser $rest xtra date]
}
putserv "NOTICE $nick :There have been $pubjoinsnum joins in $chan since $startcountdate, and $rest has joined $pubnewjoins times since $publdate"
putcmdlog "<<$nick>> !$hand! !joins $rest"
return 0
} }
}

# Adds joins to total count, and other user stats
proc add_joins {hand idx arg} {
global what_file eggver
    if {$arg==""} {
      putdcc $idx "Usage: +join \[user\] <# to add>"
      return 0
    }
    set a1 "[lindex $arg 0]"
    set a2 "[lindex $arg 1]"
    if {$a2 == ""} {
    putlog "#$hand# +join"
    if {$arg<0 || $arg>100} {
      putdcc $idx "$arg is out of my range, sorry!"
      return 0
    }
    set amntadd "$arg"
    set WhatFile [open $what_file r]
    while {![eof $WhatFile]} {
        set addjoinsnum "[gets $WhatFile]"
    close $WhatFile
    putdcc $idx "Old total $addjoinsnum"
    putdcc $idx "Adding $amntadd"
    set WhatFile [open $what_file w]
    puts $WhatFile [expr $addjoinsnum + $amntadd ]
    close $WhatFile
    set WhatFile [open $what_file r]
    while {![eof $WhatFile]} {  
        set addjoinsnum "[gets $WhatFile]"
    close $WhatFile   
    putdcc $idx "New total is $addjoinsnum"
    return 0
   }
  }
 }
    if {$a2 != ""} {
      if {$a1 != ""} {
        if {[validuser $a1] == 0} {
        putdcc $idx "$a1 is an invalid username"
        return 0
      }
      if {$a2<0 || $a2>100} {
      putdcc $idx "$a2 is out of my range, sorry!"
      return 0
    }
      putlog "#$hand# +join $a1"
      if {$eggver == "1.1" || $eggver == "1.2"} {
      set oldj "[user-get $a1 joins]"
      putdcc $idx "Old total for $a1 $oldj"
      putdcc $idx "Adding $a2 to $a1"
      set newj "[expr $oldj + $a2]"
      user-set $a1 joins $newj
      set newj2 "[user-get $a1 joins]"
      putdcc $idx "New total for $a1 is $newj2"
      return 0
      }
      if {$eggver == "1.3"} {
      set oldj "[getuser $a1 xtra joins]"
      putdcc $idx "Old total for $a1 $oldj"
      putdcc $idx "Adding $a2 to $a1"
      set newj "[expr $oldj + $a2]"
      setuser $a1 xtra joins $newj
      set newj2 "[getuser $a1 xtra joins]"
      putdcc $idx "New total for $a1 is $newj2"
      return 0
      }
    }
  }
}

# Removes joins from current count, and other users stats
proc take_joins {hand idx arg} {
global what_file eggver
    if {$arg==""} {
      putdcc $idx "Usage: -join \[user\] <# to remove>"
      return 0
    }
    set a1 "[lindex $arg 0]"
    set a2 "[lindex $arg 1]"
    if {$a2 == ""} {
    putlog "#$hand# -join"
    if {$arg<0 || $arg>100} {
      putdcc $idx "$arg is out of my range, sorry!"
      return 0
    }
    set amnttake "$arg"
    set WhatFile [open $what_file r]
    while {![eof $WhatFile]} {
        set takejoinsnum "[gets $WhatFile]"
    close $WhatFile
    putdcc $idx "Old total $takejoinsnum"
    putdcc $idx "Taking $amnttake"
    set WhatFile [open $what_file w]
    puts $WhatFile [expr $takejoinsnum - $amnttake ]
    close $WhatFile
    set WhatFile [open $what_file r]
    while {![eof $WhatFile]} {  
        set takejoinsnum "[gets $WhatFile]"
    close $WhatFile   
    putdcc $idx "New total is $takejoinsnum"
    return 0
   }
  }
 }
     if {$a2 != ""} {
      if {$a1 != ""} {
        if {[validuser $a1] == 0} {
        putdcc $idx "$a1 is an invalid username"
        return 0
      }
      if {$a2<0 || $a2>100} {
      putdcc $idx "$a2 is out of my range, sorry!"
      return 0
    }
      putlog "#$hand# -join $a1"
      if {$eggver == "1.1" || $eggver == "1.2"} {
      set oldj "[user-get $a1 joins]"
      putdcc $idx "Old total for $a1 $oldj"
      putdcc $idx "Taking $a2 from $a1"
      set newj "[expr $oldj - $a2]"
      user-set $a1 joins $newj
      set newj2 "[user-get $a1 joins]"
      putdcc $idx "New total for $a1 is $newj2"
      return 0
      }
      if {$eggver == "1.3"} {
      set oldj "[getuser $a1 xtra joins]"
      putdcc $idx "Old total for $a1 $oldj"
      putdcc $idx "Taking $a2 from $a1"
      set newj "[expr $oldj - $a2]"
      setuser $a1 xtra joins $newj
      set newj2 "[getuser $a1 xtra joins]"
      putdcc $idx "New total for $a1 is $newj2"
      return 0
      }
    }
  } 
}
# Turns the on-join notice on and off
proc on_off_notice {hand idx arg} {
global donotice eggver
putlog "#$hand# countnotice"
  if {$arg == ""} {
    putdcc $idx "The on-join counter notice is currently $donotice"
    return 0
  }
    set ansrep "[string tolower $arg]"
    if {$ansrep=="on"} {
      putdcc $idx "Now turning the on-join notice on"
      set donotice "on"
      return 0
    }
    if {$ansrep=="off"} {
      putdcc $idx "Now turning the on-join notice off"
      set donotice "off"
      return 0
    }
    if {$ansrep != "on" && $ansrep != "off"} {
      putdcc $idx "Usage: .countnotice <on/off>" 
      return 0
    }
}


# Your confirmation of this loading correctly.
  set joinsnum2 "[gets $start_var]"
  putlog "-----------Join Counter-----------"
  putlog "Join Counter 2.4 by Turbo- loaded!"
  putlog "Current count is $joinsnum2"
  putlog "On-Join notice defaulted to $donotice"
  putlog "Using Eggdrop v$eggver"
  putlog "----------------------------------"

##### EOF #####
This script besises being a simple join counter, also says the number of times a specified user has joined a channel since a specified date....
But the script only does that for +users in the eggdrop. My channel is not that big, so I would like this script to count joins for all people that join my channel individually, no matter if they are +users or not.
How do I change the script to do this?
Must be simple, but I don't see how t do it...
Thanks and greetz :)
User avatar
YooHoo
Owner
Posts: 939
Joined: Thu Feb 13, 2003 10:07 pm
Location: Redwood Coast

Post by YooHoo »

i believe this is the line of code that you seek:

Code: Select all

 if {[validuser $hand] == 1} { 
User avatar
Thunderdome
Op
Posts: 187
Joined: Tue Mar 15, 2005 4:42 pm

Post by Thunderdome »

hello! Not quite sure, I've noticed the line before posting the script, but I dunno how to change it.... I don't know much tcl I am afraid...
What shall I do exactly?
g
greenbear
Owner
Posts: 733
Joined: Mon Sep 24, 2001 8:00 pm
Location: Norway

Post by greenbear »

remove it, along with the ending brace (all the way down, almost at the end of the proc)
User avatar
Thunderdome
Op
Posts: 187
Joined: Tue Mar 15, 2005 4:42 pm

Post by Thunderdome »

I did it, but now nothing appears, not even the regular stuff... :|
I want to appear for everyuser the last time he was i nthe channel and number of joins... get my point? :\
Am I doing somehting wrong?
User avatar
Thunderdome
Op
Posts: 187
Joined: Tue Mar 15, 2005 4:42 pm

Post by Thunderdome »

maybe it would be better to post the whole code changed, all the changes I try to do won't work... :\
Locked