first commit
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import {Injectable} from "@nestjs/common";
|
||||
import axios from "axios";
|
||||
|
||||
@Injectable()
|
||||
export class NotifyService {
|
||||
async sendMessageToTele(message: string): Promise<any> {
|
||||
const axios = require('axios');
|
||||
|
||||
const BOT_TOKEN = process.env.TELEGRAM_BOT_TOKEN!;
|
||||
const CHAT_ID = process.env.TELEGRAM_CHAT_ID!;
|
||||
|
||||
await axios.post(
|
||||
`https://api.telegram.org/bot${BOT_TOKEN}/sendMessage`,
|
||||
{
|
||||
chat_id: CHAT_ID,
|
||||
text: message,
|
||||
parse_mode: 'HTML'
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
async sendMessageToTeleByChatId(chatId:number,message: string): Promise<any> {
|
||||
const axios = require('axios');
|
||||
|
||||
const BOT_TOKEN = process.env.TELEGRAM_BOT_TOKEN!;
|
||||
|
||||
await axios.post(
|
||||
`https://api.telegram.org/bot${BOT_TOKEN}/sendMessage`,
|
||||
{
|
||||
chat_id: chatId,
|
||||
text: message,
|
||||
parse_mode: 'HTML'
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user