add first PoC to print stuff

main
Helix 3 years ago
parent 781072df59
commit 881eba860b

@ -0,0 +1,37 @@
#!/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:])
Loading…
Cancel
Save