-
Notifications
You must be signed in to change notification settings - Fork 1
/
tw_begins.py
executable file
·40 lines (30 loc) · 1.23 KB
/
tw_begins.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python
import begin
import twitterlib
# Sub-command definitions using subcommand decorator for each sub-command that
# implements a timeline display.
@begin.subcommand
def timeline():
"Display recent tweets from users timeline"
for status in begin.context.api.timeline:
print u"%s: %s" % (status.user.screen_name, status.text)
@begin.subcommand
def mentions():
"Display recent tweets mentioning user"
for status in begin.context.api.mentions:
print u"%s: %s" % (status.user.screen_name, status.text)
@begin.subcommand
def retweets():
"Display recent retweets from user's timeline"
for status in begin.context.api.retweets:
print u"%s: %s" % (status.user.screen_name, status.text)
# Program main definition replace __name__ === '__main__' magic
# sub-commands are registered and loaded automatically.
@begin.start(env_prefix='', short_args=False)
def main(api_key='', api_secret='', access_token='', access_secret=''):
"""Minimal Twitter client
Demonstrate the use of the begins command line application framework by
implementing a simple Twitter command line client.
"""
api = twitterlib.API(api_key, api_secret, access_token, access_secret)
begin.context.api = api