Skip to content
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

fix #3

Merged
merged 1 commit into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/bot/TelegramBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { Bot, GrammyError, HttpError, session } = require("grammy");

const { start, search } = require("./commands");
const User = require("../db/schemas/User");
const Monitor = require("../db/schemas/Monitor");

const i18n = new I18n({
defaultLocale: "en",
Expand Down Expand Up @@ -36,6 +37,7 @@ class TelegramBot {
this.#bot.on('my_chat_member', async ctx => {
if (['kicked', 'left'].includes(ctx.myChatMember.new_chat_member.status)) {
await User.deactivate(ctx.myChatMember.chat.id);
await Monitor.deleteByTelegramId(ctx.myChatMember.chat.id);
this.#pagination.flushUserCache(ctx.from.id);
}
});
Expand Down
4 changes: 4 additions & 0 deletions app/db/schemas/Monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ MonitorSchema.statics.createOrUpdate = function ({
);
};

MonitorSchema.statics.deleteByTelegramId = function (telegramId) {
return this.deleteMany({ telegramId });
};

const Monitor = model('Monitor', MonitorSchema);

module.exports = Monitor;
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ services:
- app-network
healthcheck:
test: rabbitmq-diagnostics -q ping
interval: 5s
interval: 30s
timeout: 5s
retries: 5
start_period: 10s
logging:
driver: json-file
options:
Expand Down
Loading