jabber_mirror: Allow the mode to be specified in the config file
(imported from commit 8de5006f6935271997204d958c44c03ebf14c403)
This commit is contained in:
parent
b5c326b444
commit
c040d16425
|
@ -275,21 +275,24 @@ def get_rooms(zulip):
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = optparse.OptionParser(epilog=
|
parser = optparse.OptionParser(epilog=
|
||||||
'''Jabber configuration options may also be specified in the zulip configuration
|
'''Most general and Jabber configuration options may also be specified in the
|
||||||
file under the jabber_mirror section. Keys have the same name as options with
|
zulip configuration file under the jabber_mirror section (exceptions are noted
|
||||||
hyphens replaced with underscores.'''
|
in their help sections). Keys have the same name as options with hyphens
|
||||||
|
replaced with underscores. Zulip configuration options go in the api section,
|
||||||
|
as normal.'''.replace("\n", " ")
|
||||||
)
|
)
|
||||||
parser.add_option('--mode',
|
parser.add_option('--mode',
|
||||||
default="personal",
|
default=None,
|
||||||
action='store',
|
action='store',
|
||||||
help= \
|
help= \
|
||||||
'''Which mode to run in. Valid options are "personal" and "public". In
|
'''Which mode to run in. Valid options are "personal" and "public". In
|
||||||
"personal" mode, the mirror uses an individual users' credentials and mirrors
|
"personal" mode, the mirror uses an individual users' credentials and mirrors
|
||||||
all messages they send on Zulip to Jabber and all private Jabber messages to
|
all messages they send on Zulip to Jabber and all private Jabber messages to
|
||||||
Zulip. In "public" mode, the mirror uses the credentials for a dedicated mirror
|
Zulip. In "public" mode, the mirror uses the credentials for a dedicated mirror
|
||||||
user and mirrors messages sent to Jabber rooms to Zulip.'''.replace("\n", " "))
|
user and mirrors messages sent to Jabber rooms to Zulip. Defaults to
|
||||||
|
"personal"'''.replace("\n", " "))
|
||||||
parser.add_option('-d', '--debug',
|
parser.add_option('-d', '--debug',
|
||||||
help='set logging to DEBUG',
|
help='set logging to DEBUG. Can not be set via config file.',
|
||||||
action='store_const',
|
action='store_const',
|
||||||
dest='log_level',
|
dest='log_level',
|
||||||
const=logging.DEBUG,
|
const=logging.DEBUG,
|
||||||
|
@ -335,7 +338,7 @@ user and mirrors messages sent to Jabber rooms to Zulip.'''.replace("\n", " "))
|
||||||
config.readfp(f, config_file)
|
config.readfp(f, config_file)
|
||||||
except IOError:
|
except IOError:
|
||||||
pass
|
pass
|
||||||
for option in ("jid", "jabber_password", "conference_domain"):
|
for option in ("jid", "jabber_password", "conference_domain", "mode"):
|
||||||
if (getattr(options, option) is None
|
if (getattr(options, option) is None
|
||||||
and config.has_option("jabber_mirror", option)):
|
and config.has_option("jabber_mirror", option)):
|
||||||
setattr(options, option, config.get("jabber_mirror", option))
|
setattr(options, option, config.get("jabber_mirror", option))
|
||||||
|
@ -347,6 +350,9 @@ user and mirrors messages sent to Jabber rooms to Zulip.'''.replace("\n", " "))
|
||||||
else:
|
else:
|
||||||
setattr(options, option, False)
|
setattr(options, option, False)
|
||||||
|
|
||||||
|
if options.mode is None:
|
||||||
|
options.mode = "personal"
|
||||||
|
|
||||||
if options.mode not in ('public', 'personal'):
|
if options.mode not in ('public', 'personal'):
|
||||||
sys.exit("Bad value for --mode: must be one of 'public' or 'personal'")
|
sys.exit("Bad value for --mode: must be one of 'public' or 'personal'")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue