-1

I am writing a new Bot for Telegram for the first time using PHP Telegram Bot.
Imagine I want to show What is your name? for /start command and wait for user's answer, wait for user's answer and then show Hello USER_NAME to him.

I could implement /start commands. But how can I get user's reply that is not in form of /command? Actually I need a listener to a non-command message.

Is there anyone who can help me?

4

2 回答 2

1

穆罕默德·扬,

你应该自己做。我建议您将聊天存储在数据库表中,然后将下一个命令存储在每个聊天的列中。

假设在/start您查找用户名之后,您将存储/name到 next_command 列中,并且每当您收到没有任何的普通消息时/command,您可以检查 next_command 列并将收到的消息视为“你叫什么名字”的答案?” 问题。

您可以继续此过程以从用户那里获取完整数据。例如,在得到名字后,你可以问“你多大了?” 并更改next_command/old,然后将下一条消息视为上一个问题的答案。

顺便说一句,这只是一个建议。您应该能够找到适合您的方式。但是很明显,您应该自己做,因为电报只向您的机器人提供消息,而管理它们的是您的机器人。

希望能帮助到你。

于 2017-06-05T03:12:29.200 回答
-1

转到@BotFather,然后关闭隐私模式

/setprivacy— 设置您的机器人在添加到组时将收到哪些消息。禁用隐私模式后,机器人将接收所有消息。

于 2017-06-05T00:10:45.717 回答