IceChat Forums

IceChat 7 => IceChat 7 Scripts => Topic started by: Grue on December 11, 2006, 12:11:15 PM

Title: Requesting "!seen" script
Post by: Grue on December 11, 2006, 12:11:15 PM
My scripting skills are woefully inadequate, else I'd be able to deal with this myself, or adapt some other product's script successfully.  I believe it's the lack of full documentation of IC7 scripting functionality that prevents me from puzzling it out anyway in this case.

Is there a chance that some worthy person has or can port a common "!seen" script to be usable in IC7?  :-)

Pretty please?
Title: Re: Requesting "!seen" script
Post by: DarkStar on December 15, 2006, 06:08:53 PM
The problem is....What do you want it to do? Without that information I can't make one. I'd be more then willing to make one if you answer this question. :)
Title: Re: Requesting "!seen" script
Post by: Grue on December 15, 2006, 08:22:24 PM
Okey-dokey, I thought this was a common thing.  I guess not!   :wink:

A "seen" script keeps a database of at least joins/parts in a channel, often also nickchanges, and replies upon prompting (usually with "!seen <nick>") by giving the elapsed time since the nick in question was last used in the channel.  Often, the quit/part message will also be given.  The user is also commonly listed as "present in the channel as <nick>" if there's a related nickchange.

One useful thing that I also usually find in previous examples, is the ability to have the script only act on particular channels of the list that a user may be joined at a given time.

Anything else?
Title: Re: Requesting "!seen" script
Post by: DarkStar on December 15, 2006, 09:33:26 PM
Okey-dokey, I thought this was a common thing.  I guess not!   :wink:

A "seen" script keeps a database of at least joins/parts in a channel, often also nickchanges, and replies upon prompting (usually with "!seen <nick>") by giving the elapsed time since the nick in question was last used in the channel.  Often, the quit/part message will also be given.  The user is also commonly listed as "present in the channel as <nick>" if there's a related nickchange.

One useful thing that I also usually find in previous examples, is the ability to have the script only act on particular channels of the list that a user may be joined at a given time.

Anything else?


Hmm, I could do this, I think.

The problem I run into is when we hit the part about the time. I know there is a datediff function in Visual Basic i'm just not sure how to do it in Icechat, For I have never used it. I'll look into this right now.
Title: Re: Requesting "!seen" script
Post by: DarkStar on December 15, 2006, 10:56:52 PM
okay, when you say it keeps a record of joins/parts, do you mean number of times they join/part or when they last joined/parted?
Title: Re: Requesting "!seen" script
Post by: Snerf on December 16, 2006, 02:25:41 AM
Just the last join/part/quit. Thats all it keeps track of.
Title: Re: Requesting "!seen" script
Post by: DarkStar on December 19, 2006, 11:48:28 PM
Sorry, My computer is crapping out right now, And I wont be getting a new one until Christmas. I'm surprised it let me get online to post this...
Title: Re: Requesting "!seen" script
Post by: Snerf on July 20, 2007, 09:07:56 AM
We should try and get this !seen script up and running, as I am sure some people would like to use one.
Start with a basic one, and work from there.
Title: Re: Requesting "!seen" script
Post by: James Revan on January 21, 2008, 09:51:08 PM
Hi, i dnot know if anyone is interested still in this, but... Here is a seen script for the most popular IRC bot "eggdrop" its written in tcl, my question is can it be somehow changed to work/rewritten for IceChat? (don't mind the polish texts those are just replys from bot and not script variables). Sorry for double post, but it wont fit in one post.

Code: [Select]
#
###
#Bass's Seen script.  v1.4.2c  2/2000
#*!bass@*.psu.edu on Undernet.  Email: bass@tclslave.net or bass@mars.age.psu.edu
#This script maintains a database of *all* nicks seen online,
#not just those ppl who are in the userlist.  Simple flood
#protection is built-in.  Wildcard searches are supported.
#
#Input is accepted from:
#       pub:  !seen <query> [#chan]
#       msg:  seen <query> [#chan]
#   and dcc:  .seen <query> [#chan]
#
#Queries can be in the following formats (public examples given):
#    'regular' !seen lamer; !seen lamest | SmartSearch-enabled query
#    'limited' !seennick lamer | SmartSearch-bypassed query
#    'masked'  !seen *l?mer*; !seen *.lame.com; !seen *.edu #mychan
#
#Bonus feature:  !lastspoke <nick> 
#    You can use wildcard matching for <nick>.  The results for the
#    first match are returned.
#
###
#
#Polish translation made by Mr. Groch (mr_groch@klub.chip.pl)
#
###Parameters:

#bs(limit) is the database record limit. 
set bs(limit) 4000

#bs(nicksize) is the maximum nickname length (9 on Undernet)
set bs(nicksize) 32

#bs(no_pub) is a list of channels you *don't* want the bot to post public
#  replies to (public queries ignored).  Enter in lower case, eg: #lamer
set bs(no_pub) ""

#bs(quiet_chan) is a list of channels you want replies to requests sent 
#  to the person who made the query via notice. (The bot replies to 
#  public queries via notice.)  Enter in lower case.
set bs(quiet_chan) ""

#bs(no_log) is a list of channels you *don't* want the bot to log
#  data on.  Enter chans in lower case.
set bs(no_log) ""

#bs(log_only) is a list of channels you *only* want the bot to log
#  data on.  This is the opposite of bs(no_log).  Set it to "" if you
#  want to log new channels the bot joins.  Enter chans in lower case.
set bs(log_only) ""

#bs(cmdchar) is what command character should be used for making public
#  queries.  The default is "!".  Setting it to "" is a valid option.
set bs(cmdchar) "!"

#bs(flood) is used for flood protection, in the form x:y.  Any queries
#  beyond x in y seconds is considered a flood and ignored.
set bs(flood) 4:15
#bs(ignore) is used as a switch for ignoring flooders (1=on)
set bs(ignore) 1
#bs(ignore_time) is used to define the amount of time a flooder is
#  ignored (minutes).  This is meaningless if bs(ignore) is 0.
set bs(ignore_time) 2

#bs(smartsearch) is a master enable/disable for SmartSearch.  SmartSearch ensures that
#  the most accurate and current results are returned for nick queries. (1=on)
set bs(smartsearch) 1

#bs(logqueries) is used to log DCC/MSG/PUB queries
set bs(logqueries) 1

#bs(path) is used to indicate what path to save the database and backup to. 
#  Setting to "" will cause the script to be saved in the same path as the eggdrop executable
#  If you set it, use the full path, and make sure you terminate w/ a "/". 
#  eg:  set bs(path) "/usr/home/mydir/blah/"
set bs(path) ""

###### Don't edit below here, even if you do know Tcl ######


if {[bind msg -|- help] != "*msg:help"} {bind msg -|- help *msg:help} ; #this is to fix a bind I didn't intend to use in a prev version (which screwed up msg'd help).  Sorry!
proc bs_filt {data} {
  regsub -all -- \\\\ $data \\\\\\\\ data ; regsub -all -- \\\[ $data \\\\\[ data ; regsub -all -- \\\] $data \\\\\] data
  regsub -all -- \\\} $data \\\\\} data ; regsub -all -- \\\{ $data \\\\\{ data ; regsub -all -- \\\" $data \\\\\" data ; return $data
}
proc bs_flood_init {} {
  global bs bs_flood_array ; if {![string match *:* $bs(flood)]} {putlog "$bs(version): var bs(flood) ustawione nieprawidlowo." ; return}
  set bs(flood_num) [lindex [split $bs(flood) :] 0] ; set bs(flood_time) [lindex [split $bs(flood) :] 1] ; set i [expr $bs(flood_num) - 1]
  while {$i >= 0} {set bs_flood_array($i) 0 ; incr i -1 ; }
} ; bs_flood_init
proc bs_flood {nick uhost} {
  global bs bs_flood_array ; if {$bs(flood_num) == 0} {return 0} ; set i [expr $bs(flood_num) - 1]
  while {$i >= 1} {set bs_flood_array($i) $bs_flood_array([expr $i - 1]) ; incr i -1} ; set bs_flood_array(0) [unixtime]
  if {[expr [unixtime] - $bs_flood_array([expr $bs(flood_num) - 1])] <= $bs(flood_time)} {
    putlog "$bs(version): Wykryty flood z $nick." ; if {$bs(ignore)} {newignore [join [maskhost *!*[string trimleft $uhost ~]]] $bs(version) flood $bs(ignore_time)} ; return 1
  } {return 0}
}
if {[lsearch -exact [bind time -|- "*2 * * * *"] bs_timedsave] > -1} {unbind time -|- "*2 * * * *" bs_timedsave} ; #backup frequency can be lower
proc bs_read {} {
  global bs_list userfile bs
  if {![string match */* $userfile]} {set name [lindex [split $userfile .] 0]} {
    set temp [split $userfile /] ; set temp [lindex $temp [expr [llength $temp]-1]] ; set name [lindex [split $temp .] 0]
  }
  if {![file exists $bs(path)bs_data.$name]} {
    if {![file exists $bs(path)bs_data.$name.bak]} {
      putlog "     Nie wykryto bazy  danych!" ; putlog "     Jezeli to jest pierwsze uruchomienie bseen - nie martw sie." ; putlog "     Jezeli powinna byc baza danych, a niestety jej nie wykryto... Martw sie." ; return
    } {exec cp $bs(path)bs_data.$name.bak $bs(path)bs_data.$name ; putlog "     Old seen data not found! Using backup data."}
  } ; set fd [open $bs(path)bs_data.$name r]
  set bsu_ver "" ; set break 0
  while {![eof $fd]} {
    set inp [gets $fd] ; if {[eof $fd]} {break} ; if {[string trim $inp " "] == ""} {continue}
    if {[string index $inp 0] == "#"} {set bsu_version [string trimleft $inp #] ; continue}
    if {![info exists bsu_version] || $bsu_version == "" || $bsu_version < $bs(updater)} {
      putlog "Uaktualniam baze danych do nowszej wersji..."
#bugfix (b) - loading the wrong updater version
      if {[source scripts/bseen_updater1.4.2-polish.tcl] != "ok"} {set temp 1} {set temp 0}
      if {$temp || [bsu_go] || [bsu_finish]} {
        putlog "Wystapil powazny problem podczas uaktualniania bazy danych."
        if {$temp} {putlog "     Skrypt uaktualniajacy nie znaleziony."}
        putlog "Nie jest zalecane uruchamianie bseen ze stara wersja bazy danych."
        putlog "Jezeli nie potrafisz znalezc przyczyny bledu, usun plik  bs_data.$name oraz bs_data.$name.bak .  Nastepnie zestartuj bota."
        putlog "Poniewaz to jest potencjalna przyczyna zawieszen, ladowanie zostalo przerwane." ; die "Wystapil krytyczny blad"
      } ; set break 1 ; break
    }
    set nick [lindex $inp 0] ; set bs_list([string tolower $nick]) $inp
  } ; close $fd
  if {$break} {bs_read} {putlog "     Zakonczono ladowanie [array size bs_list] wpisow bazy danych."}
}

###
#Must check to make sure the version didn't change during a .rehash
proc bs_update {} {
  global bs
  putlog "Nowa wersja jest dynamicznie ladowana...."
  putlog "    Sprawdzam integralnosc bazy danych..."
  bs_save ; bs_read
}
set bs(updater) 10402 ; set bs(version) bseen1.4.2c
if {[info exists bs_list]} {
#a rehash was done
  if {[info exists bs(oldver)]} {
    if {$bs(oldver) < $bs(updater)} {bs_update} ;# old ver found
  } {bs_update} ;# pre- 1.4.0
}
set bs(oldver) $bs(updater)
putlog "$bs(version):  -- Bass's SEEN loaded --"
if {![info exists bs_list] || [array size bs_list] == 0} {putlog "     Laduje baze danych..." ; bs_read}
###

bind time - "12 * * * *" bs_timedsave
proc bs_timedsave {min b c d e} {bs_save}
proc bs_save {} {
  global bs_list userfile bs ; if {[array size bs_list] == 0} {return}
  if {![string match */* $userfile]} {set name [lindex [split $userfile .] 0]} {
    set temp [split $userfile /] ; set temp [lindex $temp [expr [llength $temp]-1]] ; set name [lindex [split $temp .] 0]
  }
  if {[file exists $bs(path)bs_data.$name]} {catch {exec cp -f $bs(path)bs_data.$name $bs(path)bs_data.$name.bak}}
  set fd [open $bs(path)bs_data.$name w] ; set id [array startsearch bs_list] ; putlog "Tworze kopie zapasowa bazy danych bseen..."
  puts $fd "#$bs(updater)"
  while {[array anymore bs_list $id]} {set item [array nextelement bs_list $id] ; puts $fd "$bs_list($item)"} ; array donesearch bs_list $id ; close $fd
}
#bugfix -- support new PART in egg1.5.x+
if {[string trimleft [lindex $version 1] 0] >= 1050000} {
  bind part -|- * bs_part 
} {
  if {[lsearch -exact [bind part -|- *] bs_part] > -1} {unbind part -|- * bs_part}
  bind part -|- * bs_part_oldver
}
proc bs_part_oldver {a b c d} {bs_part $a $b $c $d ""}
#bugfix - new bs_part proc
proc bs_part {nick uhost hand chan reason} {bs_add $nick "[list $uhost] [unixtime] part $chan [split $reason]"}
bind join -|- * bs_join
proc bs_join {nick uhost hand chan} {bs_add $nick "[list $uhost] [unixtime] join $chan"}
bind sign -|- * bs_sign
proc bs_sign {nick uhost hand chan reason} {bs_add $nick "[list $uhost] [unixtime] quit $chan [split $reason]"}
bind kick -|- * bs_kick
proc bs_kick {nick uhost hand chan knick reason} {bs_add $knick "[getchanhost $knick $chan] [unixtime] kick $chan [list $nick] [list $reason]"}
bind nick -|- * bs_nick
proc bs_nick {nick uhost hand chan newnick} {set time [unixtime] ; bs_add $nick "[list $uhost] [expr $time -1] nick $chan [list $newnick]" ; bs_add $newnick "[list $uhost] $time rnck $chan [list $nick]"}
bind splt -|- * bs_splt
proc bs_splt {nick uhost hand chan} {bs_add $nick "[list $uhost] [unixtime] splt $chan"}
bind rejn -|- * bs_rejn
proc bs_rejn {nick uhost hand chan} {bs_add $nick "[list $uhost] [unixtime] rejn $chan"}
bind chon -|- * bs_chon
proc bs_chon {hand idx} {foreach item [dcclist] {if {[lindex $item 3] != "CHAT"} {continue} ; if {[lindex $item 0] == $idx} {bs_add $hand "[lindex $item 2] [unixtime] chon" ; break}}}
if {[lsearch -exact [bind chof -|- *] bs_chof] > -1} {unbind chof -|- * bs_chof} ; #this bind isn't needed any more
bind chjn -|- * bs_chjn
proc bs_chjn {bot hand channum flag sock from} {bs_add $hand "[string trimleft $from ~] [unixtime] chjn $bot"}
bind chpt -|- * bs_chpt
proc bs_chpt {bot hand args} {set old [split [bs_search ? [string tolower $hand]]] ; if {$old != "0"} {bs_add $hand "[join [string trim [lindex $old 1] ()]] [unixtime] chpt $bot"}}

if {[string trimleft [lindex $version 1] 0] > 1030000} {bind away -|- * bs_away}
proc bs_away {bot idx msg} {
  global botnet-nick
  if {$bot == ${botnet-nick}} {set hand [idx2hand $idx]} {return}
  set old [split [bs_search ? [string tolower $hand]]]
  if {$old != "0"} {bs_add $hand "[join [string trim [lindex $old 1] ()]] [unixtime] away $bot [bs_filt [join $msg]]"}
}
bind dcc n|- unseen bs_unseen
proc bs_unseen {hand idx args} {
  global bs_list
  set tot 0 ; set chan [string tolower [lindex $args 0]] ; set id [array startsearch bs_list]
  while {[array anymore bs_list $id]} {
    set item [array nextelement bs_list $id]
    if {$chan == [string tolower [lindex $bs_list($item) 4]]} {incr tot ; lappend remlist $item}
  }
  array donesearch bs_list $id ; if {$tot > 0} {foreach item $remlist {unset bs_list($item)}}
  putlog "$hand usunal $chan z bazy danych bseen.  $tot wpisow usunietych."
  putidx $idx "$chan usuniety.  $tot wpisow usunietych z bazy danych bseen."
}
bind bot -|- bs_botsearch bs_botsearch
proc bs_botsearch {from cmd args} {
  global botnick ; set args [join $args]
  set command [lindex $args 0] ; set target [lindex $args 1] ; set nick [lindex $args 2] ; set search [bs_filt [join [lrange $args 3 e]]]
  if {[string match *\\\** $search]} {
    set output [bs_seenmask bot $nick $search]
    if {$output != "Nic nie znaleziono." && ![string match "Nie ma mnie na *" $output]} {putbot $from "bs_botsearch_reply $command \{$target\} {$nick, $botnick says:  [bs_filt $output]}"}
  } {
    set output [bs_output bot $nick [bs_filt [lindex $search 0]] 0]
    if {$output != 0 && [lrange [split $output] 1 4] != "Nie pamietam zebym widzial"} {putbot $from "bs_botsearch_reply $command \{$target\} {$nick, $botnick says:  [bs_filt $output]}"}
  }
}
if {[info exists bs(bot_delay)]} {unset bs(bot_delay)}
bind bot -|- bs_botsearch_reply bs_botsearch_reply
proc bs_botsearch_reply {from cmd args} {
  global bs ; set args [join $args]
  if {[lindex [lindex $args 2] 5] == "not" || [lindex [lindex $args 2] 4] == "not"} {return}
  if {![info exists bs(bot_delay)]} {
    set bs(bot_delay) on ; utimer 10 {if {[info exists bs(bot_delay)]} {unset bs(bot_delay)}}
    if {![lindex $args 0]} {putdcc [lindex $args 1] "[join [lindex $args 2]]"} {puthelp "[lindex $args 1] :[join [lindex $args 2]]"}
  }
}
bind dcc -|- seen bs_dccreq1
bind dcc -|- seennick bs_dccreq2
proc bs_dccreq1 {hand idx args} {bs_dccreq $hand $idx $args 0}
proc bs_dccreq2 {hand idx args} {bs_dccreq $hand $idx $args 1}
proc bs_dccreq {hand idx args no} {
  set args [bs_filt [join $args]] ; global bs
  if {[string match *\\\** [lindex $args 0]]} {
    set output [bs_seenmask dcc $hand $args]
    if {$output == "Nic nie znaleziono."} {putallbots "bs_botsearch 0 $idx $hand $args"}
    if {[string match "Nie jestem na *" $output]} {putallbots "bs_botsearch 0 $idx $hand $args"}
    putdcc $idx $output ; return $bs(logqueries)
  }
  set search [bs_filt [lindex $args 0]]
  set output [bs_output dcc $hand $search $no]
  if {$output == 0} {return 0}
  if {[lrange [split $output] 1 4] == "Nie przypominam sobie, bym widzial"} {putallbots "bs_botsearch 0 $idx $hand $args"}
  putdcc $idx "$output" ; return $bs(logqueries)
}
Title: Re: Requesting "!seen" script
Post by: James Revan on January 21, 2008, 09:53:48 PM
Code: [Select]
bind msg -|- seen bs_msgreq1
bind msg -|- seennick bs_msgreq2
proc bs_msgreq1 {nick uhost hand args} {bs_msgreq $nick $uhost $hand $args 0}
proc bs_msgreq2 {nick uhost hand args} {bs_msgreq $nick $uhost $hand $args 1}
proc bs_msgreq {nick uhost hand args no} {
  if {[bs_flood $nick $uhost]} {return 0} ; global bs
  set args [bs_filt [join $args]]
  if {[string match *\\\** [lindex $args 0]]} {
    set output [bs_seenmask msg $nick $args]
    if {$output == "Nic nie znaleziono."} {putallbots "bs_botsearch 1 \{notice $nick\} $nick $args"}
    if {[string match "Nie jestem na *" $output]} {putallbots "bs_botsearch 1 \{notice $nick\} $nick $args"}
    puthelp "notice $nick :$output" ; return $bs(logqueries)
  }
  set search [bs_filt [lindex $args 0]]
  set output [bs_output $search $nick $search $no]
  if {$output == 0} {return 0}
  if {[lrange [split $output] 1 4] == "Nie przypominam sobie bym widzial"} {putallbots "bs_botsearch 1 \{notice $nick\} $nick $args"}
  puthelp "notice $nick :$output" ; return $bs(logqueries)
}
bind pub -|- [string trim $bs(cmdchar)]seen bs_pubreq1
bind pub -|- [string trim $bs(cmdchar)]seennick bs_pubreq2
proc bs_pubreq1 {nick uhost hand chan args} {bs_pubreq $nick $uhost $hand $chan $args 0}
proc bs_pubreq2 {nick uhost hand chan args} {bs_pubreq $nick $uhost $hand $chan $args 1}
proc bs_pubreq {nick uhost hand chan args no} {
  if {[bs_flood $nick $uhost]} {return 0}
  global botnick bs ; set i 0
  if {[lsearch -exact $bs(no_pub) [string tolower $chan]] >= 0} {return 0}
  if {$bs(log_only) != "" && [lsearch -exact $bs(log_only) [string tolower $chan]] == -1} {return 0}
  set args [bs_filt [join $args]]
  if {[lsearch -exact $bs(quiet_chan) [string tolower $chan]] >= 0} {set target "notice $nick"} {set target "privmsg $chan"}
  if {[string match *\\\** [lindex $args 0]]} {
    set output [bs_seenmask $chan $hand $args]
    if {$output == "Nic nie znaleziono."} {putallbots "bs_botsearch 1 \{$target\} $nick $args"}
    if {[string match "Nie jestem na *" $output]} {putallbots "bs_botsearch 1 \{$target\} $nick $args"}
    puthelp "$target :$output" ; return $bs(logqueries)
  }
  set data [bs_filt [string trimright [lindex $args 0] ?!.,]]
  if {[string tolower $nick] == [string tolower $data] } {puthelp "$target :$nick, idz zobacz sie w lustrze." ; return $bs(logqueries)}
  if {[string tolower $data] == [string tolower $botnick] } {puthelp "$target :$nick, jestem przeciez tutaj.  Nie marnuj mojego czasu!" ; return $bs(logqueries)}
  if {[onchan $data $chan]} {puthelp "$target :$nick, $data jest tutaj!" ; return $bs(logqueries)}
  set output [bs_output $chan $nick $data $no] ; if {$output == 0} {return 0}
  if {[lrange [split $output] 1 4] == "Nie przypominam sobie bym widzial"} {putallbots "bs_botsearch 1 \{$target\} $nick $args"}
  puthelp "$target :$output" ; return $bs(logqueries)
}
proc bs_output {chan nick data no} {
  global botnick bs version bs_list
  set data [string tolower [string trimright [lindex $data 0] ?!.,]]
  if {$data == ""} {return 0}
  if {[string tolower $nick] == $data} {return [concat $nick, idz zobacz sie w lustrze.]}
  if {$data == [string tolower $botnick]} {return [concat $nick, jestem przeciez tutaj. Nie marnuj mojego czasu!]}
  if {[string length $data] > $bs(nicksize)} {return 0}
  if {$bs(smartsearch) != 1} {set no 1}
  if {$no == 0} {
    set matches "" ; set hand "" ; set addy ""
    if {[lsearch -exact [array names bs_list] $data] != "-1"} {
      set addy [lindex $bs_list([string tolower $data]) 1] ; set hand [finduser $addy]
      foreach item [bs_seenmask dcc ? [maskhost $addy]] {if {[lsearch -exact $matches $item] == -1} {set matches "$matches $item"}}
    }
    if {[validuser $data]} {set hand $data}
    if {$hand != "*" && $hand != ""} {
      if {[string trimleft [lindex $version 1] 0]>1030000} {set hosts [getuser $hand hosts]} {set hosts [gethosts $hand]}
      foreach addr $hosts {
        foreach item [string tolower [bs_seenmask dcc ? $addr]] {
          if {[lsearch -exact [string tolower $matches] [string tolower $item]] == -1} {set matches [concat $matches $item]}
        }
      }
    }
    if {$matches != ""} {
      set matches [string trimleft $matches " "]
      set len [llength $matches]
      if {$len == 1} {return [bs_search $chan [lindex $matches 0]]}
      if {$len > 99} {return [concat Znalazlem $len pasujacych wpisow\; Prosze sprecyzowac zapytanie.]}
      set matches [bs_sort $matches]
      set key [lindex $matches 0]
      if {[string tolower $key] == [string tolower $data]} {return [bs_search $chan $key]}
      if {$len <= 5} {
        set output [concat Znalazlem $len pasujacych wpisow: [join $matches].]
        set output [concat $output  [bs_search $chan $key]] ; return $output
      } {
        set output [concat Znalazlem $len pasujacych wpisow.  Oto 5 najlepszych: [join [lrange $matches 0 4]].]
        set output [concat $output  [bs_search $chan $key]] ; return $output
      }
    }
  }
  set temp [bs_search $chan $data]
  if {$temp != 0} { return $temp } {
    #$data not found in $bs_list, so search userfile
    if {![validuser [bs_filt $data]] || [string trimleft [lindex $version 1] 0]<1030000} {
      return "$nick, nie przypominam sobie bym widzial $data."
    } {
      set seen [getuser $data laston]
      if {[getuser $data laston] == ""} {return "$nick, nie przypominam sobie bym widzial $data."}
      if {($chan != [lindex $seen 1] || $chan == "bot" || $chan == "msg" || $chan == "dcc") && [validchan [lindex $seen 1]] && [lindex [channel info [lindex $seen 1]] 23] == "+secret"} {
        set chan "-secret-"
      } {
        set chan [lindex $seen 1]
      }
      return [concat $nick, $data byl/a ostatnio widziany/a na $chan [bs_when [lindex $seen 0]] temu.]
    }
  }
}
proc bs_search {chan n} {
  global bs_list ; if {![info exists bs_list]} {return 0}
  if {[lsearch -exact [array names bs_list] [string tolower $n]] != "-1"} {
#bugfix:  let's see if the split added below fixes the eggdrop1.4.2 truncation bug
    set data [split $bs_list([string tolower $n])]
#bugfix: added a join on the $n  (c)
    set n [join [lindex $data 0]] ; set addy [lindex $data 1] ; set time [lindex $data 2] ; set marker 0
    if {([string tolower $chan] != [string tolower [lindex $data 4]] || $chan == "dcc" || $chan == "msg" || $chan == "bot") && [validchan [lindex $data 4]] && [lindex [channel info [lindex $data 4]] 23] == "+secret"} {
      set chan "-secret-"
    } {
      set chan [lindex $data 4]
    }
    switch -- [lindex $data 3] {
part {
        set reason [lrange $data 5 e]
        if {$reason == ""} {set reason "."} {set reason " stating \"$reason\"."}
        set output [concat $n ($addy) byl/a ostatnio widziany/a na $chan [bs_when $time] temu$reason]
      }
quit { set output [concat $n ($addy) byl/a ostatnio widziany/a jak wychodzil/a z $chan [bs_when $time] temu ([join [lrange $data 5 e]]).] }
kick { set output [concat $n ($addy) byl/a ostatnio widziany/a jak zostal wykopany/a z $chan by [lindex $data 5] [bs_when $time] temu z powodu ([join [lrange $data 6 e]]).] }
rnck {
 set output [concat $n ($addy) byl/a ostatnio widziany/a jak zmienial/a nick [lindex $data 5] na [lindex $data 4] [bs_when $time] temu.]
 if {[validchan [lindex $data 4]]} {
   if {[onchan $n [lindex $data 4]]} {
     set output [concat $output $n jest nadal tutaj.]
   } {
     set output [concat $output  nie widze teraz $n .]
   }
 }
}
nick {
 set output [concat $n ($addy) byl/a ostatnio widziany/a jak zmienial/a nick [lindex $data 5] na [lindex $data 4] [bs_when $time] temu.]
}
splt { set output [concat $n ($addy) byl/a ostatnio widziany/a jak opuszczal/a $chan [bs_when $time] temu.] }
rejn {
 set output [concat $n ($addy) byl/a ostatnio widziany/a jak powracal/a na $chan [bs_when $time] temu.]
 if {[validchan $chan]} {if {[onchan $n $chan]} {set output [concat $output  $n jest nadal na $chan.]} {set output [concat $output  Nie widze teraz $n na $chan .]}}
}
join {
 set output [concat $n ($addy) byl/a ostatnio widziany/a jak wchodzil/a na $chan [bs_when $time] temu.]
 if {[validchan $chan]} {if {[onchan $n $chan]} {set output [concat $output  $n jest nadal na $chan.]} {set output [concat $output  Nie widze teraz $n na $chan .]}}
}
away {
 set reason [lrange $data 5 e]
        if {$reason == ""} {
   set output [concat $n ($addy) byl/a ostatnio widziany/a jak powracal/a na partyline $chan [bs_when $time] temu.]
 } {
   set output [concat $n ($addy) byl/a ostatnio widziany/a ze statusem away ($reason) na $chan [bs_when $time] temu.]
 }
}
chon {
 set output [concat $n ($addy) byl/a ostatnio widziany/a na partyline [bs_when $time] temu.] ; set lnick [string tolower $n]
 foreach item [whom *] {if {$lnick == [string tolower [lindex $item 0]]} {set output [concat $output  $n jest teraz na partyline.] ; set marker 1 ; break}}
 if {$marker == 0} {set output [concat $output  Nie widze teraz $n na partyline.]}
}
chof {
 set output [concat $n ($addy) byl/a ostatnio widziany/a jak opuszczal/a partyline [bs_when $time] temu.] ; set lnick [string tolower $n]
 foreach item [whom *] {if {$lnick == [string tolower [lindex $item 0]]} {set output [concat $output  $n jest nadal na partyline [lindex $item 1] .] ; break}}
}
chjn {
 set output [concat $n ($addy) byl/a ostatnio widziany/a jak wchodzil/a na partyline $chan [bs_when $time] temu.] ; set lnick [string tolower $n]
 foreach item [whom *] {if {$lnick == [string tolower [lindex $item 0]]} {set output [concat $output  $n jest teraz na partyline.] ; set marker 1 ; break}}
 if {$marker == 0} {set output [concat $output  Nie widze teraz $n na partyline.]}
}
chpt {
 set output [concat $n ($addy) byl/a ostatnio widiny/a jak opuszczal/a partyline $chan [bs_when $time] temu.] ; set lnick [string tolower $n]
 foreach item [whom *] {if {$lnick == [string tolower [lindex $item 0]]} {set output [concat $output  $n jest nadal na partyline [lindex $item 1] .] ; break}}
}
default {set output "error"}
    } ; return $output
  } {return 0}
}
proc bs_when {lasttime} {
  #This is equiv to mIRC's $duration() function
  set years 0 ; set days 0 ; set hours 0 ; set mins 0 ; set time [expr [unixtime] - $lasttime]
  if {$time < 60} {return "tylko $time sekund"}
  if {$time >= 31536000} {set years [expr int([expr $time/31536000])] ; set time [expr $time - [expr 31536000*$years]]}
  if {$time >= 86400} {set days [expr int([expr $time/86400])] ; set time [expr $time - [expr 86400*$days]]}
  if {$time >= 3600} {set hours [expr int([expr $time/3600])] ; set time [expr $time - [expr 3600*$hours]]}
  if {$time >= 60} {set mins [expr int([expr $time/60])]}
  if {$years == 0} {set output ""} elseif {$years == 1} {set output "1 rok,"} {set output "$years lat,"}
  if {$days == 1} {lappend output "1 dzien,"} elseif {$days > 1} {lappend output "$days dni,"}
  if {$hours == 1} {lappend output "1 godzine,"} elseif {$hours > 1} {lappend output "$hours godzin,"}
  if {$mins == 1} {lappend output "1 minute"} elseif {$mins > 1} {lappend output "$mins minut"}
  return [string trimright [join $output] ", "]
}
proc bs_add {nick data} {
  global bs_list bs
  if {[lsearch -exact $bs(no_log) [string tolower [lindex $data 3]]] >= 0 || ($bs(log_only) != "" && [lsearch -exact $bs(log_only) [string tolower [lindex $data 3]]] == -1)} {return}
  set bs_list([string tolower $nick]) "[bs_filt $nick] $data"
}
bind time -  "*1 * * * *" bs_trim
proc bs_lsortcmd {a b} {global bs_list ; set a [lindex $bs_list([string tolower $a]) 2] ; set b [lindex $bs_list([string tolower $b]) 2] ; if {$a > $b} {return 1} elseif {$a < $b} {return -1} {return 0}}
proc bs_trim {min h d m y} {
  global bs bs_list ; if {![info exists bs_list] || ![array exists bs_list]} {return} ; set list [array names bs_list] ; set range [expr [llength $list] - $bs(limit) - 1] ; if {$range < 0} {return}
  set list [lsort -increasing -command bs_lsortcmd $list] ; foreach item [lrange $list 0 $range] {unset bs_list($item)}
}
proc bs_seenmask {ch nick args} {
  global bs_list bs ; set matches "" ; set temp "" ; set i 0 ; set args [join $args] ; set chan [lindex $args 1]
  if {$chan != "" && [string trimleft $chan #] != $chan} {
    if {![validchan $chan]} {return "Nie jestem na $chan."} {set chan [string tolower $chan]}
  } { set $chan "" }
  if {![info exists bs_list]} {return "Nic nie znaleziono."} ; set data [bs_filt [string tolower [lindex $args 0]]]

#bugfix: unnecessarily complex masks essentially freeze the bot
  set maskfix 1
  while $maskfix {
    set mark 1
    if [regsub -all -- \\?\\? $data ? data] {set mark 0}
    if [regsub -all -- \\*\\* $data * data] {set mark 0}
    if [regsub -all -- \\*\\? $data * data] {set mark 0}
    if [regsub -all -- \\?\\* $data * data] {set mark 0}
    if $mark {break}
  }

 
Title: Re: Requesting "!seen" script
Post by: James Revan on January 21, 2008, 09:56:11 PM
Code: [Select]
set id [array startsearch bs_list]
  while {[array anymore bs_list $id]} {
    set item [array nextelement bs_list $id] ; if {$item == ""} {continue} ; set i 0 ; set temp "" ; set match [lindex $bs_list($item) 0] ; set addy [lindex $bs_list($item) 1]
    if {[string match $data $item![string tolower $addy]]} {
      set match [bs_filt $match] ; if {$chan != ""} {
        if {[string match $chan [string tolower [lindex $bs_list($item) 4]]]} {set matches [concat $matches $match]}
      } {set matches [concat $matches $match]}
    }
  }
  array donesearch bs_list $id
  set matches [string trim $matches " "]
  if {$nick == "?"} {return [bs_filt $matches]}
  set len [llength $matches]
  if {$len == 0} {return "Nic nie znaleziono."}
  if {$len == 1} {return [bs_output $ch $nick $matches 1]}
  if {$len > 99} {return "Znalazlem $len pasujacych wpisow; prosze sprecyzowac zpytanie."}
  set matches [bs_sort $matches]
  if {$len <= 5} {
    set output [concat Znalazlem $len pasujacych wpisow: [join $matches].]
  } {
    set output "Znalazlem $len pasujacych wpisow.  Oto 5 najlepszych: [join [lrange $matches 0 4]]."
  }
  return [concat $output [bs_output $ch $nick [lindex [split $matches] 0] 1]]
}
proc bs_sort {data} {global bs_list ; set data [bs_filt [join [lsort -decreasing -command bs_lsortcmd $data]]] ; return $data}
bind dcc -|- seenstats bs_dccstats
proc bs_dccstats {hand idx args} {putdcc $idx "[bs_stats]"; return 1}
bind pub -|- [string trim $bs(cmdchar)]seenstats bs_pubstats
proc bs_pubstats {nick uhost hand chan args} {
  global bs ; if {[bs_flood $nick $uhost] || [lsearch -exact $bs(no_pub) [string tolower $chan]] >= 0 || ($bs(log_only) != "" && [lsearch -exact $bs(log_only) [string tolower $chan]] == -1)} {return 0}
  if {[lsearch -exact $bs(quiet_chan) [string tolower $chan]] >= 0} {set target "notice $nick"} {set target "privmsg $chan"} ; puthelp "$target :[bs_stats]" ; return 1
}
bind msg -|- seenstats bs_msgstats
proc bs_msgstats {nick uhost hand args} {global bs ; if {[bs_flood $nick $uhost]} {return 0} ; puthelp "notice $nick :[bs_stats]" ; return $bs(logqueries)}
proc bs_stats {} {
  global bs_list bs ; set id [array startsearch bs_list] ; set bs_record [unixtime] ; set totalm 0 ; set temp ""
  while {[array anymore bs_list $id]} {
    set item [array nextelement bs_list $id]
    set tok [lindex $bs_list($item) 2] ; if {$tok == ""} {putlog "Uszkodzony wpis: $item" ; continue}
    if {[lindex $bs_list($item) 2] < $bs_record} {set bs_record [lindex $bs_list($item) 2] ; set name $item}
    set addy [string tolower [maskhost [lindex $bs_list($item) 1]]] ; if {[lsearch -exact $temp $addy] == -1} {incr totalm ; lappend temp $addy}
  }
  array donesearch bs_list $id
  return "Aktualnie sledze [array size bs_list]/$bs(limit) nickow, w tym $totalm unikalnych hostow.  Najstarszy wpis to [lindex $bs_list($name) 0], ktory zostal dodany [bs_when $bs_record] temu."
}
bind dcc -|- chanstats bs_dccchanstats
proc bs_dccchanstats {hand idx args} {
  if {$args == "{}"} {set args [console $idx]} 
  if {[lindex $args 0] == "*"} {putdcc $idx "$hand, chanstats wymaga prawidlowego argumentu kanalu lub prawidlowy wpis w bazie kanalow." ; return 1}
  putdcc $idx "[bs_chanstats [lindex $args 0]]"
  return 1
}
bind pub -|- [string trim $bs(cmdchar)]chanstats bs_pubchanstats
proc bs_pubchanstats {nick uhost hand chan args} {
  global bs ; set chan [string tolower $chan]
  if {[bs_flood $nick $uhost] || [lsearch -exact $bs(no_pub) $chan] >= 0 || ($bs(log_only) != "" && [lsearch -exact $bs(log_only) [string tolower $chan]] == -1)} {return 0}
  if {[lsearch -exact $bs(quiet_chan) $chan] >= 0} {set target "notice $nick"} {set target "privmsg $chan"}
  if {[lindex $args 0] != ""} {set chan [lindex $args 0]} ; puthelp "$target :[bs_chanstats $chan]" ; return $bs(logqueries)
}
bind msg -|- chanstats bs_msgchanstats
proc bs_msgchanstats {nick uhost hand args} {global bs ; if {[bs_flood $nick $uhost]} {return 0} ; puthelp "notice $nick :[bs_chanstats [lindex $args 0]]" ; return $bs(logqueries)}
proc bs_chanstats {chan} {
  global bs_list ; set chan [string tolower $chan] ; if {![validchan $chan]} {return "Nie jestem na $chan."}
  set id [array startsearch bs_list] ; set bs_record [unixtime] ; set totalc 0 ; set totalm 0 ; set temp ""
  while {[array anymore bs_list $id]} {
    set item [array nextelement bs_list $id] ; set time [lindex $bs_list($item) 2] ; if {$time == ""} {continue}
    if {$chan == [string tolower [lindex $bs_list($item) 4]]} {
      if {$time < $bs_record} {set bs_record $time} ; incr totalc
      set addy [string tolower [maskhost [lindex $bs_list($item) 1]]]
      if {[lsearch -exact $temp $addy] == -1} {incr totalm ; lappend temp $addy}
    }
  }
  array donesearch bs_list $id ; set total [array size bs_list]
  return "$chan to [expr 100*$totalc/$total]% ($totalc/$total) wszystkich kanalow w bazie danych.  Na $chan, jest $totalm unikalnych hostow widzinaych przez [bs_when $bs_record]."
}
foreach chan [string tolower [channels]] {if {![info exists bs_botidle($chan)]} {set bs_botidle($chan) [unixtime]}}
bind join -|- * bs_join_botidle
proc bs_join_botidle {nick uhost hand chan} {
  global bs_botidle botnick
  if {$nick == $botnick} {
   set bs_botidle([string tolower $chan]) [unixtime]
  }
}
bind pub -|- [string trim $bs(cmdchar)]lastspoke lastspoke

#bugfix: fixed lastspoke to handle [blah] nicks better (c)
proc lastspoke {nick uhost hand chan args} {
  global bs botnick bs_botidle
  set chan [string tolower $chan] ; if {[bs_flood $nick $uhost] || [lsearch -exact $bs(no_pub) $chan] >= 0 || ($bs(log_only) != "" && [lsearch -exact $bs(log_only) $chan] == -1)} {return 0}
  if {[lsearch -exact $bs(quiet_chan) $chan] >= 0} {set target "notice $nick"} {set target "privmsg $chan"}
  set data [lindex [bs_filt [join $args]] 0]
  set ldata [string tolower $data]
  if {[string match *\** $data]} {
    set chanlist [string tolower [chanlist $chan]]
    if {[lsearch -glob $chanlist $ldata] > -1} {set data [lindex [chanlist $chan] [lsearch -glob $chanlist $ldata]]}
  }
  if {[onchan $data $chan]} {
    if {$ldata == [string tolower $botnick]} {puthelp "$target :$nick, musisz marnowac moj czas?" ; return 1}
    set time [getchanidle $data $chan] ; set bottime [expr ([unixtime] - $bs_botidle($chan))/60]
    if {$time < $bottime} {
      if {$time > 0} {set diftime [bs_when [expr [unixtime] - $time*60 -15]]} {set diftime "mniej niz minute"}
      puthelp "$target :$data ostatnio wypowiedzial/a slowo na $chan $diftime temu."
    } {
      set diftime [bs_when $bs_botidle($chan)]
      puthelp "$target :$data nie powiedzial/a zadnego slowa od czasu gdy wszedlem na $chan $diftime temu."
    }
  }
  return 1
}
bind msgm -|- "help seen" bs_help_msg_seen
bind msgm -|- "help chanstats" bs_help_msg_chanstats
bind msgm -|- "help seenstats" bs_help_msg_seenstats
proc bs_help_msg_seen {nick uhost hand args} {
  global bs ; if {[bs_flood $nick $uhost]} {return 0}
  puthelp "notice $nick :###  seen <query> \[chan\]          $bs(version)"
  puthelp "notice $nick :   Zapytania moga miec format:"
  puthelp "notice $nick :     'regular':  seen lamer; seen lamest "
  puthelp "notice $nick :     'masked':   seen *l?mer*; seen *.lame.com; seen *.edu #mychan" ; return 0
}
proc bs_help_msg_chanstats {nick uhost hand args} {
  global bs ; if {[bs_flood $nick $uhost]} {return 0}
  puthelp "notice $nick :###  chanstats <chan>          $bs(version)"
  puthelp "notice $nick :   Pokazuje statystyki #chan w bazie danych bseen." ; return 0
}
proc bs_help_msg_seenstats {nick uhost hand args} {
  global bs ; if {[bs_flood $nick $uhost]} {return 0}
  puthelp "notice $nick :###  seenstats          $bs(version)"
  puthelp "notice $nick :   Pokazuje statystyki bazy danych bseen." ; return 0
}
bind dcc -|- seenversion bs_version
proc bs_version {hand idx args} {global bs ; putidx $idx "###  Bass's Seen script, $bs(version)."}
bind dcc -|- help bs_help_dcc
proc bs_help_dcc {hand idx args} {
  global bs
  switch -- $args {
    seen {
      putidx $idx "###  seen <query> \[chan\]          $bs(version)" ; putidx $idx "   Zapytania moga miec format:"
      putidx $idx "     'regular':  seen lamer; seen lamest " ; putidx $idx "     'masked':   seen *l?mer*; seen *.lame.com; seen *.edu #mychan"
    }
    seennick {putidx $idx "###  seen <nick>          $bs(version)"}
    chanstats {putidx $idx "###  chanstats <chan>" ; putidx $idx "   Pokazuje statystyki #chan w bazie danych bseen."}
    seenstats {putidx $idx "###  seenstats          $bs(version)" ; putidx $idx "   Pokazuje statystyki bazy danych bseen."}
    unseen {if {[matchattr $hand n]} {putidx $idx "###  unseen <chan>          $bs(version)" ; putidx $idx "   Usuwa wszystkie wpisy <chan> z bazy danych bseen."}}
    default {*dcc:help $hand $idx [join $args] ; return 0}
  } ; return 1
}
Sorry again for flood but i got this script here in full.... So, can it be changed to work for IceChat?
Title: Re: Requesting "!seen" script
Post by: Morio on January 22, 2008, 06:07:48 AM
I'm working on a !seen script, and it's pretty much finished, just a few additions and some testing.
Title: Re: Requesting "!seen" script
Post by: Snerf on January 22, 2008, 08:37:59 AM
James, that script is just way to big, I doubt anyone would want to make the effort on converting it.
I am sure that Morio's seen script will be an adequate replacement.
Title: Re: Requesting "!seen" script
Post by: James Revan on January 22, 2008, 11:13:30 AM
Yeah i know its big, but then again there's a lot of things needed to be set. I pasted whole script cause maybe somebody knows how to rewrite TCL into IceChat. I really look forward to Morio's script, my last IRC client had this function and i will be gratefull if the one he wrote will work.
Title: Re: Requesting "!seen" script
Post by: Morio on January 22, 2008, 12:10:34 PM
Ok, the script is pretty much finished
Code: [Select]
Sub ONJOIN(Nickname,Host,Channel,ServerNumber)
  writeinifile "seen.ini",Channel,"join:" & Nickname,GetIdentifier("$day") & "." & GetIdentifier("$monthnum") & "." & GetIdentifier("$year") & " at " & GetIdentifier("$time")
  writeinifile "seen.ini",Channel,"part:" & Nickname,""
End Sub


Sub ONPART(Nickname,Host,Channel,Reason,ServerNumber)
  writeinifile "seen.ini",Channel,"part:" & Nickname,GetIdentifier("$day") & "." & GetIdentifier("$monthnum") & "." & GetIdentifier("$year") & " at " & GetIdentifier("$time")
  writeinifile "seen.ini",Channel,"join:" & Nickname,""
End Sub

Sub ONQUIT(Nickname,Host,Reason,ServerNumber)

if FileExists(getidentifier("$scriptdir")+"seen.ini") then
  channels = sections(getidentifier("$scriptdir") + "seen.ini")
    for c=lbound(channels) to ubound(channels)-1
      channel = channels(c)
      If Len(channel) > 0 then
      keys = options(getidentifier("$scriptdir") + "seen.ini",channel)
      for k=lbound(keys) to ubound(keys)
        key = keys(k)
        If instr(key,Nickname) then
          Writeinifile "seen.ini",channel,"part:" + Nickname,GetIdentifier("$day") & "." & GetIdentifier("$monthnum") & "." & GetIdentifier("$year") & " at " & GetIdentifier("$time")
          Writeinifile "seen.ini",channel,"join:" + Nickname,""
        End if
      next
    End If
    next
End If
End Sub

Sub ONKICK(Nickname,Host,Channel,WhoKicked,Reason,ServerNumber)
  writeinifile "seen.ini",Channel,"part:" & Nickname,GetIdentifier("$day") & "." & GetIdentifier("$monthnum") & "." & GetIdentifier("$year") & " at " & GetIdentifier("$time")
  writeinifile "seen.ini",Channel,"join:" & Nickname,""
End Sub

Sub ONNICK(NewNick,OldNick,ServerNumber)
if FileExists(getidentifier("$scriptdir")+"seen.ini") then
  channels = sections(getidentifier("$scriptdir") + "seen.ini")
    for c=lbound(channels) to ubound(channels)-1
      channel = channels(c)
      If Len(channel) > 0 then
      keys = options(getidentifier("$scriptdir") + "seen.ini",channel)
      for k=lbound(keys) to ubound(keys)
        key = keys(k)
        If instr(key,OldNick) then
          Writeinifile "seen.ini",channel,"join:" + OldNick,""
          Writeinifile "seen.ini",channel,"part:" + OldNick,""
          Writeinifile "seen.ini",channel,"join:" + NewNick,""
          Writeinifile "seen.ini",channel,"part:" + NewNick,""
          Writeinifile "seen.ini",channel,"join:" + NewNick,GetIdentifier("$day") & "." & GetIdentifier("$monthnum") & "." & GetIdentifier("$year") & " at " & GetIdentifier("$time")
          Writeinifile "seen.ini",channel,"part:" + OldNick,GetIdentifier("$day") & "." & GetIdentifier("$monthnum") & "." & GetIdentifier("$year") & " at " & GetIdentifier("$time")
        End if
      next
    End If
    next
End If
End Sub


Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)
if len(message) > 6 then
  if left(Message,5) = "!seen" then

    Who = Mid(Message,7)
    When = getinifile("seen.ini",Channel,"join:" & Who,"")
   
      If Len(When) > 0 then
        SendCommand "/msg " & Channel & " " & Who & " is in this channel right now",ServerNumber
      End If

      If Len(When) = 0 then
        When = getinifile("seen.ini",Channel,"part:" & Who,"")
        If Len(When) > 0 then
          SendCommand "/msg " & Channel & " " & Who & " was last seen on " & When,ServerNumber
        End If
        If Len(When) = 0 then
          SendCommand "/msg " & Channel & " " & Who & " has never been seen on this channel",ServerNumber
        End If
      End If
     

  end if
end if
End sub

Sub scan(s_channel)
if FileExists(getidentifier("$scriptdir")+"seen.ini") then
  dim objFSo, objFile
  Set objFSO = CreateObject("Scripting.FileSystemObject")
  Set objFile = objFSO.OpenTextFile(getidentifier("$scriptdir")+"seen.ini",1)
  sText = objFile.ReadAll
  sText = Left(sText,InStr(sText,"[End]")-2)

  Set objFSO = CreateObject("Scripting.FileSystemObject")
  Set objFile = objFSO.OpenTextFile(getidentifier("$scriptdir")+"seen.ini",2)
  objFile.writeLine(sText)
  objFile.close
End If


NickCount = 0
ChanCount = 0

If s_channel = "$1" then


  for i = 1 to GetIdentifier("$totalservers")

    Chanlist = GetIdentifier("$channels",i)

      channels = Split(Chanlist," ")

      for j = 0 to Ubound(channels)
        ChanCount = ChanCount + 1
        channel = channels(j)

        Nicknames = Nicks(channel,i)
        Nicknames = Split(Nicknames," ")

        for k = 0 to UBound(Nicknames)
        NickCount = NickCount + 1
        Nick = Nicknames(k)
        writeinifile "seen.ini",Channel,"join:" & Nick,GetIdentifier("$day") & "." & GetIdentifier("$monthnum") & "." & GetIdentifier("$year") & " at " & GetIdentifier("$time")
        next
      next

  next

  SendCommand "/echo -a A Total of " & NickCount & " Nicknames found on " & ChanCount & " channels, on " & GetIdentifier("$totalservers") & " networks"

End If

If Not s_channel = "$1" then
  Nicknames = Nicks(s_channel,GetIdentifier("$currentservernumber"))
  Nicknames = Split(Nicknames," ")

  for i = 0 to UBound(Nicknames)
    NickCount = NickCount + 1
    Nick = Nicknames(i)
    writeinifile "seen.ini",s_channel,"join:" & Nick,GetIdentifier("$day") & "." & GetIdentifier("$monthnum") & "." & GetIdentifier("$year") & " at " & GetIdentifier("$time")
  next

  SendCommand "/echo -a " & NickCount & " Nicknames found on channel " & s_channel

End If


  WriteIniFile "seen.ini","End","end","end"
  WriteIniFile "seen.ini","End","end",""

End Sub


Function sections(fname)
  dim objFSo, objFile
  Set objFSO = CreateObject("Scripting.FileSystemObject")
  Set objFile = objFSO.OpenTextFile(fname,1)
  sText = objFile.ReadAll
  If Len(sText) > 0 then
    arr = split(sText,vbCrLf)
    text = ""
    for i=lbound(arr) to ubound(arr)
      if left(arr(i),1)="[" then
        if len(text)>0 then
          text = text & vbCrLf & mid(arr(i),2,len(arr(i))-2)
        else
          text = mid(arr(i),2,len(arr(i))-2)
        end if
      end if
    next
    sections = split(text,vbCrLf)
  End If
End Function
 
Function options(fname,section)
  dim objFSo, objFile
  Set objFSO = CreateObject("Scripting.FileSystemObject")
  Set objFile = objFSO.OpenTextFile(fname,1)
  sText = objFile.ReadAll
  If Len(sText) > 0 then
    arr = split(sText,vbCrLf)
    text = ""
    cur = 0
    for i=lbound(arr) to ubound(arr)
      if left(arr(i),1)="[" then
        cur = (mid(arr(i),2,len(arr(i))-2)=section)
      else
        if cur then
          if len(text)>0 then
            text = text & vbCrLf & split(arr(i),"=")(0)
          else
            text = split(arr(i),"=")(0)
          end if
        end if
      end if
    next
    options = split(text,vbCrLf)
  End If
End Function

Function FileExists(fname)
Set fso = CreateObject("Scripting.FileSystemObject")
FileExists = fso.FileExists(fname)
End Function

You also need to add this to your aliases
Code: [Select]
/scan:/! scan $1
Load the script and type '/scan'
this will scan through all your channels and create an ini file with all the nicknames in those channels, note that this can take a while if you are on many/big channels, and it might seem that icechat has crashed because it won't respond while it is scanning, but it will come back to life when it's done. If icechat says that it's taking longer than expected to execute, just keep hitting continue every time you get the popup.

You should run the scan command every time you start icechat, but note that it must be run after you are connected and have joined all your channels.
when/if you join a new channel you need to do '/scan #channelname' to scan that channel and add the info to the ini.

The script won't work perfectly with multiple networks if there are channels or persons with the same name on both networks.

to use the script people simply have to type !seen nickname, this currently only work for other people, not for yourself, but I will be adding that functionality sometime soon.

If you have any problems wih the script, contact me, and I'll try to help you out.

And last but not least, a big big thank you to DarkStar, he created most of the code needed for quits and nick changes.
Title: Re: Requesting "!seen" script
Post by: James Revan on January 23, 2008, 12:25:08 AM
Really big thank you for the script, i already set it up, and no problems so far. To bad you have to run the /scan command every time you start icechat, but i just used the autoperform list. If anything will be not as it supposed to be i'll PM you.
Title: Re: Requesting "!seen" script
Post by: Morio on January 23, 2008, 03:01:59 AM
The thig is the /scan command must be run after you have joined all channels, so autoperform isn't a very good option for that. This script is more designed for people that never shut down icechat. There will be some problems with people that have parted while you were offline, because the script will still think they are online, I think I could make a small change to the scan sub to fix that.

Another thing, the script won't work very well (at all?) for channels with '[' or ']' in the channelname.

I will make the updates and post them as soon as possible.
Title: Re: Requesting "!seen" script
Post by: James Revan on January 23, 2008, 04:28:01 AM
Well i ment that i use the autoperform list manually, its much easier for me, cause i sit on about 20-30 channels, and writing /scan #channel for every one of them every time i turn on IC would take too long.
Title: Re: Requesting "!seen" script
Post by: Morio on January 23, 2008, 07:02:16 AM
ok, as long as the /scan command is run after you have joined all channels it's ok.

Anyway, here's the script with the updates/fixes

Code: [Select]
Sub ONJOIN(Nickname,Host,Channel,ServerNumber)
  writeinifile "seen.ini",Channel,"join:" & Nickname,GetIdentifier("$day") & "." & GetIdentifier("$monthnum") & "." & GetIdentifier("$year") & " at " & GetIdentifier("$time")
  writeinifile "seen.ini",Channel,"part:" & Nickname,""
End Sub


Sub ONPART(Nickname,Host,Channel,Reason,ServerNumber)
  writeinifile "seen.ini",Channel,"part:" & Nickname,GetIdentifier("$day") & "." & GetIdentifier("$monthnum") & "." & GetIdentifier("$year") & " at " & GetIdentifier("$time")
  writeinifile "seen.ini",Channel,"join:" & Nickname,""
End Sub

Sub ONQUIT(Nickname,Host,Reason,ServerNumber)

if FileExists(getidentifier("$scriptdir")+"seen.ini") then
  channels = sections(getidentifier("$scriptdir") + "seen.ini")
    for c=lbound(channels) to ubound(channels)-1
      channel = channels(c)
      If Len(channel) > 0 then
      keys = options(getidentifier("$scriptdir") + "seen.ini",channel)
      for k=lbound(keys) to ubound(keys)
        key = keys(k)
        If instr(key,Nickname) then
          Writeinifile "seen.ini",channel,"part:" + Nickname,GetIdentifier("$day") & "." & GetIdentifier("$monthnum") & "." & GetIdentifier("$year") & " at " & GetIdentifier("$time")
          Writeinifile "seen.ini",channel,"join:" + Nickname,""
        End if
      next
    End If
    next
End If
End Sub

Sub ONKICK(Nickname,Host,Channel,WhoKicked,Reason,ServerNumber)
  writeinifile "seen.ini",Channel,"part:" & Nickname,GetIdentifier("$day") & "." & GetIdentifier("$monthnum") & "." & GetIdentifier("$year") & " at " & GetIdentifier("$time")
  writeinifile "seen.ini",Channel,"join:" & Nickname,""
End Sub

Sub ONNICK(NewNick,OldNick,ServerNumber)
if FileExists(getidentifier("$scriptdir")+"seen.ini") then
  channels = sections(getidentifier("$scriptdir") + "seen.ini")
    for c=lbound(channels) to ubound(channels)-1
      channel = channels(c)
      If Len(channel) > 0 then
      keys = options(getidentifier("$scriptdir") + "seen.ini",channel)
      for k=lbound(keys) to ubound(keys)
        key = keys(k)
        If instr(key,OldNick) then
          Writeinifile "seen.ini",channel,"join:" + OldNick,""
          Writeinifile "seen.ini",channel,"part:" + OldNick,""
          Writeinifile "seen.ini",channel,"join:" + NewNick,""
          Writeinifile "seen.ini",channel,"part:" + NewNick,""
          Writeinifile "seen.ini",channel,"join:" + NewNick,GetIdentifier("$day") & "." & GetIdentifier("$monthnum") & "." & GetIdentifier("$year") & " at " & GetIdentifier("$time")
          Writeinifile "seen.ini",channel,"part:" + OldNick,GetIdentifier("$day") & "." & GetIdentifier("$monthnum") & "." & GetIdentifier("$year") & " at " & GetIdentifier("$time")
        End if
      next
    End If
    next
End If
End Sub


Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)
if len(message) > 6 then
  if left(Message,5) = "!seen" then

    Who = Mid(Message,7)
    When = getinifile("seen.ini",Channel,"join:" & Who,"")
   
      If Len(When) > 0 then
        SendCommand "/msg " & Channel & " " & Who & " is in this channel right now",ServerNumber
      End If

      If Len(When) = 0 then

        When = getinifile("seen.ini",Channel,"part:" & Who,"")

        If Len(When) > 0 and Not When = "pwo" then
          SendCommand "/msg " & Channel & " " & Who & " was last seen on " & When,ServerNumber
        End If

        If Len(When) = 0 then
          SendCommand "/msg " & Channel & " " & Who & " has never been seen on this channel",ServerNumber
        End If

        If When = "pwo" then
          SendCommand "/msg " & Channel & " " & Who & " seems to have left the channel or changed his nick while I was offline",ServerNumber
        End If
      End If
     

  end if
