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.

Help me to made a tcl.

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
I
Igoshin
Voice
Posts: 5
Joined: Mon May 15, 2006 3:50 am

Help me to made a tcl.

Post by Igoshin »

I have 2 eggdrops first with name nick1 and second with name nick2. In bot nick1 i have statistic.tcl ( for !top10 !stat nickname and this ). And i want when nick1 is down, nick2 ( to answer to !top10 !stat ) and with statistic at nick1. Sorry for my bad eglish. Thanks in advance
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

you can simply fetch the binding of any stats script and check if the bot is online by something like 'if {[hand2nick nick1] != ""} {return 1}' (which of courses requires nick1 to be a handle name with a host matching the other bot).
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
I
Igoshin
Voice
Posts: 5
Joined: Mon May 15, 2006 3:50 am

Post by Igoshin »

Sorry but i`m new in this and can you tell me where i must put it. Cam you show me a example.
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

Not unless you link/post us the script, because we are too lazy to search the exact versions of scripts you refer to :).
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
I
Igoshin
Voice
Posts: 5
Joined: Mon May 15, 2006 3:50 am

Post by Igoshin »

I don`t remember from where i download but if you want to send you a tcl just say icq number.
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Igoshin wrote:I don`t remember from where i download but if you want to send you a tcl just say icq number.
Post the script using code tags so it can be seen.
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
I
Igoshin
Voice
Posts: 5
Joined: Mon May 15, 2006 3:50 am

Post by Igoshin »

Code: Select all

set nomer 10
bind time - "* * * * *" time:ChanLimit

proc time:ChanLimit {min hour day month year} {
    global nomer
    foreach chan [channels] {
	set newlimit [expr [llength [chanlist $chan]] + $nomer]
	set currentlimit [currentlimit $chan]
	if {$currentlimit < [expr $newlimit - 1] || $currentlimit > [expr $newlimit + 1]} {
	    putserv "mode $chan +l $newlimit"
	}
    }    
}



proc currentlimit {chan} {
    set currentmodes [getchanmode $chan]
    if {[string match "*l*" [lindex $currentmodes 0]]} {
	return [lindex $currentmodes end] 
    }
    return 0
}


 
putlog "<<< Channel Limit loaded >>>"

this is firts and second:

Code: Select all

  variable storage {scripts/dbase/statistics}

# Kill unused entries after x days
  variable killafter 30

# Command trigger
  variable trigger {!}

# smiley regex (only touch this, if you really know, what you are doing!)
  variable smileyregex {(:|8|;)(-|o)?(>|<|D|O|o|\)|\(|\]|\[|P|p|\||\\|/)}

  bind PUB   -|-  ${trigger}stat   [namespace current]::spew
  bind PUB   -|-  ${trigger}top10  [namespace current]::toplist
  bind PUB   -|-  ${trigger}top20  [namespace current]::toplist
  bind PUBM  -|-  *                [namespace current]::monitor
  bind CTCP  -|-  ACTION           [namespace current]::ctcp
  bind EVNT  -|-  save             [namespace current]::save
  bind TIME  -|-  {00 * * * *}     [namespace current]::cleanupdb

  setudef flag stat

  namespace export spew top10 toplist save load monitor
}

proc statistics::ctcp {nickname hostname handle target keyword arguments} {
  if {[validchan $target]} {
    monitor $nickname $hostname $handle $target $arguments
  }
  return 0
}

proc statistics::monitor {nickname hostname handle channel arguments} {
  variable data
  variable smileyregex
  if {([isbotnick $nickname]) || (![channel get $channel stat])} {
    return 0
  }
  set hostname [maskhost *!$hostname]
  regsub -all -- {\002|\003[\d]{0,2}(,[\d]{0,2})?|\006|\007|\017|\026|\037|\n|\t} $arguments {} arguments
  set added(words) [regexp -all -- {\S+} $arguments]
  set added(letters) [regexp -all -- {\S} $arguments]
  if {[string length $smileyregex] >= 1} {
    set added(smilies) [regexp -all -- $smileyregex $arguments]
  } else {
    set added(smilies) 0
  }
  if {(![info exists data($channel,$hostname)])} {
    set data($channel,$hostname) "0 0 0 0 0 NULL"
  }
  regexp -- {^(\d+)\s(\d+)\s(\d+)\s(\d+)\s(\d+)\s(\S+)$} $data($channel,$hostname) -> lastseen lines words letters smilies lastnick
  incr lines 1
  incr words $added(words)
  incr letters $added(letters)
  incr smilies $added(smilies)
  set data($channel,$hostname) "[unixtime] $lines $words $letters $smilies $nickname"
}

proc statistics::spew {nickname hostname handle channel arguments} {
  variable data
  if {(![channel get $channel stat])} {
    return 0
  }
  if {([isop $nickname $channel]) && ([string length $arguments] >= 1)} {
    set target [lindex [clean $arguments] 0]
  } else {
    set target $nickname
  }
  if {![onchan $target $channel]} {
    putserv "PRIVMSG $channel :\ 7« CTaTucTuka - Unknown User \002$target\002\ » "
    return 0
  }
  set targethost [maskhost *![getchanhost $target $channel]]

  if {[info exists data($channel,$targethost)]} {
    regexp -- {^(\d+)\s(\d+)\s(\d+)\s(\d+)\s(\d+)\s(\S+)$} $data($channel,$targethost) -> lastseen lines words letters smilies lastnick
    set wpl [round [expr ($words / $lines.)]]
    set spl [round [expr ($smilies / $lines.)]]
    set lpw [round [expr ($letters / $words.)]]
    putserv "PRIVMSG $channel :\ 7« CTaTucTuka 3a \002$target\002 - \002$lines\002 PeDa, \002$words\002 ($wpl B 4ac) Dymu, \002$letters\002 ($lpw) bykBu, \002$smilies\002 ($spl) ycMuBku\ » "
  } else {
    putserv "PRIVMSG $channel :\ 7« CTaTucTuka - No valuable information available for \002$target\002\ » "
  }
}

proc statistics::top {channel number {type ""}} {
  variable data
  set statistics {}
  switch $type {
    {lines} {set index 1}
    {letters} {set index 3}
    {smilies} {set index 4}
    {default} {set index 2 ; set type "words"}
  }
  foreach {user stats} [array get data $channel,*] {
    set stats [clean $stats]
    lappend statistics "[lindex [clean $stats] 5] [lindex $stats $index]"
  }
  set statistics [lrange [lsort -integer -decreasing -index 1 [lsort -unique -index 0 [lsort -integer -increasing -index 1 $statistics]]] [expr $number - 10] [expr $number - 1]]
  if {$statistics == ""} {
    return "\ 7« Top$number $type - No valuable information available for \002$channel\002\ » "
  }
  set output "\[Top$number $type -"
  for {set i 0} {$i < [llength $statistics]} {incr i 1} {
    set item [lindex $statistics $i]
    append output "\x20[expr $i+$number-9]: \002[join [lindex [clean $item] 0] { }]\002 ([lindex $item 1])"
  }
  append output "\]"
  return $output
}

proc statistics::toplist {nickname hostname handle channel arguments} {
  global lastbind
  if {(![channel get $channel stat])} {
    return 0
  }
  set arguments [clean $arguments]
  set key [lindex $arguments 0]
  if {![regexp -- {^.*?([0-9]+)$} $lastbind -> number]} {
    return 0
  }
  if {![regexp -nocase -- {^(words|letters|smilies|lines|)$} $key]} {
    putserv "PRIVMSG $channel : 7« CTaTucTuka - Unknown option: \002$key\002, valid options are \002letters\002, \002lines\002, \002smilies\002 and \002words\002\ » "
    return 0
  }
  putserv "PRIVMSG $channel :[top $channel $number [string tolower $key]]"
}

proc statistics::cleanupdb {args} {
  variable killafter
  variable data
  set killed 0
  foreach {item} [array names data] {
    set lastseen [lindex [clean $data($item)] 0]
    set expire [expr 60 * 60 * 24 * $killafter]
    if {[expr [unixtime] - $lastseen] >= $expire} {
      incr killed
      unset data($item)
    }
  }
  return $killed
}

proc statistics::load {} {
  variable data
  variable storage
  regexp -- {^(\S+/)?.*$} $storage -> directory
  if {[string length $directory] >= 1} {
    if {![file isdirectory $directory]} {
      file mkdir $directory
    }
  }
  if {![file exists $storage]} {
    return 0
  }
  if {[array exists data]} {
    array unset data
  }
  set file [open $storage r]
  while {![eof $file]} {
    gets $file line
    if {[regexp -nocase -- {^channel:(\S+)\sid:(\S+)\svalue:(\d+)\s(\d+)\s(\d+)\s(\d+)\s(\d+)\s(\S+)$} $line -> channel hostname lastseen lines words letters smilies lastnick]} {
      set data($channel,$hostname) "$lastseen $lines $words $letters $smilies $lastnick"
    }
  }
  close $file
}

proc statistics::save {args} {
  variable data
  variable storage
  set file [open $storage w]
  foreach chan_user [array names data] {
    regexp {^(\S+),(\S+)$} $chan_user -> channel user
    puts $file "channel:$channel id:$user value:$data($chan_user)"
  }
  close $file
}

proc statistics::clean {i} {
  regsub -all -- \\\\ $i \\\\\\\\ i
  regsub -all -- \\\[ $i \\\\\[ i
  regsub -all -- \\\] $i \\\\\] i
  regsub -all -- \\\} $i \\\\\} i
  regsub -all -- \\\{ $i \\\\\{ i
  return $i
}

proc statistics::round {num} {
  if {![string match "*.*" $num]} {
    return $num\.0
  }
  if {![regexp -- {^(\d+?)\.(\d+)$} $num -> primary secondary]} {
    error "syntax error in expression '$num'"
  }
  set secondary [expr round([string index $secondary 0].[string range $secondary 1 end])]
  return [expr {($secondary == 10) ? ($primary+1.0) : "$primary.$secondary"}]
}

statistics::load
[/code]
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

search at beginning of statistics::spew and statistics::toplist

Code: Select all

![channel get $channel stat]
and replace it to

Code: Select all

![channel get $channel stat] || [hand2nick nick1] != ""
dont forget to replace 'nick1' to the handle of your bot, alternately you can use '[onchan nick1 $channel]', if you dont want to add the bot as a handle a refer check for the primary nick (you will then of course get double replies, if nick1 bot uses its alternate nick).
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
I
Igoshin
Voice
Posts: 5
Joined: Mon May 15, 2006 3:50 am

Post by Igoshin »

I replace but nothing change. can you give a edited code ? I tell you the two eggdrops. The eggdrop "Dasha" have a statistic.tcl and i want when dasha is down the eggdrop with nickname "Anthem" witch he is in the channel to answer !top10, but if "dasha" is online anthem do not answer to !top10. Can you do this because i can`t.
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

what have you tried? Do you have a user/bot named 'Dasha' in the user records of your bot 'Anthem' with an hostname, that always matchs the other bot?
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
Post Reply