Skip to content

Instantly share code, notes, and snippets.

@taksatou
Created July 18, 2013 08:42
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save taksatou/6027743 to your computer and use it in GitHub Desktop.
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