mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 17:15:03 -07:00
discord
This commit is contained in:
@@ -13,8 +13,8 @@ export class TelegramService implements OnModuleInit {
|
||||
private readonly configService: ConfigService,
|
||||
private readonly telegramSubscriptionsService: TelegramSubscriptionsService
|
||||
) {
|
||||
const token: string = this.configService.get('TELEGRAM_BOT_TOKEN');
|
||||
if (token.length < 1) {
|
||||
const token: string | null = this.configService.get('TELEGRAM_BOT_TOKEN');
|
||||
if (token == null || token.length < 1) {
|
||||
console.log('No Telegram token found');
|
||||
return;
|
||||
}
|
||||
@@ -26,6 +26,10 @@ export class TelegramService implements OnModuleInit {
|
||||
|
||||
async onModuleInit(): Promise<void> {
|
||||
|
||||
if (this.bot == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
this.bot.onText(/\/subscribe/, async (msg) => {
|
||||
const address = msg.text.split('/subscribe ')[1];
|
||||
if (validate(address) == false) {
|
||||
@@ -46,6 +50,10 @@ export class TelegramService implements OnModuleInit {
|
||||
}
|
||||
|
||||
public async notifySubscribersBlockFound(address: string) {
|
||||
if (this.bot == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const subscribers = await this.telegramSubscriptionsService.getSubscriptions(address);
|
||||
subscribers.forEach(subscriber => {
|
||||
this.bot.sendMessage(subscriber.telegramChatId, 'You found a block!');
|
||||
|
||||
Reference in New Issue
Block a user