zulip_bots: Add function to get the path to a bot's logo.
This is part of our efforts to have the documentation for a particular bot live in this repo but still be able to render it in the main repo (in a way similar to how we render the webhooks docs). For the logo, if a particular bot has a logo, get_bot_logo_path expects to find it as /zulip_bots/bots/{bot_name}/logo.png or /zulip_bots/bots/{bot_name}/logo.svg.
This commit is contained in:
parent
1a26ae7f2b
commit
824000f32b
|
@ -22,6 +22,19 @@ def exit_gracefully(signum, frame):
|
||||||
# type: (int, Optional[Any]) -> None
|
# type: (int, Optional[Any]) -> None
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
def get_bot_logo_path(name):
|
||||||
|
# type: str -> Optional[str]
|
||||||
|
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
logo_path_png = os.path.join(current_dir, 'bots/{bot_name}/logo.png')
|
||||||
|
logo_path_svg = os.path.join(current_dir, 'bots/{bot_name}/logo.svg')
|
||||||
|
|
||||||
|
if os.path.isfile(logo_path_png):
|
||||||
|
return logo_path_png.format(bot_name=name)
|
||||||
|
elif os.path.isfile(logo_path_svg):
|
||||||
|
return logo_path_svg.format(bot_name=name)
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
class RateLimit(object):
|
class RateLimit(object):
|
||||||
def __init__(self, message_limit, interval_limit):
|
def __init__(self, message_limit, interval_limit):
|
||||||
# type: (int, int) -> None
|
# type: (int, int) -> None
|
||||||
|
|
Loading…
Reference in a new issue