Mercurial > code > home > repos > zulip
comparison bots/bigastbot.py @ 0:96f842f12121
start
author | drewp@bigasterisk.com |
---|---|
date | Tue, 28 Jan 2025 23:30:02 -0800 |
parents | |
children | 2a288d2cb88c |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:96f842f12121 |
---|---|
1 import zulip | |
2 from kubernetes import client, config | |
3 | |
4 config.load_kube_config() | |
5 | |
6 | |
7 def get_secret_api_key(email: str) -> str: | |
8 api = client.CoreV1Api() | |
9 secret = api.read_namespaced_secret('zulip-api-secrets', 'default') | |
10 secret_key = email.replace('@', '.') | |
11 return secret.data[secret_key] # type: ignore | |
12 | |
13 | |
14 class BigAstBot: | |
15 | |
16 def __init__(self, email: str): | |
17 | |
18 class Options: | |
19 zulip_api_key = get_secret_api_key(email) | |
20 zulip_email = email | |
21 zulip_site = 'https://chat.bigasterisk.com' | |
22 cert_bundle = None | |
23 client_cert = None | |
24 client_cert_key = None | |
25 insecure = False | |
26 verbose = True | |
27 zulip_client = None | |
28 zulip_config_file = None | |
29 | |
30 self.zulip_client = zulip.init_from_options(Options()) | |
31 | |
32 def send_to_channel(self, channelName: str, topic: str, content: str): | |
33 msg = dict(type="stream", | |
34 to=[channelName], | |
35 topic=topic, | |
36 content=content) | |
37 return self.zulip_client.send_message(msg) |