如何使用 Telegram Bot API 发送表格? [英] How do I send Tables with Telegram Bot API?
问题描述
我需要发送股市数据,现在格式很糟糕.需要发送类似这样的东西
<代码>|符号 |价格 |改变 ||--------|-------|--------||ABC |20.85 |1.626 ||防御 |78.95 |0.099 ||全球健康指数 |23.45 |0.192 ||JKL |98.85 |0.292 |
这是我试过的.
<代码>|符号 |价格 |改变 ||--------|-------|--------||ABC |20.85 |1.626 ||防御 |78.95 |0.099 ||全球健康指数 |23.45 |0.192 ||JKL |98.85 |0.292 |
将 Telegram API parse_mode 参数设置为 HTML并将消息包装在
,但请记住,电报 API 不支持嵌套标签.
|表 |是 |酷 ||-----------|:-------------:|------:||第 1 列是 |左对齐 |1600 美元 ||第 2 列是 |居中 |12 美元 ||第 3 列是 |右对齐 |$1 |
在电报信使中的结果:
已更新.如何转换图中的表格
智能手机的小屏幕会出现问题.所以这个方法不好.唯一的选择是转换图片中的表格,然后发送:
I need to send stock market data and the formatting sucks right now. Need to send something liike this
| Symbol | Price | Change |
|--------|-------|--------|
| ABC | 20.85 | 1.626 |
| DEF | 78.95 | 0.099 |
| GHI | 23.45 | 0.192 |
| JKL | 98.85 | 0.292 |
This is what I have tried.
| Symbol | Price | Change |
|--------|-------|--------|
| ABC | 20.85 | 1.626 |
| DEF | 78.95 | 0.099 |
| GHI | 23.45 | 0.192 |
| JKL | 98.85 | 0.292 |
Set the Telegram API parse_mode parameter to HTML
and wrap the message in <pre></pre>
, but remember that telegram API does not support nested tags.
<pre>
| Tables | Are | Cool |
|----------|:-------------:|------:|
| col 1 is | left-aligned | $1600 |
| col 2 is | centered | $12 |
| col 3 is | right-aligned | $1 |
</pre>
Result in Telegram messanger:
Updated. How convert the tables in the picture
There will be a problem on the small screens of smartphones. So this method is not good. The only option is to convert the tables in the picture and so send :
- Or you can convert HTML to image using a headerless browser on your server.
- Or you can convert HTML to image using here external API services
- Or you can convert HTML to image using more difficult way by php GD
这篇关于如何使用 Telegram Bot API 发送表格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!