Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
dump skype logs by chatname
#!/usr/bin/env ruby
require 'active_record'
$db, $chatname = ARGV
if $db.nil? or $chatname.nil?
puts "usage: #{__FILE__} <db> <chatname>"
exit 1
end
ActiveRecord::Base.establish_connection(
:adapter => 'sqlite3',
:database => $db
)
class Chat < ActiveRecord::Base
self.table_name = "Chats"
self.inheritance_column = :_type_disabled
has_many :messages, :finder_sql => Proc.new {
%Q{
select * from Messages m, Chats c where c.name = m.chatname and c.id = #{id}
}
}
end
class Contact < ActiveRecord::Base
self.table_name = "Contacts"
self.inheritance_column = :_type_disabled
end
class Message < ActiveRecord::Base
self.table_name = "Messages"
self.inheritance_column = :_type_disabled
end
class Conversation < ActiveRecord::Base
self.table_name = "Conversations"
self.inheritance_column = :_type_disabled
end
if __FILE__ == $0
chats = Chat.where("friendlyname like ?", "%#{$chatname}%")
chats.each do |c|
c.messages.each do |m|
puts "#{m.author} [#{Time.at m.timestamp}]: #{m.body_xml}"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment