简体   繁体   English

php - 电报机器人消息宽度

[英]php - telegram bot message width

currently I'm working on a telegram bot in php and Yii2 framework. 目前我正在使用php和Yii2框架中的电报机器人。 I want to send a message that has a fixed width in telegram. 我想在电报中发送一个固定宽度的消息。 if i send "Hi!" 如果我发送“嗨!” it should fill a line like this image: 它应该填写像这样的图像: 在此输入图像描述

is it possible? 可能吗? I want the spaces after message so <br> wont do that and breaks the line right after the word 'Hi'. 我想空格消息后,所以<br>不会做到这一点,单词“你好”之后打破了线。 can I do this without <code> tag? 我可以在没有<code>标签的情况下这样做吗? because this tag make the message like a line of code . 因为这个标签使消息像一行code

White space(s) and newline(s) at the two ends of the string are trimmed for a good reason. 弦的两端的白色空格和换行符被修剪是有充分理由的。 So, it is not possible to send the text with space or newline character(s) at any of the two ends, though you can put spaces at the end of the lines before the last character that's neither a space nor a newline. 因此,不可能在两端中的任何一端发送带有空格或换行符的文本,尽管您可以在最后一个既不是空格也不是换行符的行之前的行尾添加空格。

Update #1 There is a trick though. 更新#1虽然有一个技巧。 You can add Zero-width non-joiner as the text to a <a> tag with empty href after any number of spaces you want. 在任意数量的空格之后,您可以将零宽度非连接器作为文本添加到带有空href<a>标签。 So the essential params for sendMessage method will be: 所以sendMessage方法的基本参数将是:

$text = 'hi‌‌‌‌‌‌‌‌‌‌‌‌                           <a href="">&#8204;</a>';
$chat_id = <your chat_id>;
$parse_mode = 'HTML';


在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM