26
26
from __future__ import print_function
27
27
import os
28
28
import sys
29
- import optparse
29
+ import argparse
30
30
from six .moves .configparser import ConfigParser , NoSectionError , NoOptionError
31
31
32
32
import zulip
@@ -41,9 +41,9 @@ def write_config(config, since_id):
41
41
with open (CONFIGFILE , 'wb' ) as configfile :
42
42
config .write (configfile )
43
43
44
- parser = optparse . OptionParser (r"""
44
+ parser = zulip . add_default_arguments ( argparse . ArgumentParser (r"""
45
45
46
- %prog --user [email protected] --api-key a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 \
46
+ twitter-search-bot --user [email protected] --api-key a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 \
47
47
--search="@nprnews,quantum physics"
48
48
49
49
Send Twitter search results to a Zulip stream.
@@ -89,24 +89,23 @@ new application under your Twitter account:
89
89
90
90
Make sure to go the application you created and click "create my
91
91
access token" as well. Fill in the values displayed.
92
- """ )
93
-
94
- parser .add_option ('--search' ,
95
- dest = 'search_terms' ,
96
- help = 'Terms to search on' ,
97
- action = 'store' )
98
- parser .add_option ('--stream' ,
99
- dest = 'stream' ,
100
- help = 'The stream to which to send tweets' ,
101
- default = "twitter" ,
102
- action = 'store' )
103
- parser .add_option ('--limit-tweets' ,
104
- default = 15 ,
105
- type = 'int' ,
106
- help = 'Maximum number of tweets to send at once' )
107
-
108
- parser .add_option_group (zulip .generate_option_group (parser ))
109
- (opts , args ) = parser .parse_args ()
92
+ """ ))
93
+
94
+ parser .add_argument ('--search' ,
95
+ dest = 'search_terms' ,
96
+ help = 'Terms to search on' ,
97
+ action = 'store' )
98
+ parser .add_argument ('--stream' ,
99
+ dest = 'stream' ,
100
+ help = 'The stream to which to send tweets' ,
101
+ default = "twitter" ,
102
+ action = 'store' )
103
+ parser .add_argument ('--limit-tweets' ,
104
+ default = 15 ,
105
+ type = int ,
106
+ help = 'Maximum number of tweets to send at once' )
107
+
108
+ opts = parser .parse_args ()
110
109
111
110
if not opts .search_terms :
112
111
parser .error ('You must specify a search term.' )
0 commit comments