end if
End sub

Sub scan(s_channel)
if FileExists(getidentifier("$scriptdir")+"seen.ini") then
  dim objFSo, objFile
  Set objFSO = CreateObject("Scripting.FileSystemObject")
  Set objFile = objFSO.OpenTextFile(getidentifier("$scriptdir")+"seen.ini",1)
  sText = objFile.ReadAll
  sText = Left(sText,InStr(sText,"[End]")-2)
  If s_channel = "$1" then
    arr = Split(Stext,vbCrLf)
      Text = ""
      For i = LBound(arr) to UBound(arr)
        if Len(arr(i)) > 4 and Left(arr(i),4) = "join" then
          arr(i) = "part" & Mid(arr(i),InStr(arr(i),":"))
          arr(i) = Left(arr(i),InStr(arr(i),"=")) & "pwo"
        End If
        If Not Text = "" then
          Text = Text & vbCrLf & arr(i)
        End If
        If Text = "" then
          Text = arr(i)
        End If
      Next
    End If

  Set objFSO = CreateObject("Scripting.FileSystemObject")
  Set objFile = objFSO.OpenTextFile(getidentifier("$scriptdir")+"seen.ini",2)
  objFile.writeLine(Text)
  objFile.close




End If


NickCount = 0
ChanCount = 0

If s_channel = "$1" then


  for i = 1 to GetIdentifier("$totalservers")

    Chanlist = GetIdentifier("$channels",i)

      channels = Split(Chanlist," ")

      for j = 0 to Ubound(channels)
        ChanCount = ChanCount + 1
        channel = channels(j)

        Nicknames = Nicks(channel,i)
        Nicknames = Split(Nicknames," ")

        for k = 0 to UBound(Nicknames)
        NickCount = NickCount + 1
        Nick = Nicknames(k)
        writeinifile "seen.ini",Channel,"join:" & Nick,""
        writeinifile "seen.ini",Channel,"part:" & Nick,""
        writeinifile "seen.ini",Channel,"join:" & Nick,GetIdentifier("$day") & "." & GetIdentifier("$monthnum") & "." & GetIdentifier("$year") & " at " & GetIdentifier("$time")
        next
      next

  next

  SendCommand "/echo -a A Total of " & NickCount & " Nicknames found on " & ChanCount & " channels, on " & GetIdentifier("$totalservers") & " networks"

End If

If Not s_channel = "$1" then
  Nicknames = Nicks(s_channel,GetIdentifier("$currentservernumber"))
  Nicknames = Split(Nicknames," ")

  for i = 0 to UBound(Nicknames)
    NickCount = NickCount + 1
    Nick = Nicknames(i)
    writeinifile "seen.ini",s_channel,"join:" & Nick,GetIdentifier("$day") & "." & GetIdentifier("$monthnum") & "." & GetIdentifier("$year") & " at " & GetIdentifier("$time")
  next

  SendCommand "/echo -a " & NickCount & " Nicknames found on channel " & s_channel

