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

Seend script. Latest version: 1.8.3
Goto page 1, 2  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases
View previous topic :: View next topic  
Author Message
lee8oi
Halfop


Joined: 04 Jun 2011
Posts: 63
Location: Michigan,United States.

PostPosted: Sat Jun 04, 2011 2:39 pm    Post subject: Seend script. Latest version: 1.8.3 Reply with quote

***Note: This script is still available but may not see much development. It has been forked to "statusd". Check out the topic at http://forum.egghelp.org/viewtopic.php?t=18581 for more information.***

From v1.8.3:
Seend is a seen script that will tell you how long ago the bot last seen the specified nick, what channel they were on, and what their last message was to that channel. It also allows you to do partial nick searches using * and even lets you .seen yourself!

Seend uses an automatic system for backing up and restoring seen data. Which also includes the .seend partyline command for manually backing up and restoring seen data.

In the config section owners can enable/disable: User name prefixing, displaying last channel, and displaying last message. Also can set up Not seen responses, bot search for self response, backup file location/name, automatic backup interval time, toggle seen requests, interval backup logging, show time as duration, and public & dcc command triggers.

Note: See latest posts of this topic for the latest version of Seend. The different versions remain posted for reference. v1.1 has been removed. Only v1.2 and newer will be posted from here on.
latest testing release of Seend can be found on github at: https://github.com/lee8oi/seend/blob/master/seend.tcl

Also: Users of Sseend v1.4 or earlier will need to update channel flags to upgrade to Seend 1.5 or newer. Remove 'sseen' and add 'seend' to each channel as needed.

Please do let me know what you think of this script but please save your breath if you don't have anything nice or constructive to say. I'm volunteering my time willingly for this project, and I"m sharing my progress as a way of giving back to the community that gave to me.Thanks again. And Enjoy!

Arrow~SAY NO TO SPAM!~
_________________
https://github.com/lee8oi
https://code.google.com/u/lee8oi/


Last edited by lee8oi on Mon Oct 24, 2011 10:00 am; edited 16 times in total
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2829

PostPosted: Sat Jun 04, 2011 3:26 pm    Post subject: Reply with quote

A few comments:

_showcurtime:
You define a global variable (dateformat) which is never defined nor used. You could also avoid the local variable _curtime by directly returning the value of clock seconds directly.
Further, this proc could completely be replaced with clock seconds as is.

pub_show_seen:
lindex operates on proper tcl-lists, not strings. Random chatter should never be considdered a valid list, but a string. If you need to extract the first word of a string, you could convert it into a list using the split command first:
Code:
lindex [split "Some string"] 0

Rather than comparing the word against the global variable "botnick", I'd recommend you use the isbotnick command, which rfc1459 case-insensitive comparison
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
lee8oi
Halfop


Joined: 04 Jun 2011
Posts: 63
Location: Michigan,United States.

PostPosted: Sat Jun 04, 2011 3:32 pm    Post subject: Reply with quote

Thanks! the dateformat global was left over from samu's Sseen. The lindex thing also. But I worked in your suggestions. Thanks again!
_________________
https://github.com/lee8oi
https://code.google.com/u/lee8oi/
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
lee8oi
Halfop


Joined: 04 Jun 2011
Posts: 63
Location: Michigan,United States.

PostPosted: Sat Jun 04, 2011 5:57 pm    Post subject: Reply with quote

Ok finished implementing the changes. Bumped to version '1.2' Heres the code:
Code:

#  ----------------------------------------------------------
#
#   Sseend v 1.2 (6-4-11-3)
#   by: <lee8oiAtgmail><lee8oiOnfreenode> (thanks thommey)
#
#   Original Sseend v1.0 based on:
#   Sseen v 0.2.22 by samu (IRC: samu@pirc.pl)
#
#  ----------------------------------------------------------
#
#  This is Simple Seen 'Duke' (pronounced 'Seend' by lee8oi).
#  Sseend is a seen script forked from Sseen that will tell you how
#  long ago the bot last seen the specified nick, what channel they
#  were on, and what their last message was to that channel. Sseend
#  also allows users to .seen themselves! (demanded feature believe it or not).
#
#  Initial channel setup:
#  (starts logging and enables .seen command)
#    .chanset #channel +sseen
#
#  Public command syntax:
#    .seen <username>
#  or
#    .seen me
#
#  Example Usage:
#    <lee8oi> .seen lee8oi
#    <dukelovett> I last saw you 1 hour 3 minutes 39 seconds ago on
#    #dukelovett saying: Sseen script was awsome. My version improves on
#    it.
#
#  Note:
#    Restarting the bot will clear all stored seen data. But Rehashing
#    normally does not clear the data.

#  Updates log:
#    v1.0:
#    1. Users can .seen themselves (Strange but popular).
#    2. .seen command lines are now ignored. This allows users "seening"
#       themselves to get results besides the command they just ran.
#    3. Sseend now keeps track of the users last message.
#    4. Lastseen time now shown as a duration instead of a time to
#       better serve users accross multiple timezones.
#    5. Bot can now cleverly respond to requests for it to 'seen'
#       itself.
#    6. Users can now do '.seen me' to seen themselves.
#
#    v1.1
#    1. Bot now replies correctly if users seen themselves before
#       any seen data is saved.
#    2. Added code changes suggested by nml375 including using isbotnick
#       instead of comparing to global var botnick.
#
#    v1.2
#    1. Removed _showcurtime procedure because the new duration
#       system doesn't require it.
#
#  TODO:
#  <> Add a system for backing up and restoring seen data.
#
#  ----------------------------------------------------------

bind pubm - * public_msg_save
bind sign - * public_msg_save
bind pub - .seen pub_show_seen

set ver "1.2"


setudef flag sseen

proc public_msg_save {nick userhost handle channel text} {
   global lastseen
   global lastchan
   global lastmsg
   if {[channel get $channel sseen]} {
      if {![string match .seen* $text]} {
         set lastseen($nick) [clock seconds]
         set lastchan($nick) $channel
         set lastmsg($nick) $text
      }
   }
}

proc pub_show_seen {nick userhost handle channel text} {
   global lastseen
   global lastchan
   global lastmsg
   if {[channel get $channel sseen]} {
      set text [lindex [split $text] 0]
      if {$text == $nick || [string tolower $text] == "me"} {
         if {[info exists lastseen($nick)]} {
            putserv "PRIVMSG $channel :I last saw you [duration [expr {[clock seconds] - $lastseen($nick)}]] ago on $lastchan($nick) saying: $lastmsg($nick)"
         } else {
            putserv "PRIVMSG $channel :I haven't seen you yet $nick. Say something to put yourself in my database."
         }
      } elseif {[isbotnick $text]} {
         putserv "PRIVMSG $channel :I last saw myself just now. Right here."
      } else {
         if {[info exists lastseen($text)]} {
            putserv "PRIVMSG $channel :I last saw $text [duration [expr {[clock seconds] - $lastseen($text)}]] ago on $lastchan($text) saying: $lastmsg($text)"
         } else {
            putserv "PRIVMSG $channel :I haven't seen $text. They might not have said anything yet."
         }
      }
   }
}

putlog "Sseend $ver by <lee8oiAtgmail> loaded!"

_________________
https://github.com/lee8oi
https://code.google.com/u/lee8oi/
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
lee8oi
Halfop


Joined: 04 Jun 2011
Posts: 63
Location: Michigan,United States.

PostPosted: Sun Jun 05, 2011 12:01 pm    Post subject: Sseend v1.3 Reply with quote

v1.3
1. Running .seen without arguments now shows command help.
2. Added Config section for Not Seen responses & Bots name reply.
3. Bot now addresses the users with thier nick when replying.
Code:

