You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1006 B
Python
38 lines
1006 B
Python
#!/usr/bin/env python3
|
|
import sys, getopt, json
|
|
|
|
def printHelp():
|
|
print('usage: convert.py -i <input> <output>')
|
|
|
|
def main(argv):
|
|
fileInput = ''
|
|
fileOutput = ''
|
|
try:
|
|
opts, args = getopt.getopt(argv, "hi:o:", ["ifile=", "ofile="])
|
|
except getopt.GetoptError:
|
|
printHelp()
|
|
sys.exit(2)
|
|
for opt, argumentProvided in opts:
|
|
if opt == '-h':
|
|
printHelp()
|
|
sys.exit()
|
|
if opt in ("-i", "--ifile"):
|
|
fileInput = argumentProvided;
|
|
if opt in ("-o", "--ofile"):
|
|
fileOutput = argumentProvided;
|
|
|
|
chatLogJson = json.load(open(fileInput))
|
|
print("room name: "+chatLogJson["room_name"])
|
|
|
|
messages = chatLogJson["messages"]
|
|
for message in messages:
|
|
messageContent = message.get("content")
|
|
messageType = messageContent.get("msgtype")
|
|
if messageType == "m.text":
|
|
print(messageContent.get("body"))
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main(sys.argv[1:])
|