End If


  WriteIniFile "seen.ini","End","end","end"
  WriteIniFile "seen.ini","End","end",""

End Sub


Function sections(fname)
  dim objFSo, objFile
  Set objFSO = CreateObject("Scripting.FileSystemObject")
  Set objFile = objFSO.OpenTextFile(fname,1)
  sText = objFile.ReadAll
  If Len(sText) > 0 then
    arr = split(sText,vbCrLf)
    text = ""
    for i=lbound(arr) to ubound(arr)
      if left(arr(i),1)="[" then
        if len(text)>0 then
          text = text & vbCrLf & mid(arr(i),2,len(arr(i))-2)
        else
          text = mid(arr(i),2,len(arr(i))-2)
        end if
      end if
    next
    sections = split(text,vbCrLf)
  End If
End Function
 
Function options(fname,section)
  dim objFSo, objFile
  Set objFSO = CreateObject("Scripting.FileSystemObject")
  Set objFile = objFSO.OpenTextFile(fname,1)
  sText = objFile.ReadAll
  If Len(sText) > 0 then
    arr = split(sText,vbCrLf)
    text = ""
    cur = 0
    for i=lbound(arr) to ubound(arr)
      if left(arr(i),1)="[" then
        cur = (mid(arr(i),2,len(arr(i))-2)=section)
      else
        if cur then
          if len(text)>0 then
            text = text & vbCrLf & split(arr(i),"=")(0)
          else
            text = split(arr(i),"=")(0)
          end if
        end if
      end if
    next
    options = split(text,vbCrLf)
  End If