#  ----------------------------------------------------------
#
#   Sseend v 1.3 (6-5-11)
#   by: <lee8oiAtgmail><lee8oiOnfreenode> (thanks thommey)
#
#   Original Sseend based on:
#   Sseen v 0.2.22 by samu (IRC: samu@pirc.pl)
#
#  ----------------------------------------------------------
#
#  This is Simple Seen 'Duke' (pronounced 'Seend' by lee8oi).
#  Sseend is a seen script forked from Sseen that will tell you how
#  long ago the bot last seen the specified nick, what channel they
#  were on, and what their last message was to that channel. Sseend
#  also allows users to .seen themselves! (demanded feature believe it or not).
#
#  Initial channel setup:
#  (starts logging and enables .seen command)
#    .chanset #channel +sseen
#
#  Public command syntax:
#    .seen ?username|me?
#
#  Example Usage:
#    <lee8oi> .seen
#    <dukelovett> ~Sseend v1.3~ Usage: .seen ?username|me?
#    <lee8oi> .seen me
#    <dukelovett> I last saw you 1 hour 3 minutes 39 seconds ago on
#    #dukelovett. Last message: Sseen script was awsome. My version improves on it.
#    <lee8oi> .seen dukelovett
#    <dukelovett> I last saw myself just now. Right here.
#
#  Note:
#    Restarting the bot will clear all stored seen data. But Rehashing
#    normally does not clear the data.

#  Updates log:
#
#    v1.0:
#    1. Users can .seen themselves (Strange but popular).
#    2. .seen command lines are now ignored. This allows users "seening"
#       themselves to get results besides the command they just ran.
#    3. Sseend now keeps track of the users last message.
#    4. Lastseen time now shown as a duration instead of a time to
#       better serve users accross multiple timezones.
#    5. Bot can now cleverly respond to requests for it to 'seen'
#       itself.
#    6. Users can now do '.seen me' to seen themselves.
#
#    v1.1
#    1. Bot now replies correctly if users seen themselves before
#       any seen data is saved.
#    2. Added code changes suggested by nml375 including using isbotnick
#       instead of comparing to global var botnick.
#
#    v1.2
#    1. Removed _showcurtime procedure because the new duration
#   system doesn't require it.
#
#    v1.3
#    1. Running .seen without arguments now shows command help.
#    2. Added Config section for Not Seen responses & Bots name reply.
#    3. Bot now addresses the users with thier nick when replying.
#
#  TODO:
#    <> Add a system for backing up and restoring seen data.
#
#  ----------------------------------------------------------
#  CONFIG:
#  ----------------------------------------------------------
#   Not Seen Responses:

##  1.When users supply their own nick or 'me' and bot has NOT seen them:
set isUsersOwn "I haven't seen you yet. Say something."

##  2.When users supply an other nick and bot has NOT seen them:
set isOtherUser "I haven't seen that nick so far. They might not have spoken yet."

##  3.When users supply the bots own name:
set isBotsName "I last saw myself just now. Right here."

#  ----------------------------------------------------------
#  END CONFIG
#  ----------------------------------------------------------
#  NOTE: Only edit below if you know what you are doing. Any
#  Incorrect edits can cause undesirable results.
#  ----------------------------------------------------------

bind pubm - * public_msg_save
bind sign - * public_msg_save
bind pub - .seen pub_show_seen

set ver "1.3"

setudef flag sseen

proc public_msg_save {nick userhost handle channel text} {
   global lastseen
   global lastchan
   global lastmsg
   if {[channel get $channel sseen]} {
      if {![string match .seen* $text]} {
         set lastseen($nick) [clock seconds]
         set lastchan($nick) $channel
         set lastmsg($nick) $text
      }
   }
}

proc pub_show_seen {nick userhost handle channel text} {
   global lastseen
   global lastchan
   global lastmsg
   global isBotsName
   global isUsersOwn
   global isOtherUser
   if {[channel get $channel sseen]} {
      set text [lindex [split $text] 0]
      if {$text == ""} {
         putserv "PRIVMSG $channel :~Sseend v1.3~ Usage: .seen ?username|me?"
      } else {
         if {$text == $nick || [string tolower $text] == "me"} {
            if {[info exists lastseen($nick)]} {
               putserv "PRIVMSG $channel :$nick: I last saw you [duration [expr {[clock seconds] - $lastseen($nick)}]] ago on $lastchan($nick). Last message: $lastmsg($nick)"
            } else {
               putserv "PRIVMSG $channel :$nick: $isUsersOwn"
            }
         } elseif {[isbotnick $text]} {
            putserv "PRIVMSG $channel :$nick: $isBotsName"
         } else {
            if {[info exists lastseen($text)]} {
            putserv "PRIVMSG $channel :$nick: I last saw $text [duration [expr {[clock seconds] - $lastseen($text)}]] ago on $lastchan($text). Last message: $lastmsg($text)"
            } else {
               putserv "PRIVMSG $channel :$nick: $isOtherUser"
            }
         }
      }
   }
}

putlog "Sseend $ver by <lee8oiAtgmail> loaded!"

_________________
https://github.com/lee8oi
https://code.google.com/u/lee8oi/
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
lee8oi
Halfop


Joined: 04 Jun 2011
Posts: 63
Location: Michigan,United States.

PostPosted: Mon Jun 06, 2011 1:07 am    Post subject: Sseend v1.4 Reply with quote

v1.4
1. Fixed help output to use $ver to report script version.
2. Added config setting to enable/disable prefixing .seen results with users name.
3. Added config setting to enable/disable showing nicks last channel in .seen results.
4. Added config setting to enable/disable showing last message in seen results.
5. Added code changes/comments in proc's for better code readability.
6. Cleared prior versions update logs. Sseend scripts will now only show updates pertaining to current version to avoid extra clutter later.
Code:

#  ----------------------------------------------------------
#
#   Sseend v1.4 (6-6-11)
#   by: <lee8oiAtgmail><lee8oiOnfreenode> (thanks thommey)
#
#   Original Sseend based on:
#   Sseen v0.2.22 by samu (IRC: samu@pirc.pl)
#
#  ----------------------------------------------------------
#
#  This is Simple Seen 'Duke' (pronounced 'Seend' by lee8oi).
#  Sseend is a seen script forked from Sseen that will tell you how
#  long ago the bot last seen the specified nick, what channel they
#  were on, and what their last message was to that channel. Sseend
#  also allows users to .seen themselves! (demanded feature believe it or not).
#
#  Initial channel setup:
#  (starts logging and enables .seen command)
#    .chanset #channel +sseen
#
#  Public command syntax:
#    .seen ?username|me?
#
#  Example Usage:
#    <lee8oi> .seen
#    <dukelovett> ~Sseend 1.4~ Usage: .seen ?nick|me?
#    <lee8oi> .seen me
#    <dukelovett> I last saw you 1 hour 3 minutes 39 seconds ago on
#    #dukelovett. Last message: Sseen script was awsome. My version improves on it.
#    <lee8oi> .seen dukelovett
#    <dukelovett> I last saw myself just now. Right here.
#
#  Note:
#    Restarting the bot will clear all stored seen data. But Rehashing
#    normally does not clear the data.

#  Updates:
#
#    v1.4
#    1. Fixed help output to use $ver to report script version.
#    2. Added config setting to enable/disable prefixing .seen results
#       with users name.
#    3. Added config setting to enable/disable showing nicks last channel
#       in .seen results.
#    4. Added config setting to enable/disable showing last message in
#       .seen results.
#    5. Added code changes/comments in proc's for better code readability.
#    6. Cleared prior versions update logs. Sseend scripts will now only
#       show updates pertaining to current version to avoid extra clutter later.
#       (All versions of Sseend are posted in the egghelp forum for reference)
#
#  TODO:
#    <> Add a system for backing up and restoring seen data.
#
#  ----------------------------------------------------------
#  CONFIG: (.rehash after editing)
#  ----------------------------------------------------------
#   Not Seen Responses:

##  1.When users supply their own nick or 'me' and bot has NOT seen them:
set isUsersOwn "I haven't seen you yet. Say something."

##  2.When users supply an other nick and bot has NOT seen them:
set isOtherUser "I haven't seen that nick so far. They might not have spoken yet."

##  3.When users supply the bots own name:
set isBotsName "I last saw myself just now. Right here."

