当我检查here时,电报中的KeyboardButton
对象没有tag
或data
字段。我有我的机器人键盘的这个实现:
$keyboardArray = array('Hello', 'Hi');
apiRequestJson("sendMessage", array('chat_id' => $chat_id, "text" => 'Hello', 'reply_markup' => array(
'keyboard' => array($keyboardArray),
'one_time_keyboard' => true,
'resize_keyboard' => true)));
目前按下键盘按钮,将按钮标签发送到我的机器人。 我想知道有没有电报键盘的选项,除了键盘按钮的标签,它可以向机器人发送特殊信息吗?例如,当我按下你好时它发送100,当我按下嗨按钮时发送200.
答案 0 :(得分:0)
不,这是不可能的,这些键盘只能发送自己的标签。可能的是InlineKeyboards(see this)。在那里,您可以指定callback_data
,当按下该键时,该InlineKeyboardButton
将提供给您的服务器。您还可以指定在按钮单击时打开的URL。请参阅$x=1;
$newfilename=$movedname;
while(is_file($_SERVER['DOCUMENT_ROOT'].$newfilename)){ //actual control
$newfilename=$movedname;//to prevent creating flower123.jpg at the third iteration, see below
$fn=explode(".",$newfilename);
$fp=count($fn)-2;
$fn[$fp].=$x;
//here we get the filename before extension (eg. "flower" in fakepath/flower.jpg) and add $x to get "flower1"
$newfilename=implode(".",$fn);
//we rebuild our path having now fakepath/flower1.jpg
$x++;
}
move_uploaded_file($filevar['tmp_name'], $_SERVER['DOCUMENT_ROOT'].$newfilename);
here的文档。