如何使用 Telegram Bot API 发送表格? [英] How do I send Tables with Telegram Bot API?

查看:145
本文介绍了如何使用 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 |

在电报信使中的结果:

已更新.如何转换图中的表格

智能手机的小屏幕会出现问题.所以这个方法不好.唯一的选择是转换图片中的表格,然后发送:

  1. 或者,您可以使用服务器上的无标题浏览器将 HTML 转换为图像.
  2. 或者您可以使用此处的外部 API 服务
  3. 或者您可以通过 php GD

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 :

  1. Or you can convert HTML to image using a headerless browser on your server.
  2. Or you can convert HTML to image using here external API services
  3. Or you can convert HTML to image using more difficult way by php GD

这篇关于如何使用 Telegram Bot API 发送表格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