mullwar / telebot

The easy way to write Telegram bots in Node.js
https://www.npmjs.com/package/telebot
MIT License
1.48k stars 270 forks source link

How to add a message handler to the bot ? #194

Open xMA3x opened 3 years ago

xMA3x commented 3 years ago

I want to 1- log (date, user name,chatid, first name, last name) for every message that a user sends and if it possible it be in a spreadsheet

2- store every chatid that used the bot, so i can send a message to evrey user and if there is another way, i will appreciate it

TeLoardBruh commented 3 years ago

hello,

for the

feel free to ask for further clarify .

TeLoardBruh commented 3 years ago

or msg.from.id,

xMA3x commented 3 years ago

hello,

for the

  • first question I believe it is in the GitHub readme below the files, just scroll downwards and spends times reading the documents that the author wrote, you will see something like this Screenshot (46)
  • same goes to your second question, what you should looking for is something like "msg.chatId"

feel free to ask for further clarify .

I haad already found a way in KittyBot.js example that shows how to log every msg

// Log every text message
bot.on('text', function (msg) {
    console.log(`[text] ${ msg.chat.id } ${ msg.text }`);
});

but the idea is: how I can SAVE the log, even after deploy it to Heroku is there is a way to save it to a spreadsheet ? or i will have to add a test file to save the log ? or Heroku will show it in the log acticity?

and for the secand on, even after saving the chatid, how I will be able to send them a msg?

TeLoardBruh commented 3 years ago

to save log into database you need to create a function that do so, look up for something like "save info in rest API" something like that