End Function

Function FileExists(fname)
Set fso = CreateObject("Scripting.FileSystemObject")
FileExists = fso.FileExists(fname)
End Function

If you join a channel that you have never been on before it's ok to use the '/scan #channelname" command, but if it isn't a new channel for you and you have been there before, you need to scan through the entire channel list with the '/scan' command ('/scan #channelname' won't work properly)

when using the '/scan' command ('/scan #channelname' won't work), the people who were on the channel when you left but aren't there now, will get a "pwo" tag (parted while offline) and when someone tries to check when they have been seen, they get the message 'Nickname seems to have left the channel or changed his nick while I was offline"
Title: Re: Requesting "!seen" script
Post by: James Revan on January 23, 2008, 07:13:30 AM
Could you change the script so it would be automaticly updated? As it is right now it says the nick someone is looking for is on the channel when it quited, and i have to run the scan command again.

Is this how it should work? Or am I doing something wrong?
Title: Re: Requesting "!seen" script
Post by: Morio on January 23, 2008, 07:24:33 AM
when you quit you have to scan again after connecting. That's just the way it'll have to be, since there's now way of knowing what happens in the channel while you are offline.
Title: Re: Requesting "!seen" script
Post by: Morio on January 23, 2008, 07:33:13 AM
And also my script works pretty much in the same way as the one you sent me (I think) if you look at the seen .ini it will look something like:
[#channel]
join:somenick=somedate and sometime
part:someothernick=somedate = sometime
.
.
.


when someone types !seen somenick the script returns the value after the '=' it first checks for joins, if it finds a line with 'join:somenick' in the correct section for that channel it will say that the person is online, because he hasn't been seen leaving or changing his nick. If it doesn't find a line starting with that it will search for a line starting with 'part:somenick' again in the correct section, if that like is found and the stuff after the '0' isn't 'pwo' it will return the time fo the part, and if the text after the '=' is 'pwo' it will tell that the nick has disappeared while you were offline.

when a person changes his nick it will record it as the old nick parting and the new one joining.
Title: Re: Requesting "!seen" script
Post by: James Revan on January 23, 2008, 07:34:27 AM
I didn't quit..
There was a guy, lets say his nick was "dude". I recorded his nick when he was on the channel, then he quitted. I asked my friend to type !seen dude and the script was telling that "dude" is still on the channel when he quitted 5 minutes earlier.
Title: Re: Requesting "!seen" script
Post by: Morio on January 23, 2008, 07:43:04 AM
hmm, that's weird, I've been testing the script, and I see now problems with recording the quits and it does remove the join from the file too.

The channel doesn't happen to have '[' or ']' in the name, does it?
Title: Re: Requesting "!seen" script
Post by: James Revan on January 23, 2008, 07:51:14 AM
Nope, it has a "." if that changes anything
Title: Re: Requesting "!seen" script
Post by: Morio on January 23, 2008, 09:10:54 AM
The '.' should make no difference.

Have you tried checking the seen.ini file? There should be a line like part:dude=... and no line like join:dude=... in the section for that channel, and the section should appear only once.
Title: Re: Requesting "!seen" script
Post by: James Revan on January 23, 2008, 10:29:43 AM
Well checked that now, rather strange. Got only one channel when it should be 23
Title: Re: Requesting "!seen" script
Post by: Morio on January 23, 2008, 11:11:59 AM
what message do you get when you run the '/scan' command? It should be something like 'x nicknames found on y channels, on z servers'
Title: Re: Requesting "!seen" script
Post by: James Revan on January 23, 2008, 02:10:34 PM
what message do you get when you run the '/scan' command? It should be something like 'x nicknames found on y channels, on z servers'
Yeah, it is like this.
Title: Re: Requesting "!seen" script
Post by: Morio on January 24, 2008, 03:33:46 AM
Could you tell me the exact numbers in the message?

Also did you check the seen.in i throughly?

Also I made a security update to the script, as it could be abused, now it won't respond to messages where the nickname part starts with '!', '+', '.' or if it contains epmty spaces (this could be abused by typing '!seen !somecommand' then the reply would be '!somecommand has never been seen on this channel') And afaik, no nicknames can contain those characters.

Code: [Select]
Sub ONJOIN(Nickname,Host,Channel,ServerNumber)
  writeinifile "seen.ini",Channel,"join:" & Nickname,GetIdentifier("$day") & "." & GetIdentifier("$monthnum") & "." & GetIdentifier("$year") & " at " & GetIdentifier("$time")
  writeinifile "seen.ini",Channel,"part:" & Nickname,""
End Sub


Sub ONPART(Nickname,Host,Channel,Reason,ServerNumber)
  writeinifile "seen.ini",Channel,"part:" & Nickname,GetIdentifier("$day") & "." & GetIdentifier("$monthnum") & "." & GetIdentifier("$year") & " at " & GetIdentifier("$time")
  writeinifile "seen.ini",Channel,"join:" & Nickname,""
End Sub

Sub ONQUIT(Nickname,Host,Reason,ServerNumber)

if FileExists(getidentifier("$scriptdir")+"seen.ini") then
  channels = sections(getidentifier("$scriptdir") + "seen.ini")
    for c=lbound(channels) to ubound(channels)-1
      channel = channels(c)
      If Len(channel) > 0 then
      keys = options(getidentifier("$scriptdir") + "seen.ini",channel)
      for k=lbound(keys) to ubound(keys)
        key = keys(k)
        If instr(key,Nickname) then
          Writeinifile "seen.ini",channel,"part:" + Nickname,GetIdentifier("$day") & "." & GetIdentifier("$monthnum") & "." & GetIdentifier("$year") & " at " & GetIdentifier("$time")
          Writeinifile "seen.ini",channel,"join:" + Nickname,""
        End if
      next
    End If
    next
End If
End Sub

Sub ONKICK(Nickname,Host,Channel,WhoKicked,Reason,ServerNumber)
  writeinifile "seen.ini",Channel,"part:" & Nickname,GetIdentifier("$day") & "." & GetIdentifier("$monthnum") & "." & GetIdentifier("$year") & " at " & GetIdentifier("$time")
  writeinifile "seen.ini",Channel,"join:" & Nickname,""
End Sub

Sub ONNICK(NewNick,OldNick,ServerNumber)
if FileExists(getidentifier("$scriptdir")+"seen.ini") then
  channels = sections(getidentifier("$scriptdir") + "seen.ini")
    for c=lbound(channels) to ubound(channels)-1
      channel = channels(c)
      If Len(channel) > 0 then
      keys = options(getidentifier("$scriptdir") + "seen.ini",channel)
      for k=lbound(keys) to ubound(keys)
        key = keys(k)
        If instr(key,OldNick) then
          Writeinifile "seen.ini",channel,"join:" + OldNick,""
          Writeinifile "seen.ini",channel,"part:" + OldNick,""
          Writeinifile "seen.ini",channel,"join:" + NewNick,""
          Writeinifile "seen.ini",channel,"part:" + NewNick,""
          Writeinifile "seen.ini",channel,"join:" + NewNick,GetIdentifier("$day") & "." & GetIdentifier("$monthnum") & "." & GetIdentifier("$year") & " at " & GetIdentifier("$time")
          Writeinifile "seen.ini",channel,"part:" + OldNick,GetIdentifier("$day") & "." & GetIdentifier("$monthnum") & "." & GetIdentifier("$year") & " at " & GetIdentifier("$time")
        End if
      next
    End If
    next
End If
End Sub


Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)
if len(message) > 6 then
  if left(Message,5) = "!seen" then

    Who = Mid(Message,7)
    When = getinifile("seen.ini",Channel,"join:" & Who,"")
    If Not (Left(Who,1) = "!" or Left(Who,1) = "+" or Left(Who,1) = "." or InStr(Who," ") > 0)then
   
      If Len(When) > 0 then
        SendCommand "/msg " & Channel & " " & Who & " is in this channel right now",ServerNumber
      End If

      If Len(When) = 0 then

        When = getinifile("seen.ini",Channel,"part:" & Who,"")

        If Len(When) > 0 and Not When = "pwo" then
          SendCommand "/msg " & Channel & " " & Who & " was last seen on " & When,ServerNumber
        End If

        If Len(When) = 0 then
          SendCommand "/msg " & Channel & " " & Who & " has never been seen on this channel",ServerNumber
        End If

        If When = "pwo" then
          SendCommand "/msg " & Channel & " " & Who & " seems to have left the channel or changed his nick while I was offline",ServerNumber
        End If
      End If
     
    End If
  End if
End if
End sub

Sub scan(s_channel)
if FileExists(getidentifier("$scriptdir")+"seen.ini") then
  dim objFSo, objFile
  Set objFSO = CreateObject("Scripting.FileSystemObject")
  Set objFile = objFSO.OpenTextFile(getidentifier("$scriptdir")+"seen.ini",1)
  sText = objFile.ReadAll
  sText = Left(sText,InStr(sText,"[End]")-2)
  If s_channel = "$1" then
    arr = Split(Stext,vbCrLf)
      Text = ""
      For i = LBound(arr) to UBound(arr)
        if Len(arr(i)) > 4 and Left(arr(i),4) = "join" then
          arr(i) = "part" & Mid(arr(i),InStr(arr(i),":"))
          arr(i) = Left(arr(i),InStr(arr(i),"=")) & "pwo"
        End If
        If Not Text = "" then
          Text = Text & vbCrLf & arr(i)
        End If
        If Text = "" then
          Text = arr(i)
        End If
      Next
    End If

  Set objFSO = CreateObject("Scripting.FileSystemObject")
  Set objFile = objFSO.OpenTextFile(getidentifier("$scriptdir")+"seen.ini",2)
  objFile.writeLine(Text)
  objFile.close




End If


NickCount = 0
ChanCount = 0

If s_channel = "$1" then


  for i = 1 to GetIdentifier("$totalservers")

    Chanlist = GetIdentifier("$channels",i)

      channels = Split(Chanlist," ")

      for j = 0 to Ubound(channels)
        ChanCount = ChanCount + 1
        channel = channels(j)

        Nicknames = Nicks(channel,i)
        Nicknames = Split(Nicknames," ")

        for k = 0 to UBound(Nicknames)
        NickCount = NickCount + 1
        Nick = Nicknames(k)
        writeinifile "seen.ini",Channel,"join:" & Nick,""
        writeinifile "seen.ini",Channel,"part:" & Nick,""
        writeinifile "seen.ini",Channel,"join:" & Nick,GetIdentifier("$day") & "." & GetIdentifier("$monthnum") & "." & GetIdentifier("$year") & " at " & GetIdentifier("$time")
        next
      next

  next

  SendCommand "/echo -a A Total of " & NickCount & " Nicknames found on " & ChanCount & " channels, on " & GetIdentifier("$totalservers") & " networks"

End If

If Not s_channel = "$1" then
  Nicknames = Nicks(s_channel,GetIdentifier("$currentservernumber"))
  Nicknames = Split(Nicknames," ")

  for i = 0 to UBound(Nicknames)
    NickCount = NickCount + 1
    Nick = Nicknames(i)
    writeinifile "seen.ini",s_channel,"join:" & Nick,GetIdentifier("$day") & "." & GetIdentifier("$monthnum") & "." & GetIdentifier("$year") & " at " & GetIdentifier("$time")
  next

  SendCommand "/echo -a " & NickCount & " Nicknames found on channel " & s_channel

End If


  WriteIniFile "seen.ini","End","end","end"
  WriteIniFile "seen.ini","End","end",""

End Sub


Function sections(fname)
  dim objFSo, objFile
  Set objFSO = CreateObject("Scripting.FileSystemObject")
  Set objFile = objFSO.OpenTextFile(fname,1)
  sText = objFile.ReadAll
  If Len(sText) > 0 then
    arr = split(sText,vbCrLf)
    text = ""
    for i=lbound(arr) to ubound(arr)
      if left(arr(i),1)="[" then
        if len(text)>0 then
          text = text & vbCrLf & mid(arr(i),2,len(arr(i))-2)
        else
          text = mid(arr(i),2,len(arr(i))-2)
        end if
      end if
    next
    sections = split(text,vbCrLf)
  End If
End Function
 
Function options(fname,section)
  dim objFSo, objFile
  Set objFSO = CreateObject("Scripting.FileSystemObject")
  Set objFile = objFSO.OpenTextFile(fname,1)
  sText = objFile.ReadAll
  If Len(sText) > 0 then
    arr = split(sText,vbCrLf)
    text = ""
    cur = 0
    for i=lbound(arr) to ubound(arr)
      if left(arr(i),1)="[" then
        cur = (mid(arr(i),2,len(arr(i))-2)=section)
      else
        if cur then
          if len(text)>0 then
            text = text & vbCrLf & split(arr(i),"=")(0)
          else
            text = split(arr(i),"=")(0)
          end if
        end if
      end if
    next
    options = split(text,vbCrLf)
  End If
End Function

Function FileExists(fname)
Set fso = CreateObject("Scripting.FileSystemObject")
FileExists = fso.FileExists(fname)
End Function
Title: Re: Requesting "!seen" script
Post by: jcof on January 19, 2009, 11:36:53 AM
[17:31:21]  ->> ERROR:modScriptFunctions:seen.ice:Function:LoadScriptFile: Error Number:1032 : Invalid character
[17:35:44]  ->> ERROR:modScriptFunctions:seen.ice:Function:LoadScriptFile: Error Number:1032 : Invalid character

[17:36:00] -- Script Engine Error:13:Type mismatch: 'scan': Line #1 --
[17:36:07] -- Script Engine Error:13:Type mismatch: 'scan': Line #1 --
[17:36:11] -- Script Engine Error:13:Type mismatch: 'scan': Line #1 --
[17:21:39] -- Script Engine Error:1002:Syntax error: Line #1 -- scan #channel

well these are the errors I'm getting and I cant fix it any help?  :?
Title: Re: Requesting "!seen" script
Post by: Atreus on January 19, 2009, 11:49:18 AM
You want my version, which is know to be errorless?  :-D
Title: Re: Requesting "!seen" script
Post by: Morio on January 19, 2009, 12:10:12 PM
This is an old script that never worked perfectly, I wrote a new one a while ago, and it's found in the download section of this site

or here if you're lazy (http://www.icechat.net/site/download.php?file=47)
Title: Re: Requesting "!seen" script
Post by: jcof on January 19, 2009, 04:57:40 PM
Yeah I downloaded it from the download section the first time and now from yourlink, it still give me the same error though. i added that command to alias /scan: something like this but no lucky! :(
Title: Re: Requesting "!seen" script
Post by: Snerf on January 19, 2009, 07:36:35 PM
It is supposed to be added as an alias.
So you go to the IceChat Editor, in the Aliases tab and add this.

/scan:/! scan $1

If that does not work, then the script was not loaded properly.
Title: Re: Requesting "!seen" script
Post by: HKboy on February 13, 2009, 02:22:24 AM
Mario, nice seen script, I'm using it.

But can you make it so, that it only works in some channels, OR that only me can use it (maybe this is better, as BotServ usually has the seen script)?

Sorry, but I can't understand the scripting style of Icechat
Title: Re: Requesting "!seen" script
Post by: Morio on February 13, 2009, 03:40:43 AM
I'm starting to think all new IceChat users come from a parallel universe where o is the same as a

anyway, back to your request.

To make the script work for you only, remove the ONTEXT sub in the script

To make the script work only in one or more channels (and still work for everyone) add this line to the beginning of the ONTEXT sub
Code: [Select]
If Not (Channel="#channelname" or Channel = "#someotherchannel") then exit sub

If you want to exclude one or more channels add this
Code: [Select]
If Channel="#channelname" or Channel = "#someotherchannel" then exit sub

fore only one channel, you can remove the parentheses and the "or Channel = ..."

The script will still record data for all channels, but it won't trigger when someone uses the !seen command.
Title: Re: Requesting "!seen" script
Post by: HKboy on February 14, 2009, 01:15:42 PM
I'm starting to think all new IceChat users come from a parallel universe where o is the same as a
I'm not new with icechat, I just never cared about icechat scripting.


I've experimented, and this is what I came with:
Code: [Select]
If Nickname="HKboy" or Nickname = "Diffybot" then
I just did that, and it worked =). Thank you Morio.
Title: Re: Requesting "!seen" script
Post by: Socom on May 04, 2009, 08:29:10 AM
I keep getting two errors.. upon loading the script I get:

[11:26]  ->> ERROR:modScriptFunctions:seen.ice:Function:LoadScriptFile: Error Number:1032 : Invalid character

When I run the /scan I get:

[11:27] -- Script Engine Error:1032:Invalid character: Line #335 -- __________ Information from ESET NOD32 Antivirus, version of virus signaturedatabase 3631 (20081121) __________
[11:27] -- Script Engine Error:1002:Syntax error: Line #1 -- scan #EoD

I have tried removing the script and reloading it.. but no such luck.. any ideas?
Title: Re: Requesting "!seen" script
Post by: Snerf on May 04, 2009, 08:32:09 AM
Best if you just post the lines that are producing those errors, to see what the problem is. An invalid character means the script was written wrong somewhere.
Title: Re: Requesting "!seen" script
Post by: Socom on May 04, 2009, 08:34:20 AM
Line1: '#####################

Line 335:    SendCommand "/msg " & Channel & " " & Who & " has never been seen on this channel",ServerNumber


Hope that helps
Title: Re: Requesting "!seen" script
Post by: Snerf on May 04, 2009, 08:42:04 AM
Well, both of those look fine, but line 335 looks like something else.

At line #1 it is seeing "scan #EOD" .. that must be somewhere there. Unless you have it in another script.

At the very bottom of the script, does it have "__________ Information from ESET NOD32 Antivirus, version of virus signaturedatabase 3631 (20081121) __________" or such, those lines should be removed, it looks like a NOD32 Tag (Thats an antivirus)
Title: Re: Requesting "!seen" script
Post by: Socom on May 04, 2009, 08:51:01 AM
The line 1 error was it echoing my /scan #EoD

Found the code at the bottom.. removed.. all errors are gone.. works perfect!

Thank you..

Anyway to allow for wildcards with the !seen?
Title: Re: Requesting "!seen" script
Post by: Snerf on May 04, 2009, 11:26:12 AM
The script would have to be modified to allow for wild cards.
Title: Re: Requesting "!seen" script
Post by: Manyman on July 11, 2010, 11:29:29 PM
Can sombody show me the code for when somebody types !seen Manyman or !seen Awayman it shows a message. Below is my code:
Code: [Select]
Sub ONJOIN(Nickname,Host,Channel,ServerNumber)
  writeinifile "seen.ini",Channel,"join:" & Nickname,GetIdentifier("$day") & "." & GetIdentifier("$monthnum") & "." & GetIdentifier("$year") & " at " & GetIdentifier("$time")
  writeinifile "seen.ini",Channel,"part:" & Nickname,""
End Sub


Sub ONPART(Nickname,Host,Channel,Reason,ServerNumber)
  writeinifile "seen.ini",Channel,"part:" & Nickname,GetIdentifier("$day") & "." & GetIdentifier("$monthnum") & "." & GetIdentifier("$year") & " at " & GetIdentifier("$time")
  writeinifile "seen.ini",Channel,"join:" & Nickname,""
End Sub

Sub ONQUIT(Nickname,Host,Reason,ServerNumber)

if FileExists(getidentifier("$scriptdir")+"seen.ini") then
  channels = sections(getidentifier("$scriptdir") + "seen.ini")
    for c=lbound(channels) to ubound(channels)-1
      channel = channels(c)
      If Len(channel) > 0 then
      keys = options(getidentifier("$scriptdir") + "seen.ini",channel)
      for k=lbound(keys) to ubound(keys)
        key = keys(k)
        If instr(key,Nickname) then
          Writeinifile "seen.ini",channel,"part:" + Nickname,GetIdentifier("$day") & "." & GetIdentifier("$monthnum") & "." & GetIdentifier("$year") & " at " & GetIdentifier("$time")
          Writeinifile "seen.ini",channel,"join:" + Nickname,""
        End if
      next
    End If
    next
End If
End Sub

Sub ONKICK(Nickname,Host,Channel,WhoKicked,Reason,ServerNumber)
  writeinifile "seen.ini",Channel,"part:" & Nickname,GetIdentifier("$day") & "." & GetIdentifier("$monthnum") & "." & GetIdentifier("$year") & " at " & GetIdentifier("$time")
  writeinifile "seen.ini",Channel,"join:" & Nickname,""
End Sub

Sub ONNICK(NewNick,OldNick,ServerNumber)
if FileExists(getidentifier("$scriptdir")+"seen.ini") then
  channels = sections(getidentifier("$scriptdir") + "seen.ini")
    for c=lbound(channels) to ubound(channels)-1
      channel = channels(c)
      If Len(channel) > 0 then
      keys = options(getidentifier("$scriptdir") + "seen.ini",channel)
      for k=lbound(keys) to ubound(keys)
        key = keys(k)
        If instr(key,OldNick) then
          Writeinifile "seen.ini",channel,"join:" + OldNick,""
          Writeinifile "seen.ini",channel,"part:" + OldNick,""
          Writeinifile "seen.ini",channel,"join:" + NewNick,""
          Writeinifile "seen.ini",channel,"part:" + NewNick,""
          Writeinifile "seen.ini",channel,"join:" + NewNick,GetIdentifier("$day") & "." & GetIdentifier("$monthnum") & "." & GetIdentifier("$year") & " at " & GetIdentifier("$time")
          Writeinifile "seen.ini",channel,"part:" + OldNick,GetIdentifier("$day") & "." & GetIdentifier("$monthnum") & "." & GetIdentifier("$year") & " at " & GetIdentifier("$time")
        End if
      next
    End If
    next
End If
End Sub

Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)
If Channel="#wikia" or Channel="#wikia-vstf" or Channel="#cvn-wikia" then exit sub
if len(message) > 6 then
  if left(Message,5) = "!seen" then

    Who = Mid(Message,7)
    When = getinifile("seen.ini",Channel,"join:" & Who,"")
    If Not (Left(Who,1) = "!" or Left(Who,1) = "+" or Left(Who,1) = "." or InStr(Who," ") > 0)then
   
      If Len(When) > 0 then
        SendCommand "/msg " & Channel & " " & Who & " is in this channel right now",ServerNumber
      End If

      If Len(When) = 0 then

        When = getinifile("seen.ini",Channel,"part:" & Who,"")

        If Len(When) > 0 and Not When = "pwo" then
          SendCommand "/msg " & Channel & " " & Who & " was last seen on " & When,ServerNumber
        End If

        If Len(When) = 0 then
          SendCommand "/msg " & Channel & " " & Who & " has never been seen on this channel",ServerNumber
        End If

        If When = "pwo" then
          SendCommand "/msg " & Channel & " " & Who & " seems to have left the channel or changed his nick while I was offline",ServerNumber
        End If
      End If
     
    End If
  End if
