diff --git a/tweet.py b/tweet.py index 4b9e227..868251e 100755 --- a/tweet.py +++ b/tweet.py @@ -1,11 +1,18 @@ #!/usr/bin/env python3 -import twitools +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('-t', '--text', default=None, type=str, help='tweet provided string') + args = parser.parse_args() two = twitools.twObject() try: - text = input("> ") + if not args.text: + text = input("> ") + else: + text = args.text except KeyboardInterrupt: exit(0) - two.tweet(text) + two.tweet(text, args.reply) diff --git a/twitools/__init__.py b/twitools/__init__.py index 956e4ca..988d160 100644 --- a/twitools/__init__.py +++ b/twitools/__init__.py @@ -30,8 +30,8 @@ class twObject: tweets.reverse() return tweets - def tweet(self, text): - self.api.update_status(text) + def tweet(self, text, replyto = None): + self.api.update_status(text, replyto) def whoami(self): return self.auth.get_username()