2016-03-18 20:09:50 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
2016-09-13 17:56:26 +00:00
|
|
|
import argparse, twitools
|
2016-03-18 20:09:50 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2016-09-13 17:56:26 +00:00
|
|
|
parser = argparse.ArgumentParser(description='Send a tweet from the status monitor\'s account.')
|
2016-09-13 18:20:05 +00:00
|
|
|
parser.add_argument('-r', '--reply', default=None, metavar='ID', help='reply to tweet ID')
|
2016-09-13 17:56:26 +00:00
|
|
|
parser.add_argument('-t', '--text', default=None, type=str, help='tweet provided string')
|
|
|
|
args = parser.parse_args()
|
2016-09-13 18:20:05 +00:00
|
|
|
|
2016-03-18 20:09:50 +00:00
|
|
|
two = twitools.twObject()
|
2016-09-13 18:20:05 +00:00
|
|
|
|
2016-03-18 20:09:50 +00:00
|
|
|
try:
|
2016-09-13 17:56:26 +00:00
|
|
|
if not args.text:
|
|
|
|
text = input("> ")
|
|
|
|
else:
|
|
|
|
text = args.text
|
2016-03-18 20:09:50 +00:00
|
|
|
except KeyboardInterrupt:
|
|
|
|
exit(0)
|
2016-09-13 18:20:05 +00:00
|
|
|
|
2017-03-23 15:01:26 +00:00
|
|
|
reply = None
|
|
|
|
|
2017-03-23 14:59:51 +00:00
|
|
|
if 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.")
|
2016-09-13 18:20:05 +00:00
|
|
|
|
|
|
|
two.tweet(text, reply)
|