telegram: Add support for topics. (#184)
This commit is contained in:
parent
bf3170cb6f
commit
775fb89cf6
|
@ -1,6 +1,7 @@
|
|||
[default.publisher.telegram]
|
||||
active=true
|
||||
chat_id="xxx"
|
||||
message_thread_id="xxx"
|
||||
token="xxx"
|
||||
username="xxx"
|
||||
[default.publisher.zulip]
|
||||
|
@ -31,6 +32,7 @@ page_access_token="xxx"
|
|||
[default.notifier.telegram]
|
||||
active=true
|
||||
chat_id="xxx"
|
||||
message_thread_id="xxx"
|
||||
token="xxx"
|
||||
username="xxx"
|
||||
[default.notifier.zulip]
|
||||
|
|
|
@ -4,6 +4,7 @@ from dynaconf import Validator
|
|||
|
||||
telegram_validators = [
|
||||
Validator("notifier.telegram.chat_id", must_exist=True),
|
||||
Validator("notifier.telegram.message_thread_id", default=None),
|
||||
Validator("notifier.telegram.token", must_exist=True),
|
||||
Validator("notifier.telegram.username", must_exist=True),
|
||||
]
|
||||
|
|
|
@ -3,6 +3,7 @@ from dynaconf import Validator
|
|||
|
||||
telegram_validators = [
|
||||
Validator("publisher.telegram.chat_id", must_exist=True),
|
||||
Validator("publisher.telegram.message_thread_id", default=None),
|
||||
Validator("publisher.telegram.msg_template_path", must_exist=True, default=None),
|
||||
Validator("publisher.telegram.recap_template_path", must_exist=True, default=None),
|
||||
Validator(
|
||||
|
|
|
@ -99,9 +99,14 @@ class TelegramPlatform(AbstractPlatform):
|
|||
)
|
||||
|
||||
def _send(self, message: str, event: Optional[MobilizonEvent] = None) -> Response:
|
||||
json_message = {"chat_id": self.conf.chat_id, "text": message, "parse_mode": "html"}
|
||||
|
||||
if self.conf.message_thread_id:
|
||||
json_message["message_thread_id"] = self.conf.message_thread_id
|
||||
|
||||
return requests.post(
|
||||
url=f"https://api.telegram.org/bot{self.conf.token}/sendMessage",
|
||||
json={"chat_id": self.conf.chat_id, "text": message, "parse_mode": "html"},
|
||||
json=json_message,
|
||||
)
|
||||
|
||||
def _validate_response(self, res):
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
[default]
|
||||
local_state_dir = "/var/mobilizon_reshare"
|
||||
db_url = "sqlite:///var/mobilizon_reshare/events.db"
|
||||
log_dir = "@format {this.local_state_dir}"
|
||||
db_url = "@format sqlite://{this.local_state_dir}/events.db"
|
||||
locale= "en-us"
|
||||
|
||||
[default.source.mobilizon]
|
||||
|
@ -31,7 +32,7 @@ stream = "ext://sys.stderr"
|
|||
level = "DEBUG"
|
||||
class = "logging.handlers.RotatingFileHandler"
|
||||
formatter = "standard"
|
||||
filename = "/var/log/mobilizon_reshare/mobilizon_reshare.log"
|
||||
filename = "@format {this.log_dir}/mobilizon_reshare.log"
|
||||
maxBytes = 52428800
|
||||
backupCount = 500
|
||||
encoding = "utf8"
|
||||
|
|
Loading…
Reference in New Issue