morny-book/inline/share-twitter.md

81 lines
7.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# Twitter 分享链接格式化
这个内联查询可以使输入的 twitter tweet 分享链接重新格式化为合法的 [vxtwitter][vxtwitter-home] 分享链接,
同时也会去除 twitter 分享链接会附带的跟踪参数。
被输出的 vxtwitter 分享链接即能够基于 telegram 自带的链接预览工具,达到分享 tweet 内容的效果。
## 输入
支持以下各种格式的 twitter 分享链接:
- 标准的 tweet 链接 <code><font color="mediumseagreen">https://</font><font color="orange">twitter.com</font>/<font color="cornflowerblue">Twitter/status/1551967807428071431</font></code>
- 附带了跟踪参数的链接,例如但不限于使用 twitter 分享按钮时的默认链接 <code><font color="mediumseagreen">https://</font><font color="orange">twitter.com</font>/<font color="cornflowerblue">Twitter/status/1551967807428071431</font><font color="tan">?s=20&t=IeYlNFDoXYi9WNk8BkJ3-A</font></code>,相比于标准链接,其中 <code><font color="tan">?s=20&t=...</font></code> 是跟踪参数
- 简短的 <code><font color="orange">twitter.com</font>/<font color="cornflowerblue">Twitter/status/1551967807428071431</font></code>
- 也就是链接当中的 <code><font color="mediumseagreen">https://</font></code> 可以省略(如这个例子)
- 也可以是 <code><font color="mediumseagreen">http://</font></code>
- 以 vxtwitter/[fxtwitter][fxtwitter-home] 为域名的 <code><font color="mediumseagreen">https://</font><font color="lightsalmon">c.</font><font color="orangered">vx</font><font color="orange">twitter.com</font>/<font color="cornflowerblue">Twitter/status/1551967807428071431</font></code> 链接
- 域名 <code><font color="lightsalmon">c.</font><font color="orangered">vx</font><font color="orange">twitter.com</font></code> 或是 <code><font color="orangered">vx</font><font color="orange">twitter.com</font></code> 或是 <code><font color="orangered">fx</font><font color="orange">twitter.com</font></code> 都受到支援
- 域名 <code><font color="lightsalmon">www.</font><font color="orange">twitter.com</font></code> 也是受到支援的
- *但域名 <code><font color="lightsalmon">www.</font><font color="orangered">vx</font><font color="orange">twitter.com</font></code> (以及带有 <code><font color="lightsalmon">www.</font></code><code><font color="orangered">fx</font><font color="orange">twitter</font></code> 都) 并不被支援*
- 带有 <code><font color="mediumorchid">/photo</font></code> 参数的链接也受到支援,例如 <code><font color="mediumseagreen">https://</font><font color="orangered">fx</font><font color="orange">twitter.com</font>/<font color="cornflowerblue">Do_While02/status/1579516695320072192</font><font color="mediumorchid">/photo/2/</font></code><small>其实是来源于 [fxtwitter][fxtwitter-home]的,但这个分享工具所基于的 vxtwitter 其实并不支持 photo 参数和单图片分享</small>
> (感觉写出来的就是一大坨好丑)
<!-- [引自 世界计划小站 (日向 加藤)]
#同人 https://fxtwitter.com/Do_While02/status/1579516695320072192/photo/2/ -->
## 输出
将会被格式化为
<code><font color="mediumseagreen">https://</font><font color="orangered">vx</font><font color="orange">twitter.com</font>/<font color="cornflowerblue">Twitter/status/1551967807428071431</font></code> - 选项 **[tweet] Share as VxTwitter**
<code><font color="mediumseagreen">https://</font><font color="lightsalmon">c.</font><font color="orangered">vx</font><font color="orange">twitter.com</font>/<font color="cornflowerblue">Twitter/status/1551967807428071431</font></code> - 选项 **[tweet] Share as VxTwitter(combination)**
> 关于 combination method (官方说明摘抄) :
> ***combination_method** - using c.vxtwitter as the url causes vxTwitter to combine all images in the post into one. *
格式化输出将只会保留 <code><font color="cornflowerblue">Twitter/status/1551967807428071431</font></code> 部分,根据选项组合域名
<code><font color="mediumseagreen">https://</font><font color="orangered">vx</font><font color="orange">twitter.com</font>/</code> 或是
<code><font color="mediumseagreen">https://</font><font color="lightsalmon">c.</font><font color="orangered">vx</font><font color="orange">twitter.com</font>/</code>。
输入中的 <code><font color="tan">?s=20&t=...</font></code> 等跟踪参数(目前来说是一切参数,可以看作是
<code><font color="tan">?</font></code> 之后的一切)都会被丢弃掉。
目前,<code><font color="mediumorchid">/photo</font></code> 参数尽管会在输入中被解析,但并不会被组合进结果当中,即它也是会被丢弃的参数
<small>同时 vxtwitter 也本来就并不支援这个参数</small>
> 尽管目前,这个分享工具使用的是 vxtwitter 服务,搭配 telegram 自身的链接预览分享 tweet 内容,但 vxtwitter 所提供的 tweet 正文在遇到长文本时会截断长文本twitter 自身的链接预览都不会,尽管 twitter 自身的链接预览经常会获取不到预览内容)导致分享出来之后只剩下了文本摘要和一个 `...`。出于这个问题,我们也正在设计一个更好用一点的,不依赖于 vxtwitter 的分享方式。
<!-- ## egs:
input: <code><font color="mediumseagreen">https://</font><font color="orange">twitter.com</font>/<font color="cornflowerblue">Twitter/status/1551967807428071431</font><font color="tan">?s=20&t=IeYlNFDoXYi9WNk8BkJ3-A</font></code>
[tweet] Share as VxTwitter : <code><font color="mediumseagreen">https://</font><font color="orangered">vx</font><font color="orange">twitter.com</font>/<font color="cornflowerblue">Twitter/status/1551967807428071431</font></code>
[tweet] Share as VxTwitter(combination) : <code><font color="mediumseagreen">https://</font><font color="lightsalmon">c.</font><font color="orangered">vx</font><font color="orange">twitter.com</font>/<font color="cornflowerblue">Twitter/status/1551967807428071431</font></code>
[vxtwitter-home]: https://github.com/dylanpdx/BetterTwitFix
[fxtwitter-home]: https://github.com/FixTweet/FixTweet -->
## technic infomation
链接解析所使用的正则表达式 : <code class="regex">^(?:https?://)?((?:(?:c.)?vx|fx|www.)?twitter.com)/((\w+)/status/(\d+)(?:/photo/(\d+))?)/?(\?[\w&=-]+)?$</code>
<table>
<caption>vxtwitter version</caption>
<thead><tr><th colspan=2>inline query node info</th></tr></thead>
<tr><td align=right><b>title</b></td><td>[tweet] Share as VxTwitter</td></tr>
<tr><td align=right><b>id</b></td><td><code>[morny/share/twitter/vxtwi]</code></td></tr>
<tr><td align=right><b>cache</b></td><td><u>default<small><code>300</code></small></u></td></tr>
<tr><td align=right><b>is_personal</b></td><td><u>default<small><code>false</code></small></u></td></tr>
</table>
<table>
<caption>c.vxtwitter version</caption>
<thead><tr><th colspan=2>inline query node info</th></tr></thead>
<tr><td align=right><b>title</b></td><td>[tweet] Share as VxTwitter (combination)</td></tr>
<tr><td align=right><b>id</b></td><td><code>[morny/share/twitter/vxtwi_combine]</code></td></tr>
<tr><td align=right><b>cache</b></td><td><u>default<small><code>300</code></small></u></td></tr>
<tr><td align=right><b>is_personal</b></td><td><u>default<small><code>false</code></small></u></td></tr>
</table>