Commit a2b6d3d2 authored by Klaus-Uwe Mitterer's avatar Klaus-Uwe Mitterer

Allow to parse Twitter status URLs for replies

parent e0fe42a3
......@@ -4,10 +4,12 @@ import argparse, twitools
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Send a tweet from the status monitor\'s account.')
parser.add_argument('-r', '--reply', default=None, metavar='ID', type=int, help='reply to tweet ID')
parser.add_argument('-r', '--reply', default=None, metavar='ID', help='reply to tweet ID')
parser.add_argument('-t', '--text', default=None, type=str, help='tweet provided string')
args = parser.parse_args()
two = twitools.twObject()
if not args.text:
text = input("> ")
......@@ -15,4 +17,14 @@ if __name__ == "__main__":
text = args.text
except KeyboardInterrupt:
two.tweet(text, args.reply)
if isinstance(args.reply, int):
reply = args.reply
if "" in args.reply and "status" in args.reply:
reply = int(args.reply.split('/')[-1])
raise ValueError("Invalid tweet ID passed for -r.")
two.tweet(text, reply)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment