Created
May 1, 2017 23:20
-
-
Save AnthonySuper/c5458a9440ae8c29f42217f66af4131c to your computer and use it in GitHub Desktop.
Lets you see a history of the names in a group chat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'sqlite3' | |
path = File.expand_path("~/Library/Messages/chat.db") | |
db = SQLite3::Database.new path | |
db.results_as_hash = true | |
r = db.execute(%{SELECT chat.display_name, chat.ROWID FROM chat | |
WHERE chat.display_name IS NOT NULL AND | |
chat.display_name != ''}) | |
r.each.with_index do |row, idx| | |
puts "#{idx}\t#{row["display_name"]}" | |
end | |
print "Enter the chat you want: " | |
idx = gets.chomp.to_i | |
rowid = r[idx]["ROWID"] | |
query = %{ | |
SELECT message.group_title, | |
message.account, | |
message.date FROM message | |
INNER JOIN chat_message_join | |
ON chat_message_join.message_id = message.ROWID | |
INNER JOIN chat | |
ON chat.ROWID = chat_message_join.chat_id | |
WHERE chat.ROWID = #{rowid} | |
AND message.group_title IS NOT NULL | |
AND message.group_title != '' | |
ORDER BY message.date DESC} | |
r = db.execute(query) | |
r.each do |r| | |
puts "#{r["date"]}\t#{r["account"]}\t#{r["group_title"]}" | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment