catch IOError when config not exists
[rainbowstream.git] / docs / index.rst
1 Rainbow Stream
2 --------------
3
4 .. image:: http://img.shields.io/pypi/dm/rainbowstream.svg?style=flat
5 :target: https://pypi.python.org/pypi/rainbowstream
6
7 .. image:: http://img.shields.io/pypi/v/rainbowstream.svg?style=flat
8 :target: https://pypi.python.org/pypi/rainbowstream
9
10 Terminal-based Twitter Client. Realtime tweetstream, compose, search ,
11 favorite … and much more fun directly from terminal.
12
13 This package is built on the top of `Python Twitter Tool`_ and `Twitter API`_,
14 can run on Python 2.7.x and 3.x .
15
16 Install
17 -------
18
19 The quick way
20 ^^^^^^^^^^^^^
21
22 You will need Python and pip (2.7.x or 3.x).
23
24 .. code:: bash
25
26 sudo pip install rainbowstream
27 # Python 3 users: sudo pip3 install rainbowstream
28
29 The recommended way
30 ^^^^^^^^^^^^^^^^^^^
31
32 Use `virtualenv`_
33
34 .. code:: bash
35
36 virtualenv venv
37 # Python 3 users : use -p to specify your Python 3 localtion as below
38 # virtualenv -p /usr/bin/python3 venv
39 source venv/bin/activate
40 pip install rainbowstream
41
42 Troubleshooting
43 ^^^^^^^^^^^^^^^
44
45 If you use Linux, you might need to install some packages if you haven't already.
46 For debian-based distros, these can be installed with
47
48 .. code:: bash
49
50 sudo apt-get install python-dev libjpeg libjpeg-dev libfreetype6 libfreetype6-dev zlib1g-dev
51
52 Besides, Mac OSX Maverick with Xcode 5.1 has a well-known `clang unknown argument`_ problem with
53 the ``Pillow`` package installation - a dependency of this app.
54 If you are in this case, I recommend taking a look at `Issue #10`_ and let me know if this workaround doesn't work for you.
55
56 .. code:: bash
57
58 export ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future
59
60 If installation in *the quick way* doesn't work:
61
62 - ``sudo pip uninstall rainbowstream``
63 - use the *virtualenv way* above
64 - `create an issue`_ and provide:
65
66 + Your OS
67 + Your Python version
68
69 Usage
70 -----
71
72 The stream
73 ^^^^^^^^^^
74
75 Just type
76
77 .. code:: bash
78
79 rainbowstream
80
81 and see your stream.
82
83 I shipped a feature which can display **tweet's images directly on terminal**.
84 You can try it with:
85
86 .. code:: bash
87
88 rainbowstream -iot # Or rainbowstream --image-on-term
89
90 You also can change the config key ``IMAGE_ON_TERM`` to ``True`` inside the app
91 to enable above feature,
92 change ``IMAGE_SHIFT`` to set image's margin (relative to your terminal's width)
93 or ``IMAGE_MAX_HEIGHT`` to control max height of every image.
94 (see `config management`_ section).
95
96 In the first time you will be asked for authorization of Rainbow Stream
97 app at Twitter. Just click the “Authorize access” button and paste PIN
98 number to the terminal, the rainbow will start.
99
100 The interactive mode
101 ^^^^^^^^^^^^^^^^^^^^
102
103 While your personal stream is continued, you are also ready to tweet,
104 search, reply, retweet… directly from console. Simply type “h” and hit
105 the Enter key to see the help.
106
107 Input is in interactive mode. It means that you can use arrow key to
108 move up and down history, tab-autocomplete or 2 tab to view available
109 suggestion. Input history from previous run is available as well.
110
111 Here is full list of supported command:
112
113 **Explore Commands**
114
115 - ``trend`` will show global trending topics. ``trend US`` will show
116 trends in United States while ``trend JP Tokyo`` will show trends in
117 Tokyo/Japan.
118
119 - ``home`` will show your timeline. ``home 10`` will print exactly 10
120 tweets.
121
122 - ``mentions`` will show mentions timeline. ``mentions 7`` will show 7
123 mention tweets.
124
125 - ``whois @dtvd88`` will show profile of @dtvd88.
126
127 - ``view @mdo`` will show @mdo ’s timeline. ``view @dmo 9`` will print
128 exactly 9 tweets.
129
130 - ``s noah`` will search the word *‘noah’*. Result will come back with
131 highlight. Search can be performed with or without hashtag.
132
133 **Tweet Commands**
134
135 - ``t the rainbow is god's promise to noah`` will tweet exactly *‘the
136 rainbow is god’s promise to noah’*.
137
138 - ``rt 12`` will retweet the tweet with *[id=12]*. You can see id of
139 each tweet beside the time.
140
141 - ``quote 12`` will quote the tweet with *[id=12]*. If no extra text is added,
142 the quote will be cancelled.
143
144 - ``allrt 12 20`` will list 20 newest retweets of the tweet with *[id=12]*. If the number of retweets is not specified, 5 newest retweets will be listed instead.
145
146 - ``rep 12 Really`` will reply *‘Really’* to the tweet with *[id=12]*.
147
148 - ``fav 12`` will favorite the tweet with *[id=12]*.
149
150 - ``ufav 12`` will unfavorite tweet with *[id=12]*.
151
152 - ``del 12`` will delete tweet with *[id=12]*.
153
154 - ``show image 12`` will show the image in tweet with *[id=12]* in your
155 OS’s image viewer.
156
157 - ``open 12`` will open url in tweet with *[id=12]* in your
158 OS’s default browser.
159
160 **Direct Messages Commands**
161
162 - ``inbox`` will show inbox messages. ``inbox 7`` will show newest 7
163 messages.
164
165 - ``sent`` will show sent messages. ``sent 7`` will show newest 7
166 messages.
167
168 - ``mes @dtvd88 hi`` will send a ``hi`` message to @dtvd88.
169
170 - ``trash 5`` will remove message with *[message\_id=5]*
171
172 **Friends and followers Commands**
173
174 - ``ls fl`` will list all your followers (people who are following
175 you).
176
177 - ``ls fr`` will list all your friends (people who you are following).
178
179 - ``fl @dtvd88`` will follow @dtvd88.
180
181 - ``ufl @dtvd88`` will unfollow @dtvd88.
182
183 - ``mute @dtvd88`` will mute @dtvd88.
184
185 - ``unmute @dtvd88`` will unmute @dtvd88.
186
187 - ``muting`` will list muting users.
188
189 - ``block @dtvd88`` will block @dtvd88.
190
191 - ``unblock @dtvd88`` will unblock @dtvd88.
192
193 - ``report @dtvd88`` will report @dtvd88 as a spam account.
194
195 **Twitter list**
196
197 - ``list`` will show all lists you are belong to.
198
199 - ``list home`` will show timeline of list. You will be asked for list's name.
200
201 - ``list all_mem`` will show list's all members.
202
203 - ``list all_sub`` will show list's all subscribers.
204
205 - ``list add`` will add specific person to a list owned by you.
206
207 - ``list rm`` will remove specific person from a list owned by you.
208
209 - ``list sub`` will subscribe you to a specific list.
210
211 - ``list unsub`` will unsubscribe you from a specific list.
212
213 - ``list own`` will show all list owned by you.
214
215 - ``list new`` will create a new list.
216
217 - ``list update`` will update a list owned by you.
218
219 - ``list del`` will delete a list owned by you.
220
221 **Switching Stream Commands**
222
223 - ``switch public #AKB48`` will switch current stream to public stream
224 and track keyword ``AKB48``
225
226 - ``switch public #AKB48 -f`` will do exactly as above but will ask you
227 to provide 2 list:
228
229 ``Only nicks`` decide what nicks will be include only.
230
231 ``Ignore nicks``\ decide what nicks will be exclude.
232
233 - ``switch public #AKB48 -d`` will apply filter to *ONLY\_LIST* and
234 *IGNORE\_LIST*. You can setup 2 list above at ``config.py``
235
236 - ``switch mine`` will switch current stream to personal stream. ``-f``
237 and ``-d`` will work as well.
238
239 **Smart shell**
240
241 - Put anything to terminal, the app will try to eval and display result as a python interactive shell.
242
243 + ``142857*2`` or ``101**3`` like a calculator.
244 + Even ``cal`` will show the calendar for current month.
245 + Put ``order_rainbow('anything')`` or ``random_rainbow('wahahaha')`` will make more fun :)
246
247 **Config Management**
248
249 - ``theme`` will list available themes.
250
251 + ``theme monokai`` will apply *monokai* theme immediately.
252 + Changed theme will be remember as the next time's default theme.
253
254 - ``config`` will list all config key.
255
256 + ``config ASCII_ART`` will output current value of *ASCII_ART* config key.
257 + ``config TREND_MAX default`` will output default value of *TREND_MAX* config key.
258 + ``config CUSTOM_CONFIG drop`` will drop *CUSTOM_CONFIG* config key.
259 + ``config IMAGE_ON_TERM = true`` will set value of *IMAGE_ON_TERM* config key to *True*.
260
261 **Screening Commands**
262
263 - ``h`` will show the help.
264
265 - ``p`` will pause the stream.
266
267 - ``r`` will unpause the stream.
268
269 - ``c`` will clear the screen.
270
271 - ``q`` will quit.
272
273 Theme customization
274 ^^^^^^^^^^^^^^^^^^^
275
276 Rainbow Stream is shipped with some default themes.
277 You can either change theme by ``theme`` command or create your favorite one.
278
279 Theme’s screenshot:
280
281 - Monokai
282
283 .. figure:: https://raw.githubusercontent.com/DTVD/rainbowstream/master/screenshot/themes/Monokai.png
284 :alt: monokai
285
286 - Solarized
287
288 .. figure:: https://raw.githubusercontent.com/DTVD/rainbowstream/master/screenshot/themes/Solarized.png
289 :alt: solarized
290
291 - Tomorrow Night
292
293 .. figure:: https://raw.githubusercontent.com/DTVD/rainbowstream/master/screenshot/themes/TomorrowNight.png
294 :alt: tomorrownight
295
296 - Larapaste
297
298 .. figure:: https://raw.githubusercontent.com/DTVD/rainbowstream/master/screenshot/themes/larapaste.png
299 :alt: larapaste
300
301 For detaile information, see `theme usage and customization`_.
302
303 Config explanation
304 ^^^^^^^^^^^^^^^^^^
305
306 Rainbow Stream has a config file located at ``~/.rainbow_config.json``.
307 You can view or set a new value of every config key by ``config`` command (See **Interactive mode** section above).
308
309 - ``HEARTBEAT_TIMEOUT``: after this timeout (count by minutes), the stream will automatically hangup.
310
311 - ``IMAGE_ON_TERM``: display tweet's image directly on terminal.
312
313 - ``THEME``: current theme.
314
315 - ``ASCII_ART``: diplay your twitter name by ascii art at stream begin or not.
316
317 - ``HIDE_PROMPT``: hide prompt after receiving a tweet or not.
318
319 - ``PREFIX``: display string of prompt.
320
321 - ``SEARCH_MAX_RECORD``: max tweets can display on 'search' command.
322
323 - ``HOME_TWEET_NUM``: default tweets to display on 'home' command.
324
325 - ``RETWEETS_SHOW_NUM``: default tweets to display on 'allrt' command.
326
327 - ``QUOTE_FORMAT``: format when quote a tweet
328
329 + ``#comment``: Your own comment about the tweet
330 + ``#owner``: owner's username with '@'
331 + ``#tweet``: original tweet
332
333 - ``MESSAGES_DISPLAY``: default messages to display on 'inbox' or 'sent' command.
334
335 - ``TREND_MAX``: default trends to display on 'trend' command.
336
337 - ``LIST_MAX``: default tweets to display on 'list home' command.
338
339 - ``ONLY_LIST``: filter list on 'switch' command.
340
341 - ``IGNORE_LIST``: ignore list on 'switch' command.
342
343 - ``HISTORY_FILENAME``: name of file which stores input history.
344
345 - ``IMAGE_SHIFT``: left and right margin of image in '-iot'/'--image-on-term' mode.
346
347 - ``IMAGE_MAX_HEIGHT``: max height of image in '-iot'/'--image-on-term' mode.
348
349 - ``USER_DOMAIN``: user URL of Twitter Streaming API.
350
351 - ``PUBLIC_DOMAIN``: public URL of Twitter Streaming API.
352
353 - ``SITE_DOMAIN``: site URL of Twitter Streaming API.
354
355 - ``FORMAT``: display format for tweet and message.
356
357 + ``CLOCK_FORMAT``: time format, see `Python's strftime format`_.
358 + ``DISPLAY``: decide how tweet will be printed.
359
360 + ``#name``: Twitter's name
361 + ``#nick``: Twitter's screen name
362 + ``#clock``: Datetime
363 + ``#rt_count``: retweets count
364 + ``#fa_count``: favorites count
365 + ``#id``: ID
366 + ``#fav``: favorited symbol
367 + ``#fav``: favorited symbol
368 + ``#tweet``: Tweet's content
369 + ``#sender_name``: Message's sender name
370 + ``#sender_nick``: Message's sender screen name
371 + ``#to``: '>>>' symbol
372 + ``#recipient_name``: Message's recipient name
373 + ``#recipient_nick``: Message's recipient screen name
374
375
376 Development
377 -----------
378
379 If you want to build a runnable version yourself, follow these simple
380 steps
381
382 - `Create your own Twitter Application`_
383 - Get your Twitter application’s API key and secret
384 - Fork github's repo and clone in your system.
385 - Create a file ``consumer.py`` in ```rainbowstream```_ folder with
386 following content
387
388 .. code:: python
389
390 # Consumer information
391 CONSUMER_KEY = 'APIKey' # Your Twitter application's API key
392 CONSUMER_SECRET = 'APISecret' # Your Twitter application's API secret
393
394 - Use pip to install in local
395
396 .. code:: bash
397
398 # cd to directory which contains setup.py (cloned directory)
399 virtualenv venv # Python3 users: use -p to specify python3
400 source venv/bin/activate
401 pip install -e .
402 which rainbowstream # /this-directory/venv/bin/rainbowstream
403 pip list | grep rainbowstream # rainbowstream (0.x.x, /this-directory)
404 # Remove ~/.rainbow_oauth if exists
405 rainbowstream # local version of rainbowstream
406
407 .. _Create your own Twitter Application: https://apps.twitter.com/app/new
408 .. _``rainbowstream``: https://github.com/DTVD/rainbowstream/tree/master/rainbowstream
409 .. _Python Twitter Tool: http://mike.verdone.ca/twitter/
410 .. _Twitter API: https://dev.twitter.com/docs/api/1.1
411 .. _theme usage and customization: https://github.com/DTVD/rainbowstream/blob/master/theme.md
412 .. _virtualenv: http://docs.python-guide.org/en/latest/dev/virtualenvs/
413 .. _config management: http://rainbowstream.readthedocs.org/en/latest/#config-explanation
414 .. _Python's strftime format: https://docs.python.org/2/library/time.html#time.strftime
415 .. _clang unknown argument: http://kaspermunck.github.io/2014/03/fixing-clang-error/
416 .. _Issue #10: https://github.com/DTVD/rainbowstream/issues/10
417