File tree Expand file tree Collapse file tree 2 files changed +46
-33
lines changed
zulip_botserver/zulip_botserver Expand file tree Collapse file tree 2 files changed +46
-33
lines changed Original file line number Diff line number Diff line change
1
+ import argparse
2
+
3
+
4
+ def parse_args () -> argparse .Namespace :
5
+ usage = '''
6
+ zulip-bot-server --config-file <path to flaskbotrc> --hostname <address> --port <port>
7
+ Example1: zulip-bot-server --config-file ~/flaskbotrc
8
+ Example2: zulip-bot-server --config-file ~/flaskbotrc -b mybotname
9
+ (This program loads the bot configurations from the
10
+ config file (flaskbotrc here) and loads the bot modules.
11
+ It then starts the server and fetches the requests to the
12
+ above loaded modules and returns the success/failure result)
13
+ Please make sure you have a current flaskbotrc file with the
14
+ configurations of the required bots.
15
+ Hostname and Port are optional arguments. Default hostname is
16
+ 127.0.0.1 and default port is 5002.
17
+ See lib/readme.md for more context.
18
+ '''
19
+
20
+ parser = argparse .ArgumentParser (usage = usage )
21
+ parser .add_argument (
22
+ '--config-file' ,
23
+ action = 'store' ,
24
+ required = True ,
25
+ help = 'Config file for the zulip bot server (flaskbotrc)'
26
+ )
27
+ parser .add_argument (
28
+ '--bot-name' , '-b' ,
29
+ action = 'store' ,
30
+ help = 'Bot name (optional, rewrites first bot name from config file). '
31
+ 'Only for single-bot usage! Other bots will be ignored'
32
+ )
33
+ parser .add_argument (
34
+ '--hostname' ,
35
+ action = 'store' ,
36
+ default = "127.0.0.1" ,
37
+ help = 'Address on which you want to run the server'
38
+ )
39
+ parser .add_argument (
40
+ '--port' ,
41
+ action = 'store' ,
42
+ default = 5002 ,
43
+ type = int ,
44
+ help = 'Port on which you want to run the server'
45
+ )
46
+ return parser .parse_args ()
Original file line number Diff line number Diff line change 1
- import argparse
2
1
import configparser
3
2
import json
4
3
import os
@@ -105,38 +104,6 @@ def handle_bot(bot: str) -> Union[str, BadRequest]:
105
104
return json .dumps ("" )
106
105
107
106
108
- def parse_args () -> argparse .Namespace :
109
- usage = '''
110
- zulip-bot-server --config-file <path to flaskbotrc> --hostname <address> --port <port>
111
- Example: zulip-bot-server --config-file ~/flaskbotrc
112
- (This program loads the bot configurations from the
113
- config file (flaskbotrc here) and loads the bot modules.
114
- It then starts the server and fetches the requests to the
115
- above loaded modules and returns the success/failure result)
116
- Please make sure you have a current flaskbotrc file with the
117
- configurations of the required bots.
118
- Hostname and Port are optional arguments. Default hostname is
119
- 127.0.0.1 and default port is 5002.
120
- See lib/readme.md for more context.
121
- '''
122
-
123
- parser = argparse .ArgumentParser (usage = usage )
124
- parser .add_argument ('--config-file' ,
125
- action = 'store' ,
126
- required = True ,
127
- help = 'Config file for the zulip bot server (flaskbotrc)' )
128
- parser .add_argument ('--hostname' ,
129
- action = 'store' ,
130
- default = "127.0.0.1" ,
131
- help = 'Address on which you want to run the server' )
132
- parser .add_argument ('--port' ,
133
- action = 'store' ,
134
- default = 5002 ,
135
- type = int ,
136
- help = 'Port on which you want to run the server' )
137
- return parser .parse_args ()
138
-
139
-
140
107
def main () -> None :
141
108
options = parse_args ()
142
109
bots_config = read_config_file (options .config_file )
You can’t perform that action at this time.
0 commit comments