End if
End sub

Sub scan(s_channel)
if FileExists(getidentifier("$scriptdir")+"seen.ini") then
  dim objFSo, objFile
  Set objFSO = CreateObject("Scripting.FileSystemObject")
  Set objFile = objFSO.OpenTextFile(getidentifier("$scriptdir")+"seen.ini",1)
  sText = objFile.ReadAll
  sText = Left(sText,InStr(sText,"[End]")-2)
  If s_channel = "$1" then
    arr = Split(Stext,vbCrLf)
      Text = ""
      For i = LBound(arr) to UBound(arr)
        if Len(arr(i)) > 4 and Left(arr(i),4) = "join" then
          arr(i) = "part" & Mid(arr(i),InStr(arr(i),":"))
          arr(i) = Left(arr(i),InStr(arr(i),"=")) & "pwo"
        End If
        If Not Text = "" then
          Text = Text & vbCrLf & arr(i)
        End If
        If Text = "" then
          Text = arr(i)
        End If
      Next
    End If

  Set objFSO = CreateObject("Scripting.FileSystemObject")
  Set objFile = objFSO.OpenTextFile(getidentifier("$scriptdir")+"seen.ini",2)
  objFile.writeLine(Text)
  objFile.close




End If


NickCount = 0
ChanCount = 0