#  ----------------------------------------------------------
#   Seen Results Output: (0=disable,1=enable)

##  1.Prefix results with users name.
set usename 1

##  3.Show last channel in results.
set showchannel 1

##  2.Show last message in results.
set showmessage 1

#  ----------------------------------------------------------
#  END CONFIG
#  ----------------------------------------------------------
#  NOTE: Only edit below if you know what you are doing. Any
#  Incorrect edits can cause undesirable results.
#  ----------------------------------------------------------

bind pubm - * public_msg_save
bind sign - * public_msg_save
bind pub - .seen pub_show_seen

set ver "1.4"

setudef flag sseen

proc public_msg_save {nick userhost handle channel text} {
   global lastseen;global lastchan;global lastmsg
   
   if {[channel get $channel sseen]} {
      # channel has sseen flag set
      if {![string match .seen* $text]} {
         # not a .seen request. save data.
         set lastseen($nick) [clock seconds]
         set lastchan($nick) $channel
         set lastmsg($nick) $text
      }
   }
}

proc pub_show_seen {nick userhost handle channel text} {
   global ver;global lastseen;global lastchan;global lastmsg
   global isBotsName;global isUsersOwn;global isOtherUser
   global usename;global showmessage;global showchannel
   
   if {[channel get $channel sseen]} {
      # channel has sseen flag set
      set text [lindex [split $text] 0] ;#grab first word
      if {$text == ""} {
         # No args supplied. Show help:
         putserv "PRIVMSG $channel :~Sseend $ver~ Usage: .seen ?nick|me?"
      } elseif {[isbotnick $text]} {
         # User supplied bots name as arg
         putserv "PRIVMSG $channel :[if {$usename} {append nick :}] $isBotsName"
      } elseif {$text == $nick || [string tolower $text] == "me"} {
         # User supplied their own name or 'me' as arg
         if {[info exists lastseen($nick)]} {
            # seen data available
            putserv "PRIVMSG $channel :[if {$usename} {set name $nick;append name :}]\
            I last saw you [duration [expr {[clock seconds] - $lastseen($nick)}]]\
            ago[if {$showchannel} {set msg { on };append msg $lastchan($nick).} else {set msg \.}]\
            [if {$showmessage} {set msg {Last message: };append msg $lastmsg($nick)}]"
         } else {
            # seen data not available.
            putserv "PRIVMSG $channel :[if {$usename} {append nick :}] $isUsersOwn"
         }
      } else {
         # User supplied other user name
         if {[info exists lastseen($text)]} {
            # seen data available
            putserv "PRIVMSG $channel :[if {$usename} {set name $nick;append name :}]\
            I last saw $text [duration [expr {[clock seconds] - $lastseen($text)}]]\
            ago[if {$showchannel} {set msg { on };append msg $lastchan($text).} else {set msg \.}]\
            [if {$showmessage} {set msg {Last message: };append msg $lastmsg($text)}]"
         } else {
            # seen data not available.
            putserv "PRIVMSG $channel :[if {$usename} {append nick :}] $isOtherUser"
         }
      }
   }
}

putlog "Sseend $ver by <lee8oiAtgmail> loaded!"

_________________
https://github.com/lee8oi
https://code.google.com/u/lee8oi/
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2829

PostPosted: Mon Jun 06, 2011 11:59 am    Post subject: Reply with quote

Another suggestion, rather than having multiple global commands on the same line, consider using a single global command with multiple parameters:
Code:
global ver lastseen lastchan lastmsg isBotsName isUsersOwn isOtherUser username showmessage showchannel

It generally makes the code a lot more reader-friendly.

Also, avoid embedding code in output-strings if they don't contribute to the actual contents; setting unused variables to return a conditional value is not the prefered way, consider using the expr command (be cautious of double-evaluation though), or defining the variables outside the string, and using them within the string:
Code:
...
putserv "PRIVMSG $channel :[expr { $usename ? "${nick}:" : "" }]\
I last saw you [duration [expr {[clock seconds] - $lastseen($nick)}]] ago\
[expr { $showchannel ? " on $lastchan($nick)." : "." }]"

### Another way of doing this:
...
set name ""
set chanmsg ""
set lastwhat ""
set last [duration [expr {[clock seconds] - $lastseen($nick)}]]
if {$usename} {
  set name "${nick}:"
}
if {$showchannel} {
  set chanmsg " on $lastchan($nick)"
}
if {$showmessage} {
  set lastwhat " Last message: $lastmsg($nick)"
}
putserv "PRIVMSG $channel :$name I last saw you $last ago${chanmsg}.${lastwhat}"
...

There's probably an abundance of ways to write this piece of code, general rule of thumb though, if you define a variable - use it.

Edit: Fixed two issues with mixed up variable names.
_________________
NML_375, idling at #eggdrop@IrcNET


Last edited by nml375 on Mon Jun 06, 2011 4:00 pm; edited 1 time in total
Back to top
View user's profile Send private message
lee8oi
Halfop


Joined: 04 Jun 2011
Posts: 63
Location: Michigan,United States.

PostPosted: Mon Jun 06, 2011 3:25 pm    Post subject: Reply with quote

set lastmsg " Last message: $lastmsg($nick)"

doesn't work because lastmsg is the name of the global array. I got the following error:
Tcl error [pub_show_seen]: can't set "lastmsg": variable is array

and its:
[duration [expr {[clock seconds] - $lastseen($nick)}]]
not
[duration [expr {[clock seconds] - $lastchan($nick)}]]

So you almost got it right. Gotta use something else for the one var name. and use the correct varnames in thier places Smile But I'm working your suggestions in...thanks again good info!
_________________
https://github.com/lee8oi
https://code.google.com/u/lee8oi/
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2829

PostPosted: Mon Jun 06, 2011 3:57 pm    Post subject: Reply with quote

Yep, you're right. I'll update my previous post to fix those issues..
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
lee8oi
Halfop


Joined: 04 Jun 2011
Posts: 63
Location: Michigan,United States.

PostPosted: Mon Jun 06, 2011 5:13 pm    Post subject: Seend Script version 1.5! Reply with quote

v1.5
1. Added partyline command '.seend' for managing seen data. Includes 'backup' and 'restore' optional arguments for backing up and restoring seen data. Using .seend with no argument shows script version and usage info.
2. Incorporated code changes suggested by nml375(6-6-11)
3. Renamed script name and channel flag to seend instead of sseend. Since this script is evolving so much, 'Simple' might not be the right word to describe it anymore.

NOTE TO USERS OF Sseend v1.4 OR EARLIER:
remove -sseen flag from channels, and add '+seend' to update to this version of Seend script.
Code:

#  ----------------------------------------------------------
#
#   Seend v1.5 (6-6-11-17)
#   by: <lee8oiAtgmail><lee8oiOnfreenode> (thanks thommey)
#
#   Original Sseend based on:
#   Sseen v0.2.22 by samu (IRC: samu@pirc.pl)
#
#  ----------------------------------------------------------
#
#  This is Seen 'Duke' (pronounced 'Seend' by lee8oi).
#  Seend is a seen script forked from Sseen that will tell you how
#  long ago the bot last seen the specified nick, what channel they
#  were on, and what their last message was to that channel. Seend
#  also allows users to .seen themselves!(demanded). Via script edits
#  Bot owners can enable/disable: prefixing seen results with users name,
#  showing last channel, and showing last message. Owners also
#  have access to the '.seend' partyline command for backing up
#  and restoring seen data.
#
#  Initial channel setup:
#  (starts logging and enables .seen command)
#    .chanset #channel +seend
#
#  Public command syntax:
#    .seen ?username|me?
#
#  DCC (partyline) command syntax:
#    .seend ?backup|restore?
#
#  Example Usage:
#    (public)
#    <lee8oi> .seen
#    <dukelovett> ~Seend 1.5~ Usage: .seen ?nick|me?
#    <lee8oi> .seen me
#    <dukelovett> I last saw you 1 hour 3 minutes 39 seconds ago on
#    #dukelovett. Last message: Sseen script was awsome. My version improves on it.
#    <lee8oi> .seen dukelovett
#    <dukelovett> I last saw myself just now. Right here.
#
#    (partyline)
#    <lee8oi> .seend
#    <dukelovett> ~Seend 1.5~ Usage: Seend ?backup|restore?
#    <lee8oi> .seend backup
#    <dukelovett> Seend data backup performed.
#    <lee8oi> .seend restore
#    <dukelovett> Seend data restore performed.
#
#  Note:
#    Restarting the bot will clear all stored seen data. But Rehashing
#    normally does not clear the data.

