Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Freetalk write last message
import commands
import time
f = '~/.freetalk/history/mgcclx@gmail.com/SESSION'
s = commands.getoutput('cat ' + f + ' | tail --lines 1 | cut -c 21-')
s = s.replace('[','<fc=#ffffff>',1)
s = s.replace(']',':</fc>',1)
s = s.replace('@gmail.com','',1)
s = s.rstrip()
u = unicode(s, "utf-8")
print u[0:100].encode("utf-8")
(define last-message-file (string-append (ft-get-config-dir) "/last-message"))
(define (last-message message)
"log the last to ~/.freetalk/last-message for some other program"
(define last-message-fd (open-file last-message-file "w"))
(display message last-message-fd)
(close-output-port last-message-fd))
;;; hook procedure for logging last sent messages
(define (last-sent-message to message)
"hook procedure for logging last sent messages"
(pretty-message (ft-get-jid) message))
(add-hook! ft-message-send-hook last-sent-message)
;;; hook procedure for logging last revceived messages
(define (last-received-message time from nickname message)
"hook procedure for logging last revceived messages"
(pretty-message from message))
(add-hook! ft-message-receive-hook last-received-message)
(define (pretty-message buddy message)
(last-message
(string-append "<fc=#ffffff>" (buddy-name buddy) ":</fc> " message "\n")))
(define (buddy-name name)
(substring name 0 (string-index name #\@)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment