mirror of
https://github.com/tornadocash/tornado-relayer
synced 2024-02-02 15:04:06 +01:00
add MockTelegram
This commit is contained in:
parent
66dc7efa60
commit
eef6bb2581
@ -19,16 +19,30 @@ export enum AlertType {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class MockTelegram {
|
||||||
|
async sendMessage(chatId, text: string, extra?: any) {
|
||||||
|
console.log(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
async getMe() {
|
||||||
|
return {
|
||||||
|
id: 1,
|
||||||
|
first_name: 'test',
|
||||||
|
is_bot: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@autoInjectable()
|
@autoInjectable()
|
||||||
export class NotifierService {
|
export class NotifierService {
|
||||||
private telegram: Telegram;
|
private telegram: Telegram | MockTelegram;
|
||||||
private readonly token: string;
|
private readonly token: string;
|
||||||
private readonly chatId: string;
|
private readonly chatId: string;
|
||||||
|
|
||||||
constructor(private store: RedisStore) {
|
constructor(private store: RedisStore) {
|
||||||
this.token = process.env.TELEGRAM_NOTIFIER_BOT_TOKEN || '';
|
this.token = process.env.TELEGRAM_NOTIFIER_BOT_TOKEN;
|
||||||
this.chatId = process.env.TELEGRAM_NOTIFIER_CHAT_ID || '';
|
this.chatId = process.env.TELEGRAM_NOTIFIER_CHAT_ID;
|
||||||
this.telegram = new Telegram(this.token);
|
this.telegram = this.token ? new Telegram(this.token) : new MockTelegram();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +72,6 @@ export class NotifierService {
|
|||||||
|
|
||||||
send(message: string, level: Levels) {
|
send(message: string, level: Levels) {
|
||||||
const text = `${AlertLevel[level]} ${message}`;
|
const text = `${AlertLevel[level]} ${message}`;
|
||||||
console.log('sending message: ', text);
|
|
||||||
return this.telegram.sendMessage(
|
return this.telegram.sendMessage(
|
||||||
this.chatId,
|
this.chatId,
|
||||||
text,
|
text,
|
||||||
|
Loading…
Reference in New Issue
Block a user