#  Updates:
#
#    v1.5
#    1. Added partyline command '.seend' for managing seen data.
#       Includes 'backup' and 'restore' optional arguments for
#       backing up and restoring seen data via partyline with .seend
#       no argument shows script version and usage info.
#    2. Incorporated code changes suggested by nml375(6-6-11)
#    3. Renamed script and channel flag to seend instead of sseend.
#       Since this script is evolving so much, 'Simple' might not be
#       the right word to describe it anymore.
#    NOTE to users of v1.4 or earlier:
#       remove -sseen flag from channels, and add '+seend' to update
#       to this version of Seend.
#       
#
#
#  ----------------------------------------------------------
#  CONFIG: (.rehash after editing)
#  ----------------------------------------------------------
#   Not Seen Responses:

##  1.When users supply their own nick or 'me' and bot has NOT seen them:
set isUsersOwn "I haven't seen you yet. Say something."

##  2.When users supply an other nick and bot has NOT seen them:
set isOtherUser "I haven't seen that nick so far. They might not have spoken yet."

##  3.When users supply the bots own name:
set isBotsName "I last saw myself just now. Right here."

#  ----------------------------------------------------------
#   Seen Results Output: (0=disable,1=enable)

##  1.Prefix results with users name.
set usename 1

##  3.Show last channel in results.
set showchannel 1

##  2.Show last message in results.
set showmessage 1

set backupfile "scripts/SseendData.fs"
#  ----------------------------------------------------------
#  END CONFIG
#  ----------------------------------------------------------
#  NOTE: Only edit below if you know what you are doing. Any
#  Incorrect edits can cause undesirable results.
#  ----------------------------------------------------------

bind pubm - * public_msg_save
bind sign - * public_msg_save
bind pub - .seen pub_show_seen
bind dcc n seend dcc_seend
set ver "1.5"
setudef flag seend
proc dcc_seend {handle idx text} {
   global lastseen lastchan lastmsg ver backupfile
   set text [string tolower [lindex [split $text] 0]]
   if {$text == ""} {
      putdcc $idx "~Seend $ver~ Usage: Seend ?backup|restore?"
   } elseif {$text == "backup"} {
         set fs [open $backupfile w+]
         foreach arr {lastseen lastchan lastmsg} {
            puts $fs "array set $arr [list [array get $arr]]"
         }
         close $fs;
         putdcc $idx "Seend data backup performed."
   } elseif {$text == "restore"} {
      source $backupfile
      putdcc $idx "Seend data restore performed."
   }
}
proc public_msg_save {nick userhost handle channel text} {
   global lastseen lastchan lastmsg
   set first [string tolower [lindex [split $text] 0]]
   if {[channel get $channel seend]} {
      # channel has seend flag set
      if {$first != ".seen"} {
         # not a .seen request. save data.
         set lastseen($nick) [clock seconds]
         set lastchan($nick) $channel
         set lastmsg($nick) $text
      }
   }
}
proc pub_show_seen {nick userhost handle channel text} {
   global ver lastseen lastchan lastmsg
   global isBotsName isUsersOwn isOtherUser
   global usename showmessage showchannel
   set name ""
   set chanmsg ""
   set storedmsg ""
   if {[channel get $channel seend]} {
      # channel has sseen flag set
      set text [string tolower [lindex [split $text] 0]]
      if {$usename} {
         set name "${nick}: "
      }
      if {$text == ""} {
         # No args supplied. Show help:
         putserv "PRIVMSG $channel :~Seend $ver~ Usage: .seen ?nick|me?"
      } elseif {[isbotnick $text]} {
         # User supplied bots name as arg
         putserv "PRIVMSG $channel :${name}$isBotsName"
      } elseif {$text == $nick || $text == "me"} {
         # User supplied their own name or 'me' as arg
         if {[info exists lastseen($nick)]} {
            # seen data available
            set last [duration [expr {[clock seconds] - $lastseen($nick)}]]
            if {$showchannel} {
               set chanmsg " on $lastchan($nick)"
            }
            if {$showmessage} {
               set storedmsg " Last message: $lastmsg($nick)"
            }
            putserv "PRIVMSG $channel :${name}I last saw you $last\
            ago${chanmsg}.${storedmsg}"
         } else {
            # seen data not available.
            putserv "PRIVMSG $channel :${name}${isUsersOwn}"
         }
      } else {
         # User supplied other user name
         if {[info exists lastseen($text)]} {
            # seen data available
            set last [duration [expr {[clock seconds] - $lastseen($text)}]]
            if {$showchannel} {
               set chanmsg " on $lastchan($text)"
            }
            if {$showmessage} {
               set storedmsg " Last message: $lastmsg($text)"
            }
            putserv "PRIVMSG $channel :${name}I last saw $text $last\
            ago${chanmsg}.${storedmsg}"
         } else {
            # seen data not available.
            putserv "PRIVMSG $channel :${name}${isOtherUser}"
         }
      }
   }
}
putlog "Seend $ver by <lee8oiAtgmail> loaded!"

_________________
https://github.com/lee8oi
https://code.google.com/u/lee8oi/
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
lee8oi
Halfop


Joined: 04 Jun 2011
Posts: 63
Location: Michigan,United States.

PostPosted: Tue Jun 07, 2011 5:15 pm    Post subject: Seend Script version 1.6 Reply with quote

Updates:
v1.6
1. Implemented automatic backup and restore system that saves seen data on .restart & .die and restores data on load.
2. Created a namespace to keep procs and variables isolated to avoid future conflicts with other scripts.
3. Not seen responses are now 'split' and rejoined to allow better handling of special characters in response messages.
4. Rewrote description and comment documentation. And added copyright and GPL license reference and more code comments.
Code:

namespace eval seend {
########################################################################
#   Copyright 2011 lee8oi@gmail.com
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#   http://www.gnu.org/licenses/
#
#   Seend v1.6 (6-7-11)
#   by: <lee8oiAtgmail><lee8oiOnfreenode>
#
#   Original Sseend based on:
#   Sseen v0.2.22 by samu (IRC: samu@pirc.pl)
#
#    ----------------------------------------------------------
#
#   Seend is a seen script that will tell you how long ago the bot
#   last seen the specified nick, what channel they were on, and what their
#   last message was to that channel. It even allows users to .seen
#   themselves! Seend uses an automatic system for backing up seen data
#   and restoring it on load along with the .seend partyline command to
#   manually backup and restore seen data.
#   In the config section owners can enable/disable: User name prefixing,
#   displaying last channel, and displaying last message. And can also set
#   up Not seen responses, bot search for self response, and backup file
#   location/name.
#
#   Initial channel setup:
#   (starts logging and enables .seen command)
#    .chanset #channel +seend
#
#   Public command syntax:
#    .seen ?username|me?
#
#   DCC (partyline) command syntax:
#    .seend ?backup|restore?
#
#   Example Usage:
#    (public)
#    <lee8oi> .seen
#    <dukelovett> ~Seend 1.6~ Usage: .seen ?nick|me?
#    <lee8oi> .seen me
#    <dukelovett> I last saw you 1 hour 3 minutes 39 seconds ago on
#    #dukelovett. Last message: Sseen script was awsome. My version improves on it.
#    <lee8oi> .seen dukelovett
#    <dukelovett> I last saw myself just now. Right here.
#
#    (console)
#    <lee8oi> .seend
#    <dukelovett> ~Seend 1.6~ Usage: Seend ?backup|restore?
#    <lee8oi> .seend backup
#    <dukelovett> Seend data backup performed.
#    <lee8oi> .seend restore
#    <dukelovett> Seend data restore performed.
#
#   Note:
#    Automatic backup system saves seen data on .die & .restart and
#    restores data on load.
#
#   Thanks:
#    Thanks to thommey, nml375, and jack3 for their great code suggestions
#    and all the helpful answers that made this script possible.
#
#   Updates:
#    v1.6
#    1. Implemented automatic backup and restore system that saves
#       seen data on .restart & .die and restores data on load.
#    2. Created a namespace to keep procs and variables isolated to
#       avoid future conflicts with other scripts.
#    3. Not seen responses are now 'split' and rejoined to allow
#       better handling of special characters in response messages.
#    4. Rewrote description and comment documentation. And added
#       copyright and GPL license reference and more code comments.
#
#    ----------------------------------------------------------
#           CONFIGURATION
#    ----------------------------------------------------------
#               Not Seen Responses
#
#   note: Escape special characters with '\' example: '\{'
#   in the message.
#   
##  1.When users supply their own nick or 'me' and bot has NOT seen them:
set isUsersOwn "I haven't seen you yet. Say something."
#
##  2.When users supply an other nick and bot has NOT seen them:
set isOtherUser "I haven't seen that nick so far. They might not have spoken yet."
#
##  3.When users supply the bots own name:
set isBotsName "I last saw myself just now! Right here."
#
#    ----------------------------------------------------------
#                        Seen Results
#   (0=disable,1=enable)
#
##  1.Prefix results with users name.
variable usename 1
#
##  3.Show last channel in results.
variable showchannel 1
#
##  2.Show last message in results.
variable showmessage 1
#
#    ----------------------------------------------------------
#                        Backup file
#
## Set relative path to backup file.
variable backupfile "scripts/SeendData.fs"
#
#    ----------------------------------------------------------
#                      END CONFIGURATION
#
#  NOTE: Only edit below if you know what you are doing. Any
#  Incorrectly editing code can cause undesirable results.
#
####################################################################
variable isUsersOwn [split $isUsersOwn]
variable isOtherUser [split $isOtherUser]
variable isBotsName [split $isBotsName]
variable lastseen
variable lastchan
variable lastmsg
variable ver "1.6"
}
bind pubm - * ::seend::pub_msg_save
bind sign - * ::seend::pub_msg_save
bind pub - .seen ::seend::pub_show_seen
bind evnt - prerestart ::seend::prerestart
bind evnt - loaded ::seend::loaded
bind dcc n seend ::seend::dcc
setudef flag seend
if {![info exists ::seend_dietrace]} {
   # .die trigger. do backup
   trace add execution *dcc:die enter ::seend::backup
   trace add execution *msg:die enter ::seend::backup
}
namespace eval seend {
   proc restore {args} {
      # restore from file
      variable ::seend::backupfile
      source $backupfile
   }
   proc prerestart {type} {
      # prerestart trigger. Do backup.
      ::seend::backup
      putlog "Seend data saved."
   }
   proc loaded {type} {
      # bot loaded trigger do restore.
      ::seend::restore
      putlog "Seend data restored."
   }
   proc backup {args} {
      # backup to file: Write lines to file so it can
      # be sourced as a script during restore.
      variable ::seend::backupfile
      variable ::seend::lastseen
      variable ::seend::lastchan
      variable ::seend::lastmsg
      set fs [open $backupfile w+]
      # write variable lines for loading namespace vars.
      puts $fs "variable ::seend::lastseen"
      puts $fs "variable ::seend::lastchan"
      puts $fs "variable ::seend::lastmsg"
      foreach arr {lastseen lastchan lastmsg} {
         # create 'array set' lines using array data.
         puts $fs "array set $arr [list [array get $arr]]"
      }
      close $fs;
   }
   proc dcc {handle idx text} {
      # dcc/partyline .seend command
      variable ::seend::ver
      set text [string tolower [lindex [split $text] 0]]
      if {$text == ""} {
         # show help.
         putdcc $idx "~Seend $ver~ Usage: Seend ?backup|restore?"
      } elseif {$text == "backup"} {
         # run backup procedure.
         ::seend::backup
         putdcc $idx "Seend data saved."
      } elseif {$text == "restore"} {
         # run restore procedure.
         ::seend::restore
         putdcc $idx "Seend data restored."
      }
   }
   proc pub_msg_save {nick userhost handle channel text} {
      # grab seen data from channel message.
      set first [string tolower [lindex [split $text] 0]]
      if {[channel get $channel seend]} {
         # channel has seend flag
         if {$first != ".seen"} {
            # not a .seen request. Ok to save.
            set seend::lastseen($nick) [clock seconds]
            set seend::lastchan($nick) $channel
            set seend::lastmsg($nick) $text
         }
      }
   }
   proc pub_show_seen {nick userhost handle channel text} {
      # Retrive and display seen info or help.
      variable ::seend::ver
      variable ::seend::usename
      variable ::seend::showchannel
      variable ::seend::showmessage
      variable ::seend::isUsersOwn
      variable ::seend::isOtherUser
      variable ::seend::isBotsName
      variable ::seend::lastseen
      variable ::seend::lastchan
      variable ::seend::lastmsg
      set name ""
      set chanmsg ""
      set storedmsg ""
      if {[channel get $channel seend]} {
         # channel has sseen flag set
         set text [string tolower [lindex [split $text] 0]]
         if {$usename} {
            # usename is enabled. Add nick.
            set name "${nick}: "
         }
         if {$text == ""} {
            # No args supplied. Show help:
            putserv "PRIVMSG $channel :~Seend $ver~ Usage: .seen ?nick|me?"
         } elseif {[isbotnick $text]} {
            # User supplied bots name as arg
            putserv "PRIVMSG $channel :${name}[join [lrange $isBotsName 0 end]]"
         } elseif {$text == $nick || $text == "me"} {
            # User supplied their own name or 'me' as arg
            if {[info exists lastseen($nick)]} {
               # seen data available
               set last [duration [expr {[clock seconds] - $lastseen($nick)}]]
               if {$showchannel} {
                  # showchannel is enabled. Add last channel.
                  set chanmsg " on $lastchan($nick)"
               }
               if {$showmessage} {
                  # show message is enabled. Add last message.
                  set storedmsg " Last message: $lastmsg($nick)"
               }
               putserv "PRIVMSG $channel :${name}I last saw you $last\
               ago${chanmsg}.${storedmsg}"
            } else {
               # seen data not available.
               putserv "PRIVMSG $channel :${name}${isUsersOwn}"
            }
         } else {
            # User supplied other user name
            if {[info exists lastseen($text)]} {
               # seen data available
               set last [duration [expr {[clock seconds] - $lastseen($text)}]]
               if {$showchannel} {
                  # showchannel is enabled. Add last channel.
                  set chanmsg " on $lastchan($text)"
               }
               if {$showmessage} {
                  # show message is enabled. Add last message.
                  set storedmsg " Last message: $lastmsg($text)"
               }
               putserv "PRIVMSG $channel :${name}I last saw $text $last\
               ago${chanmsg}.${storedmsg}"
            } else {
               # seen data not available.
               putserv "PRIVMSG $channel :${name}${isOtherUser}"
            }
         }
      }
   }
   namespace export backup restore prerestart loaded dcc pub_msg_save pub_show_seen
}
putlog "Seend $ver by <lee8oiAtgmail> loaded!"

_________________
https://github.com/lee8oi
https://code.google.com/u/lee8oi/
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
lee8oi
Halfop


Joined: 04 Jun 2011
Posts: 63
Location: Michigan,United States.

PostPosted: Wed Jun 08, 2011 3:23 pm    Post subject: Seend script. Latest version: 1.7 Reply with quote

Updates:
v1.7
1. Removed 'me' feature. Simply because someone might just use that for a nickname one day.(thanks ente)
2. Help is now accessed by using '.seen help'. Running .seen without a nick is the same as running seen on your own nick.
3. Partyline command '.seend' can now use 'help' or no arg to display command help.
4. Added automatic interval backup system. Including config section for setting the interval time in minutes.
5. Added pattern searching. Users can now use partial names with * to see matching names in the seen database.
6. Added .seen request logging which uses 'putlog'. This can be turned on & off in the config section.
7. Cleaned up namespace variable references and made minor code changes to reduce unnecessary references. Also tried to move smaller code bits higher up in procs for quicker execution.
Code:

namespace eval seend {
########################################################################
#   Copyright 2011 lee8oi@gmail.com
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#   http://www.gnu.org/licenses/
#
#   Seend v1.7 (6-8-11)
#   by: <lee8oiAtgmail><lee8oiOnfreenode>
#
#   Original Sseend based on:
#   Sseen v0.2.22 by samu (IRC: samu@pirc.pl)
#
#    ----------------------------------------------------------
#
#   Seend is a seen script that will tell you how long ago the bot
#   last seen the specified nick, what channel they were on, and what their
#   last message was to that channel. It also allows you to do partial
#   nick searches using * and even lets you .seen yourself!
#
#   Seend uses an automatic system for backing up and restoring seen
#   data. Which also includes the .seend partyline command for manually
#   backing up and restoring seen data.
#
#   In the config section owners can enable/disable: User name prefixing,
#   displaying last channel, and displaying last message. And can also set
#   up Not seen responses, bot search for self response, backup file
#   location/name, automatic backup interval time, and toggle log seen requests.
#
#   Initial channel setup:
#   (starts logging and enables .seen command)
#    .chanset #channel +seend
#
#   Public command syntax:
#    .seen ?nick|help|*?
#
#   DCC (partyline) command syntax:
#    .seend ?backup|restore?
#
#   Example Usage:
#    (public)
#    <lee8oi> .seen help
#    <dukelovett> ~Seend 1.7~ Usage: .seen ?nick|help|*?
#    <lee8oi> .seen
#    <dukelovett> lee8oi: I last saw you 1 hour 3 minutes 39 seconds ago on
#    #dukelovett. Last message: Sseen script was awsome. My version improves on it.
#    <lee8oi> .seen dukelovett
#    <dukelovett> lee8oi: I last saw myself just now. Right here.
#    <lee8oi> .seen lee*
#    <dukelovett> lee8oi: The pattern 'lee*' matches: lee8oi
#
#    (console)
#    <lee8oi> .seend
#    <dukelovett> ~Seend 1.7~ Usage: Seend ?backup|restore?
#    <lee8oi> .seend backup
#    <dukelovett> Seend data backup performed.
#    <lee8oi> .seend restore
#    <dukelovett> Seend data restore performed.
#
#   Note:
#    Automatic backup system saves seen data on .die & .restart and
#    restores data on load. Interval backups are every 15 mins by default.
#
#   Thanks:
#    Thanks to thommey, nml375, and jack3 for their great code suggestions
#    and all the helpful answers that made this script possible.
#
#   Updates:
#    v1.7
#    1. Removed 'me' feature. Simply because someone might just use that
#       for a nickname one day.(thanks ente)
#    2. Help is now accessed by using '.seen help'. Running .seen without
#       a nick is the same as running seen on your own nick.
#    3. Partyline command '.seend' can now use 'help' or no arg to display
#       command help.
#    4. Added automatic interval backup system. Including
#       config section for setting the interval time in minutes.
#    5. Added pattern searching. Users can now use partial names with * to
#       see matching names in the seen database.
#    6. Added .seen request logging which uses 'putlog'. This can be
#       turned on & off in the config section.
#    7. Cleaned up namespace variable references and made minor code
#       changes to reduce unnecessary references. Also tried to move
#       smaller code bits higher up in procs for quicker execution.
#
#    ----------------------------------------------------------
#           CONFIGURATION
#    ----------------------------------------------------------
#               Not Seen Responses
#
#   note: Escape special characters with '\' example: '\{'
#   in the message.
#   
##  1.When users supply their own nick or no nick, and bot has NOT seen them:
set isUsersOwn "I haven't seen you yet. Say something."
#
##  2.When users supply an other nick and bot has NOT seen it yet:
set isOtherUser "I haven't seen that nick so far. They might not have spoken yet."
#
##  3.When users supply the bots own name:
set isBotsName "I last saw myself just now! Right here."
#
#    ----------------------------------------------------------
#                        Seen Results
#   (0=disable,1=enable)
#
##  1.Prefix results with users name.
variable usename 1
#
##  3.Show last channel in results.
variable showchannel 1
#
##  2.Show last message in results.
variable showmessage 1
#
#    ----------------------------------------------------------
#                        Backup file
#
## Set relative path to backup file.
variable backupfile "scripts/SeendData.tcl"
#
## set backup interval time in minutes.
variable interval 15

## log .seen requests. Uses 'putlog'. (1=enable,0=disable)
variable logseens 1
#
#    ----------------------------------------------------------
#                      END CONFIGURATION
#
#  NOTE: Only edit below if you know what you are doing. Any
#  Incorrectly editing code can cause undesirable results.
#
####################################################################
variable isUsersOwn [split $isUsersOwn]
variable isOtherUser [split $isOtherUser]
variable isBotsName [split $isBotsName]
variable lastseen
variable lastchan
variable lastmsg
variable ver "1.7"
}
bind pubm - * ::seend::pub_msg_save
bind sign - * ::seend::pub_msg_save
bind pub - .seen ::seend::pub_show_seen
bind evnt - prerestart ::seend::prerestart
bind evnt - loaded ::seend::loaded
bind dcc n seend ::seend::dcc
setudef flag seend
if {![info exists ::seend_dietrace]} {
   # .die trigger. do backup
   trace add execution *dcc:die enter ::seend::backup
   trace add execution *msg:die enter ::seend::backup
}
if {![info exists timer_running]} {
   # no existing timer. start new one.
   timer [set seend::interval] ::seend::timer_proc
   set timer_running 1
}
namespace eval seend {
   proc timer_proc {args} {
      # call self at timed intervals. do backup
      ::seend::backup
      putlog "Interval Seend backup performed."
      timer [set seend::interval] ::seend::timer_proc
      return 1
   }
   proc restore {args} {
      # restore from file
      source [set seend::backupfile]
   }
   proc prerestart {type} {
      # prerestart trigger. do backup.
      ::seend::backup
      putlog "Seend data saved."
   }
   proc loaded {type} {
      # bot loaded trigger do restore.
      ::seend::restore
      putlog "Seend data restored."
   }
   proc backup {args} {
      # backup to file: Write lines to file so it can
      # be sourced as a script during restore.
      variable ::seend::lastseen
      variable ::seend::lastchan
      variable ::seend::lastmsg
      set fs [open [set seend::backupfile] w+]
      # write variable lines for loading namespace vars.
      puts $fs "variable ::seend::lastseen"
      puts $fs "variable ::seend::lastchan"
      puts $fs "variable ::seend::lastmsg"
      # create 'array set' lines using array data.
      foreach arr {lastseen lastchan lastmsg} {
         puts $fs "array set $arr [list [array get $arr]]"
      }
      close $fs;
   }
   proc dcc {handle idx text} {
      # dcc/partyline .seend command
      set text [string tolower [lindex [split $text] 0]]
      if {$text == "" || $text == "help"} {
         # show help.
         variable ::seend::ver
         putdcc $idx "~Seend $ver~ Usage: Seend ?backup|restore?"
      } elseif {$text == "backup"} {
         # run backup procedure.
         ::seend::backup
         putdcc $idx "Seend data saved."
      } elseif {$text == "restore"} {
         # run restore procedure.
         ::seend::restore
         putdcc $idx "Seend data restored."
      }
   }
   proc pub_msg_save {nick userhost handle channel text} {
      # grab seen data from channel message.
      set first [string tolower [lindex [split $text] 0]]
      if {[channel get $channel seend]} {
         # channel has seend flag
         if {$first != ".seen"} {
            # not a .seen request. Ok to save.
            set seend::lastseen($nick) [clock seconds]
            set seend::lastchan($nick) $channel
            set seend::lastmsg($nick) $text
         } else {
            variable ::seend::logseens
            if {$logseens} {
               putlog "New .seen request from $nick: $text"
            }
         }
      }
   }
   proc pub_show_seen {nick userhost handle channel text} {
      # Retrive and display seen info or help.
      if {[channel get $channel seend]} {
         variable ::seend::lastseen
         variable ::seend::lastchan
         variable ::seend::lastmsg
         set name ""
         set chanmsg ""
         set storedmsg ""
         # channel has sseen flag set
         set text [string tolower [lindex [split $text] 0]]
         if {[set seend::usename]} {
            # usename is enabled. Add nick.
            set name "${nick}: "
         }
         if {$text == "help"} {
            # No args supplied. Show help:
            variable ::seend::ver
            putserv "PRIVMSG $channel :~Seend $ver~ Usage: .seen ?nick|help|\*?"
         } elseif {[isbotnick $text]} {
            # User supplied bots name as arg
            variable ::seend::isBotsName
            putserv "PRIVMSG $channel :${name}[join [lrange $isBotsName 0 end]]"
         } elseif {[regexp {\*} $text]} {
            # text includes a * so it must be a pattern search.
            set namelist [array names lastseen $text]
            if { $namelist != "" } {
               # names matching pattern exist.
               putserv "PRIVMSG $channel :${name}The pattern '${text}' matches: ${namelist}"
            } else {
               # no names match pattern.
               putserv "PRIVMSG $channel :${name}No match found for '${text}'."
            }
         } elseif {$text == $nick || $text == ""} {
            # User supplied their own name or 'me' as arg
            if {[info exists lastseen($nick)]} {
               # seen data available
               set last [duration [expr {[clock seconds] - $lastseen($nick)}]]
               if {[set seend::showchannel]} {
                  # showchannel is enabled. Add last channel.
                  set chanmsg " on $lastchan($nick)"
               }
               if {[set seend::showmessage]} {
                  # show message is enabled. Add last message.
                  set storedmsg " Last message: $lastmsg($nick)"
               }
               putserv "PRIVMSG $channel :${name}I last saw you $last\
               ago${chanmsg}.${storedmsg}"
            } else {
               # seen data not available.
               variable ::seend::isUsersOwn
               putserv "PRIVMSG $channel :${name}${isUsersOwn}"
            }
         } else {
            # User supplied other user name
            if {[info exists lastseen($text)]} {
               # seen data available
               set last [duration [expr {[clock seconds] - $lastseen($text)}]]
               if {[set seend::showchannel]} {
                  # showchannel is enabled. Add last channel.
                  set chanmsg " on $lastchan($text)"
               }
               if {[set seend::showmessage]} {
                  # show message is enabled. Add last message.
                  set storedmsg " Last message: $lastmsg($text)"
               }
               putserv "PRIVMSG $channel :${name}I last saw $text $last\
               ago${chanmsg}.${storedmsg}"
            } else {
               # seen data not available.
               variable ::seend::isOtherUser
               putserv "PRIVMSG $channel :${name}${isOtherUser}"
            }
         }
      }
   }
   namespace export backup restore prerestart loaded dcc pub_msg_save pub_show_seen
}
putlog "Seend 1.7 by <lee8oiAtgmail> loaded!"

