[英]Telegram Bot -UnhandledPromiseRejectionWarning: Error: 400: Bad Request: chat not found
I am trying to get chat from one user using my telegram bot.我正在尝试使用我的电报机器人与一位用户聊天。 Below is my code so far
到目前为止,下面是我的代码
const { Telegraf } = require('telegraf')
const bot = new Telegraf(process.env.BOT_TOKEN);
bot.telegram.getChat('username', async (ctx) =>{'incoming message ', console.log(ctx.message.tesx)})
from Doument来自杜门
(method) Telegram.getChat(chatId: string | number): Promise<ChatFromGetChat>
Get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.).
@param chatId — Unique identifier for the target chat or username of the target supergroup or channel (in the format
@channelusername — )
so in my parameter i use the username of that particular chat (not group chat, only 1 person) but it return chat not found.所以在我的参数中,我使用了那个特定聊天的用户名(不是群聊,只有 1 个人),但它返回聊天未找到。
Any advice is appreciated任何建议表示赞赏
You have to pass the chat and chat id for the getChat instead of just passing a string.您必须为 getChat 传递聊天和聊天 ID,而不仅仅是传递字符串。
bot.telegram.getChat(ctx.message.chat.id, ctx.message.chat, async (ctx) =>
{'incoming message ', console.log(ctx.message.tesx)})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.