Telegram 机器人 - 如何使用 mypokerbot 等图标创建回复菜单?

Telegram Bots - How Can I create Reply Menus with icons like mypokerbot?

我有一个通过电报机器人发送菜单的通用功能(如下所示),但我不知道如何在这些菜单上添加图标(mypokerbot 的方式,检查图像)。有什么提示吗?

function SendGenericMenu ($chatid) {
$lista=array("A", "B", "C");
$text="Choose:";
global $bottoken;
$replyMarkup = array(
    'keyboard' => $lista,
);
$encodedMarkup = json_encode($replyMarkup);
$content = array(
    'chat_id' => $chatid,
    'reply_markup' => $encodedMarkup,
    'text' => "$text"
);

$ch = curl_init();
$url="https://api.telegram.org/bot$bottoken/SendMessage";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($content));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

// receive server response ...
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$server_output = curl_exec ($ch);
curl_close ($ch);
var_dump($server_output);

}

你应该使用表情符号,取自这里:
http://apps.timwhitlock.info/emoji/tables/unicode
单击 Unicode 列您可以获得不同编码的值。

将表情符号字符串与您的消息连接起来以构建您的键盘文本。
对于 Java 它将是:

String s = new String(new byte[]{(byte) 0xF0, (byte) 0x9F, (byte) 0x98, (byte) 0x81}, "UTF-8");

String s = "\uD83D\uDE4C" + "myKeyboardTest";

对于PHP我认为是这样的:

"\xF0\x9F\x98\x81" . "your super keyboard"

在 MyPokerBot 中,我们使用表情符号和命令的关联列表。在检查 "what method of code should we call" 的主循环中,它检查文本是否以该表情符号开头并调用它的命令。

示例:

protected $shortCmds = [
    Emoji::CMD_MAIN_MENU      => '/start',
    Emoji::CMD_STOP           => '/stop',
];

您可以将所有表情符号存储在表情符号 class 中作为 ihoru and append them as pengrad . Yet you don't necessarily have to store unicode values of emojis in constants. You can copy paste emojis as strings from, say, http://emojipedia.org/ 的常量,这在某些操作系统上的某些 IDE 中应该也能正常工作,例如Mac 表情符号将以人类可理解的形式实际表示。

一个更简单的方法是用你喜欢的表情符号在电报中写一条剪贴信息(不要发送)。然后 copy/paste 将该文本(包括表情符号)添加到您的代码中。他们将完美复制。 整个过程如图所示: Emoji Icons copy/paste