简体   繁体   English

Telegram Bot -UnhandledPromiseRejectionWarning:错误:400:错误请求:找不到聊天

[英]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.

相关问题 Telegram Bot deleteMessage 函数返回 400 Bad Request Error - Telegram Bot deleteMessage function returns 400 Bad Request Error telebot.apihelper.ApiTelegramException:对 Telegram API 的请求不成功。 错误代码:400。说明:错误请求:找不到聊天 - telebot.apihelper.ApiTelegramException: A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: chat not found 电报 API 不适用于用户名 - 400。错误请求:找不到聊天 - Telegram API doesn't work with username - 400. Bad Request: chat not found 电报机器人“找不到聊天” - Telegram Bot "chat not found" 电报错误 400 错误请求上的内联键盘 - inline keyboard on telegram error 400 bad request 电报机器人 API Python - telegram.error.BadRequest:找不到聊天 - Telegram Bot API Python - telegram.error.BadRequest: Chat not found 电报机器人向聊天错误发送消息:找不到聊天 - Telegram bot send message to chat error : chat not found 尝试编辑消息时出现 Telegram Bot API 错误:“错误请求:找不到消息” - Telegram Bot API error when try to edit message: "Bad Request: message not found" PHP 电报机器人:错误请求:未找到要编辑的消息 - PHP telegram bot : Bad Request: message to edit not found 为什么调用 Telegram Bot API 报告错误消息:“未找到聊天” - Why invoke Telegram Bot API reported error msg : "chat not found"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM