-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Support group topics in Telgram sender #1022
base: master
Are you sure you want to change the base?
Feature: Support group topics in Telgram sender #1022
Conversation
Bumped telebot package from v2.5.0 to v3.2.1. Fixed related issues in /moira/senders/telegram caused by backwards incompatible struct names and method signatures. Relates moira-alert#1009
Also includes major refactoring of senders/telegram/send.go Custom `Chat` struct is now used for storing chat data in db as json object and `sender.talk`, `sender.sendAsMessage`, `sender.sendAsAlbum` functions instead of `telebot.Chat`. Relates moira-alert#1009
Also includes some refactoring to enable mocking `Sender.bot`. Relates moira-alert#1009
iter := d.Client().Scan(d.Context(), 0, telegramUsersKey+"*", 0).Iterator() | ||
for iter.Next(d.Context()) { | ||
key := iter.Val() | ||
if key == telegramLockName { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a recent PR #1027 we changed the key name slightly from moira-telegram-users:moira-bot-host
to moira-telegram-users:moira-bot-host:*
, so I suggest changing the code like this:
var (
telegramUsersKey = "moira-telegram-users:"
telegramLockName = "moira-telegram-users:moira-bot-host:"
)
if strings.HasPrefix(key, telegramLockName) {
continue
}
iter := d.Client().Scan(d.Context(), 0, telegramUsersKey+"*", 0).Iterator() | ||
for iter.Next(d.Context()) { | ||
key := iter.Val() | ||
if key == telegramLockName { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var (
telegramUsersKey = "moira-telegram-users:"
telegramLockName = "moira-telegram-users:moira-bot-host:"
)
if strings.HasPrefix(key, telegramLockName) {
continue
}
Implements support for group topics as Moira Notification Channels in Telegram sender
Closes #1009