If s_channel = "$1" then


  for i = 1 to GetIdentifier("$totalservers")

    Chanlist = GetIdentifier("$channels",i)

      channels = Split(Chanlist," ")

      for j = 0 to Ubound(channels)
        ChanCount = ChanCount + 1
        channel = channels(j)

        Nicknames = Nicks(channel,i)
        Nicknames = Split(Nicknames," ")

        for k = 0 to UBound(Nicknames)
        NickCount = NickCount + 1
        Nick = Nicknames(k)
        writeinifile "seen.ini",Channel,"join:" & Nick,""
        writeinifile "seen.ini",Channel,"part:" & Nick,""
        writeinifile "seen.ini",Channel,"join:" & Nick,GetIdentifier("$day") & "." & GetIdentifier("$monthnum") & "." & GetIdentifier("$year") & " at " & GetIdentifier("$time")
        next
      next

  next

  SendCommand "/echo -a A Total of " & NickCount & " Nicknames found on " & ChanCount & " channels, on " & GetIdentifier("$totalservers") & " networks"

End If

If Not s_channel = "$1" then
  Nicknames = Nicks(s_channel,GetIdentifier("$currentservernumber"))
  Nicknames = Split(Nicknames," ")

  for i = 0 to UBound(Nicknames)
    NickCount = NickCount + 1
    Nick = Nicknames(i)
    writeinifile "seen.ini",s_channel,"join:" & Nick,GetIdentifier("$day") & "." & GetIdentifier("$monthnum") & "." & GetIdentifier("$year") & " at " & GetIdentifier("$time")
  next

  SendCommand "/echo -a " & NickCount & " Nicknames found on channel " & s_channel

End If


  WriteIniFile "seen.ini","End","end","end"
  WriteIniFile "seen.ini","End","end",""

End Sub


Function sections(fname)
  dim objFSo, objFile
  Set objFSO = CreateObject("Scripting.FileSystemObject")
  Set objFile = objFSO.OpenTextFile(fname,1)
  sText = objFile.ReadAll
  If Len(sText) > 0 then
    arr = split(sText,vbCrLf)
    text = ""
    for i=lbound(arr) to ubound(arr)
      if left(arr(i),1)="[" then
        if len(text)>0 then
          text = text & vbCrLf & mid(arr(i),2,len(arr(i))-2)
        else
          text = mid(arr(i),2,len(arr(i))-2)
        end if
      end if
    next
    sections = split(text,vbCrLf)
  End If
End Function
 
Function options(fname,section)
  dim objFSo, objFile
  Set objFSO = CreateObject("Scripting.FileSystemObject")
  Set objFile = objFSO.OpenTextFile(fname,1)
  sText = objFile.ReadAll
  If Len(sText) > 0 then
    arr = split(sText,vbCrLf)
    text = ""
    cur = 0
    for i=lbound(arr) to ubound(arr)
      if left(arr(i),1)="[" then
        cur = (mid(arr(i),2,len(arr(i))-2)=section)
      else
        if cur then
          if len(text)>0 then
            text = text & vbCrLf & split(arr(i),"=")(0)
          else
            text = split(arr(i),"=")(0)
          end if
        end if
      end if
    next
    options = split(text,vbCrLf)
  End If
End Function

Function FileExists(fname)
Set fso = CreateObject("Scripting.FileSystemObject")
FileExists = fso.FileExists(fname)
End Function
Manyman
Title: Re: Requesting "!seen" script
Post by: Morio on July 12, 2010, 05:57:50 AM
Manyman: Basically the whole ONTEXT sub is used for the message. There is three possible messages, and you should be able to figure out which is which.
Title: Re: Requesting "!seen" script
Post by: Snerf on July 12, 2010, 02:51:39 PM
You also have to remember that ONTEXT does not fire when you type something, only when someone else does.
Title: Re: Requesting "!seen" script
Post by: pokereyes on January 04, 2011, 09:19:37 AM
Sorry if this is in the wrong place I am new to this, so please don't shoot me :-D

I have downloaded the latest !seen script for icechat that can be found here but I would like to edit it so that it will search all the channels I am connected to and return something like the following:

Nick is on #channel #channels at the moment
Nick was last seen leaving #channel (should be any of the channels my bot is connected to and not just the channel !seen is run in)

So in short I would like to edit it to do cross channel search and response's is this possible and could someone give me a kick start with what sort of additions would be needed.

Thanks...
Title: Re: Requesting "!seen" script
Post by: Morio on January 04, 2011, 01:13:59 PM
Due to the way the script stores the data, it would be easy to see on which channels a nick is (and in fact the script does exactly that on certain occasions)

Just search for the nickname in the network.ini (for example QuakeNet.ini) file in the "scripts\seen" folder, and you will get a list of all the channels that nick is on, on that network
Title: Re: Requesting "!seen" script
Post by: pokereyes on January 05, 2011, 03:23:39 AM
Thank you for getting back to me so quickly and yes I had seen that folder in the seen folder but being a total newbie to bot making could you please tewll me how I can incorperate that into my script so that it always searches that folder as I am trying to edit it at the moment to add a !where but it doesn't work at all for me. so basically you will run !seen in a channel and you get the response never seen or left at blaa blaaa blaaa then you can run a !where and it will respond nick can be found at or was last seen leaving etc...

Thank...
Title: Re: Requesting "!seen" script
Post by: Morio on January 05, 2011, 05:05:28 AM
This line will get the list of the channels a nickname is on and store it in a variable named "Channels" (Keep in mind that you need to put the nick you are looking for into the variable "Nickname" first.

Code: [Select]
Channels = getinifile(SeenDirectory & NW & ".ini","nicknames","online:" & Nickname,"")
Keep in mind that the ini file only tracks nicknames that are online, it doesn't store the information in the same way after they have left a channel. That information is stored in separate files for each channel. You could make it search through the files for every channel that you are on, but it might be quite slow
Title: Re: Requesting "!seen" script
Post by: pokereyes on January 05, 2011, 12:09:31 PM
 :-D I have got it working exactly as I want it thank you for all the help  :-D
Title: Re: Requesting "!seen" script
Post by: Muttley9 on February 28, 2012, 09:14:17 AM
I keep getting an "database mismatch, run the /scan command to fix the problem" error in console.
I have added the line '/scan:/! scan $1' to the aliases
I have also added aliases for each of the three channels I frequent as follows:
'/sb /scan #channel' etc.
After logging in, I run /scan from the console. I then run each channel; I realize I can group them :)
Any solutions to this issue?
Also one channel I frequent has MANY Guest1234 joins and parts; is there a way to filter these out?
Many thanks  :-D