-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
48 lines (42 loc) · 1.57 KB
/
index.js
File metadata and controls
48 lines (42 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const readLastLines = require('read-last-lines');
const TelegramBot = require('node-telegram-bot-api');
const fs = require("fs");
const env = require('dotenv').config().parsed;
// replace the value below with the Telegram token you receive from @BotFather
const token = env.TOKEN;
var fileSizeApi = 0;
var fileSizeTrack = 0;
var fileSizeCallback = 0;
// Create a bot that uses 'polling' to fetch new updates
const bot = new TelegramBot(token, {polling: true});
// Listen for any kind of message. There are different kinds of
// messages.
bot.on('message', (msg) => {
const chatId = msg.chat.id;
// send a message to the chat acknowledging receipt of their message
bot.sendMessage(chatId, 'you chat id is: ' + chatId);
});
setInterval(async () => {
var errors = await readLastLines.read(env.PATH_ZERO_CONF, 5);
var stats = fs.statSync(env.PATH)
if (stats.size !== fileSizeApi) {
bot.sendMessage(env.XIN, 'zero_conf api new error:' + errors);
}
fileSizeApi = stats.size
}, 1000)
setInterval(async () => {
var errors = await readLastLines.read(env.PATH_TRACK, 5);
var stats = fs.statSync(env.PATH)
if (stats.size !== fileSizeTrack) {
bot.sendMessage(env.XIN, 'zero_conf tracker new error:' + errors);
}
fileSizeTrack = stats.size
}, 1000)
setInterval(async () => {
var errors = await readLastLines.read(env.PATH_CALLBACK, 5);
var stats = fs.statSync(env.PATH)
if (stats.size !== fileSizeCallback) {
bot.sendMessage(env.XIN, 'zero_conf callback new error:' + errors);
}
fileSizeCallback = stats.size
}, 1000)