_________________
https://github.com/lee8oi
https://code.google.com/u/lee8oi/
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
Kurthalis
Voice


Joined: 07 Jun 2011
Posts: 3

PostPosted: Tue Jun 14, 2011 1:45 am    Post subject: Reply with quote

Link?

:>
Back to top
View user's profile Send private message Send e-mail
lee8oi
Halfop


Joined: 04 Jun 2011
Posts: 63
Location: Michigan,United States.

PostPosted: Tue Jun 14, 2011 8:31 am    Post subject: Reply with quote

Kurthalis wrote:
Link?

:>


The code is posted its really mostly a copy and paste job. They don't update the archive much. But you can paste it into an editor and save it in the scripts dir then add the appropriate source line to your eggdrop.conf and it will work the same. 'seend.tcl' isn't a bad choice for a file name.
_________________
https://github.com/lee8oi
https://code.google.com/u/lee8oi/
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
lee8oi
Halfop


Joined: 04 Jun 2011
Posts: 63
Location: Michigan,United States.

PostPosted: Thu Jun 30, 2011 2:58 pm    Post subject: Reply with quote

Updates:
v1.8
1. Added configuration for enabling/disabling interval backup logging.
2. Added configuration to enable/disable showing last seen time as duration.
3. Created get_info procedure to grab seen info and format the output
message according to configuration.
Code:

namespace eval seend {
########################################################################
#   Copyright 2011 lee8oi@gmail.com
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#   http://www.gnu.org/licenses/
#
#   Seend v1.8 (6-8-11)
#   by: <lee8oiAtgmail><lee8oiOnfreenode>
#   egghelp forum: http://forum.egghelp.org/viewtopic.php?t=18493
#   github link: https://github.com/lee8oi/eggdrop/blob/master/seend.tcl
#
#   Original Sseend based on:
#   Sseen v0.2.22 by samu (IRC: samu@pirc.pl)
#
#    ----------------------------------------------------------
#
#   Seend is a seen script that will tell you how long ago the bot
#   last seen the specified nick, what channel they were on, and what their
#   last message was to that channel. It also allows you to do partial
#   nick searches using * and even lets you .seen yourself!
#
#   Seend uses an automatic system for backing up and restoring seen
#   data. Which also includes the .seend partyline command for manually
#   backing up and restoring seen data.
#
#   In the config section owners can enable/disable: User name prefixing,
#   displaying last channel, and displaying last message. Also can set
#   up Not seen responses, bot search for self response, backup file
#   location/name, automatic backup interval time, toggle seen requests,
#   interval backup logging, and show time as duration.
#
#   Initial channel setup:
#   (starts logging and enables .seen command)
#    .chanset #channel +seend
#
#   Public command syntax:
#    .seen ?nick|help|*?
#
#   DCC (partyline) command syntax:
#    .seend ?backup|restore?
#
#   Example Usage:
#    (public)
#    <lee8oi> .seen help
#    <dukelovett> ~Seend 1.8~ Usage: .seen ?nick|help|*?
#    <lee8oi> .seen
#    <dukelovett> lee8oi: I last saw you 1 hour 3 minutes 39 seconds ago on
#    #dukelovett. Last message: Sseen script was awsome. My version improves on it.
#    <lee8oi> .seen dukelovett
#    <dukelovett> lee8oi: I last saw myself just now. Right here.
#    <lee8oi> .seen lee*
#    <dukelovett> lee8oi: The pattern 'lee*' matches: lee8oi
#
#    (console)
#    <lee8oi> .seend
#    <dukelovett> ~Seend 1.8~ Usage: Seend ?backup|restore?
#    <lee8oi> .seend backup
#    <dukelovett> Seend data backup performed.
#    <lee8oi> .seend restore
#    <dukelovett> Seend data restore performed.
#
#   Note:
#    Automatic backup system saves seen data on .die & .restart and
#    restores data on load. Interval backups are every 15 mins by default.
#
#   Thanks:
#    Thanks to thommey, nml375, and jack3 for their great code suggestions
#    and all the helpful answers that made this script possible.
#
#   Updates:
#    v1.8
#     1. Added configuration for enabling/disabling interval backup logging.
#     2. Added configuration to enable/disable showing last seen time as duration.
#     3. Created get_info procedure to grab seen info and format the output
#     message according to configuration.
#
#    ----------------------------------------------------------
#           CONFIGURATION
#    ----------------------------------------------------------
#                       Not Seen Responses
#
#   note: Escape special characters with '\' example: '\{'
#   in the message.
#   
##  1.When users supply their own nick or no nick, and bot has NOT seen them:
set isUsersOwn "I haven't seen you yet. Say something."
#
##  2.When users supply an other nick and bot has NOT seen it yet:
set isOtherUser "I haven't seen that nick so far. They might not have spoken yet."
#
##  3.When users supply the bots own name:
set isBotsName "I last saw myself just now! Right here."
#
#    ----------------------------------------------------------
#                        Seen Results
#   (0=disable,1=enable)
#
##  1.Prefix results with users name.
variable usename 1
#
##  3.Show last channel in results.
variable showchannel 1
#
##  2.Show last message in results.
variable showmessage 1
#
##  3.Show last seen time as duration. (1=enable,0=disable)
#  (off shows date and time instead)
variable showduration 1
#
#
#    ----------------------------------------------------------
#                        Backup file
#
## Set relative path to backup file.
variable backupfile "scripts/SeendData.tcl"
#
## set backup interval time in minutes.
variable interval 15
#
## log interval backups. Uses 'putlog'. (1=enable,0=disable)
variable logintervals 0
#
## log .seen requests. Uses 'putlog'. (1=enable,0=disable)
variable logseens 0
#

#    ----------------------------------------------------------
#                      END CONFIGURATION
#
#  NOTE: Only edit below if you know what you are doing. Any
#  Incorrectly editing code can cause undesirable results.
#
####################################################################
variable isUsersOwn [split $isUsersOwn]
variable isOtherUser [split $isOtherUser]
variable isBotsName [split $isBotsName]
variable lastseen
variable lastchan
variable lastmsg
variable ver "1.8"
}
bind pubm - * ::seend::pub_msg_save
bind sign - * ::seend::pub_msg_save
bind pub - .seen ::seend::pub_show_seen
bind evnt - prerestart ::seend::prerestart
bind evnt - loaded ::seend::loaded
bind dcc n seend ::seend::dcc
setudef flag seend
if {![info exists ::seend_dietrace]} {
   # .die trigger. do backup
   trace add execution *dcc:die enter ::seend::backup
   trace add execution *msg:die enter ::seend::backup
}
if {![info exists timer_running]} {
   # no existing timer. start new one.
   timer [set seend::interval] ::seend::timer_proc
   set timer_running 1
}
namespace eval seend {
   proc restore {args} {
      # restore from file
      source [set seend::backupfile]
   }
   proc prerestart {type} {
      # prerestart trigger. do backup.
      ::seend::backup
      putlog "Seend data saved."
   }
   proc loaded {type} {
      # bot loaded trigger do restore.
      ::seend::restore
      putlog "Seend data restored."
   }
   
