mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 17:07:07 +00:00
bots: Add get_config_info function for bots.
This commit is contained in:
@@ -7,6 +7,8 @@ import sys
|
||||
import time
|
||||
import re
|
||||
|
||||
from six.moves import configparser
|
||||
|
||||
if False:
|
||||
from mypy_extensions import NoReturn
|
||||
from typing import Any, Optional, List, Dict
|
||||
@@ -94,6 +96,16 @@ class BotHandlerApi(object):
|
||||
content=response,
|
||||
))
|
||||
|
||||
def get_config_info(self, bot_name, section=None):
|
||||
# type: (str, Optional[str]) -> Dict[str, Any]
|
||||
conf_file_path = os.path.realpath(os.path.join(
|
||||
our_dir, '..', 'bots', bot_name, bot_name + '.conf'))
|
||||
section = section or bot_name
|
||||
config = configparser.ConfigParser()
|
||||
config.read(conf_file_path)
|
||||
return dict(config.items(section))
|
||||
|
||||
|
||||
class StateHandler(object):
|
||||
def __init__(self):
|
||||
# type: () -> None
|
||||
|
||||
Reference in New Issue
Block a user