X-Git-Url: https://jfr.im/git/z_archive/twitter.git/blobdiff_plain/098660ce6ca34597e97f074b3af48f64dcf3ea03..4f8b921564da2d1b11ab154e58d068241cd59895:/twitter/cmdline.py?ds=sidebyside diff --git a/twitter/cmdline.py b/twitter/cmdline.py index a167c14..5ed9510 100644 --- a/twitter/cmdline.py +++ b/twitter/cmdline.py @@ -22,6 +22,7 @@ ACTIONS: search search twitter (Beware: octothorpe, escape it) set set your twitter status shell login to the twitter shell + rate get your current rate limit status (remaining API reqs) OPTIONS: @@ -523,6 +524,13 @@ class DoNothingAction(Action): def __call__(self, twitter, options): pass +class RateLimitStatus(Action): + def __call__(self, twitter, options): + rate = twitter.account.rate_limit_status() + print("Remaining API requests: %s / %s (hourly limit)" % (rate['remaining_hits'], rate['hourly_limit'])) + print("Next reset in %ss (%s)" % (int(rate['reset_time_in_seconds']-time.time()), + time.asctime(time.localtime(rate['reset_time_in_seconds'])))) + actions = { 'authorize' : DoNothingAction, 'follow' : FollowAction, @@ -537,6 +545,7 @@ actions = { 'search' : SearchAction, 'set' : SetStatusAction, 'shell' : TwitterShell, + 'rate' : RateLimitStatus, } def loadConfig(filename):