Allow tweet.py to parse Twitter status URLs for replies
This commit is contained in:
parent
e0fe42a35d
commit
a2b6d3d2e0
16
tweet.py
16
tweet.py
|
@ -4,10 +4,12 @@ import argparse, twitools
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
parser = argparse.ArgumentParser(description='Send a tweet from the status monitor\'s account.')
|
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')
|
parser.add_argument('-t', '--text', default=None, type=str, help='tweet provided string')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
two = twitools.twObject()
|
two = twitools.twObject()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if not args.text:
|
if not args.text:
|
||||||
text = input("> ")
|
text = input("> ")
|
||||||
|
@ -15,4 +17,14 @@ if __name__ == "__main__":
|
||||||
text = args.text
|
text = args.text
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
exit(0)
|
exit(0)
|
||||||
two.tweet(text, args.reply)
|
|
||||||
|
if isinstance(args.reply, int):
|
||||||
|
reply = args.reply
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
if "twitter.com" in args.reply and "status" in args.reply:
|
||||||
|
reply = int(args.reply.split('/')[-1])
|
||||||
|
except:
|
||||||
|
raise ValueError("Invalid tweet ID passed for -r.")
|
||||||
|
|
||||||
|
two.tweet(text, reply)
|
||||||
|
|
Loading…
Reference in a new issue