   proc timer_proc {args} {
      # call self at timed intervals. do backup
      ::seend::backup
      timer [set seend::interval] ::seend::timer_proc
      if {[set seend::logintervals]} {
         # logging is enabled.
         putlog "Interval Seend backup performed."
      }
      return 1
   }
   proc backup {args} {
      # backup to file: Write lines to file so it can
      # be sourced as a script during restore.
      variable ::seend::lastseen
      variable ::seend::lastchan
      variable ::seend::lastmsg
      set fs [open [set seend::backupfile] w+]
      # write variable lines for loading namespace vars.
      puts $fs "variable ::seend::lastseen"
      puts $fs "variable ::seend::lastchan"
      puts $fs "variable ::seend::lastmsg"
      # create 'array set' lines using array data.
      foreach arr {lastseen lastchan lastmsg} {
         puts $fs "array set $arr [list [array get $arr]]"
      }
      close $fs;
   }
   proc dcc {handle idx text} {
      # dcc/partyline .seend command
      set text [string tolower [lindex [split $text] 0]]
      if {$text == "" || $text == "help"} {
         # show help.
         variable ::seend::ver
         putdcc $idx "~Seend $ver~ Usage: Seend ?backup|restore?"
      } elseif {$text == "backup"} {
         # run backup procedure.
         ::seend::backup
         putdcc $idx "Seend data saved."
      } elseif {$text == "restore"} {
         # run restore procedure.
         ::seend::restore
         putdcc $idx "Seend data restored."
      }
   }
   proc pub_msg_save {nick userhost handle channel text} {
      # grab seen data from channel message.
      set first [string tolower [lindex [split $text] 0]]
      if {[channel get $channel seend]} {
         # channel has seend flag
         if {$first != ".seen"} {
            # not a .seen request. Ok to save.
            set seend::lastseen($nick) [clock seconds]
            set seend::lastchan($nick) $channel
            set seend::lastmsg($nick) $text
         } else {
            variable ::seend::logseens
            if {$logseens} {
               putlog "New .seen request from $nick: $text"
            }
         }
      }
   }
   proc get_info {nick who} {
      variable ::seend::lastseen
      variable ::seend::lastchan
      variable ::seend::lastmsg
      set chanmsg ""
      set storedmsg ""
      set time $lastseen($who)
      if {[set ::seend::showduration] == 1} {
         set last "[duration [expr {[clock seconds] - $time}]] ago"
      } else {
         set last [string map {"\n" ""} [clock format $time -format {%Y/%m/%d %H:%M:%S}]]
      }
      if {[set seend::showchannel]} {
         # showchannel is enabled. Add last channel.
         set chanmsg " on $lastchan($who)"
      }
      if {[set seend::showmessage]} {
         # show message is enabled. Add last message.
         set storedmsg " Last message: $lastmsg($who)"
      }
      if {$nick == $who} {
         set result "I last saw you $last${chanmsg}.${storedmsg}"
      } else {
         set result "I last saw $who $last${chanmsg}.${storedmsg}"
      }
      return $result
   }
   proc pub_show_seen {nick userhost handle channel text} {
      # Retrive and display seen info or help.
      if {[channel get $channel seend]} {
         variable ::seend::lastseen
         variable ::seend::lastchan
         variable ::seend::lastmsg
         set name ""
         set chanmsg ""
         set storedmsg ""
         # channel has sseen flag set
         set text [string tolower [lindex [split $text] 0]]
         if {[set seend::usename]} {
            # usename is enabled. Add nick.
            set name "${nick}: "
         }
         if {$text == "help"} {
            # No args supplied. Show help:
            variable ::seend::ver
            putserv "PRIVMSG $channel :~Seend $ver~ Usage: .seen ?nick|help|\*?"
         } elseif {[isbotnick $text]} {
            # User supplied bots name as arg
            variable ::seend::isBotsName
            putserv "PRIVMSG $channel :${name}[join [lrange $isBotsName 0 end]]"
         } elseif {[regexp {\*} $text]} {
            # text includes a * so it must be a pattern search.
            set namelist [array names lastseen $text]
            if { $namelist != "" } {
               # names matching pattern exist.
               putserv "PRIVMSG $channel :${name}The pattern '${text}' matches: ${namelist}"
            } else {
               # no names match pattern.
               putserv "PRIVMSG $channel :${name}No match found for '${text}'."
            }
         } elseif {$text == $nick || $text == ""} {
            # User supplied their own name or no name.
            if {[info exists lastseen($nick)]} {
               # seen data available
               set output [::seend::get_info $nick $nick]
               putserv "PRIVMSG $channel :${name}$output"
            } else {
               # seen data not available.
               variable ::seend::isUsersOwn
               putserv "PRIVMSG $channel :${name}${isUsersOwn}"
            }
         } else {
            # User supplied other user name
            if {[info exists lastseen($text)]} {
               # seen data available
               set output [::seend::get_info $nick $text]
               putserv "PRIVMSG $channel :${name}$output"
            } else {
               # seen data not available.
               variable ::seend::isOtherUser
               putserv "PRIVMSG $channel :${name}${isOtherUser}"
            }
         }
      }
   }
   namespace export backup restore prerestart loaded dcc pub_msg_save pub_show_seen
}
putlog "Seend [set ::seend::ver] loaded!"

_________________
https://github.com/lee8oi
https://code.google.com/u/lee8oi/
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases All times are GMT - 4 Hours
Goto page 1, 2  Next
Page 1 of 2

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


Forum hosting provided by Reverse.net

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