33 lines
832 B
Python
Executable file
33 lines
832 B
Python
Executable file
#!/usr/bin/env python3
|
|
|
|
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', 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()
|
|
|
|
try:
|
|
if not args.text:
|
|
text = input("> ")
|
|
else:
|
|
text = args.text
|
|
except KeyboardInterrupt:
|
|
exit(0)
|
|
|
|
reply = None
|
|
|
|
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.")
|
|
|
|
two.tweet(text, reply)
|