Browse Source

add first PoC to print stuff

main
Helix 6 months ago
parent
commit
881eba860b
  1. 37
      convert.py

37
convert.py

@ -0,0 +1,37 @@ @@ -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