Code Monkey home page Code Monkey logo

Comments (27)

qwqcode avatar qwqcode commented on June 23, 2024 1

模版功能已在 v2.1.8 正式版中添加支持,正在编译发布

from artalkgo.

qwqcode avatar qwqcode commented on June 23, 2024 1

模版分为两种类型,notify_tplmail_tpl

from artalkgo.

qwqcode avatar qwqcode commented on June 23, 2024 1

默认模板:

@{{reply_nick}}:

{{reply_content}}

{{link_to_reply}}

可用参数和邮件模板是一样的,可参考 https://artalk.js.org/guide/backend/email.html#%E9%82%AE%E4%BB%B6%E6%A8%A1%E6%9D%BF

from artalkgo.

leirock avatar leirock commented on June 23, 2024 1

Telegram 的 API 有毒,如果不转义的话,单独一个 _[]( 符号也会导致报错,总之非常容易报错 🥲

image

go-telegram-bot-api/telegram-bot-api#174

维持现状吧,全部转义是最安全的,这样不管是 markdown 还是 html 渲染都不会出错。

from artalkgo.

qwqcode avatar qwqcode commented on June 23, 2024

为了解决重复通知问题,我修改了配置文件:924a080

# 管理员多元推送
admin_notify:
# 邮件通知管理员
email:
enabled: true
mail_subject: '[{{site_name}}] 您的文章 "{{page_title}}" 有新回复'
# Telegram
telegram:
enabled: false
api_token: ""
receivers:
- 7777777
# Bark
bark:
enabled: false
server: "http://day.app/xxxxxxx/"

from artalkgo.

qwqcode avatar qwqcode commented on June 23, 2024

通知模版等待做进一步工作,模版引擎需要从强耦合的邮件发送功能中独立拆分出来

from artalkgo.

leirock avatar leirock commented on June 23, 2024

重复通知问题似乎没有解决,使用 artalk/artalk-go:2.1.8-alpha.2 版本,设置通知如下

  email:
-   mail_subject_to_admin: '[{{site_name}}] 您的文章 "{{page_title}}" 有新回复'
  admin_notify:
+   email:
+     enabled: false
+     mail_subject: '[{{site_name}}] 您的文章 "{{page_title}}" 有新回复'
    telegram:
      enabled: true
      api_token: "111111111"
    receivers:
      - 1111111

依然会给管理员发送邮件通知,而且邮件标题也变成了无标题。

from artalkgo.

qwqcode avatar qwqcode commented on June 23, 2024

新版配置可参考此处:https://github.com/ArtalkJS/ArtalkGo/blob/master/artalk-go.example.yml#L134-L162

from artalkgo.

leirock avatar leirock commented on June 23, 2024

新版配置可参考此处:https://github.com/ArtalkJS/ArtalkGo/blob/master/artalk-go.example.yml#L134-L162

admin_notify.notify_tpl 这里的模板是不是专门给管理员发送通知邮件的模板?与前面给普通用户发送通知的邮件模版 email.mail_tpl 是不同的吧?

from artalkgo.

qwqcode avatar qwqcode commented on June 23, 2024

admin_notify.notify_tpl 仅是多元通知的模版,管理员邮件发送模版遵循 email.mail_tpl

from artalkgo.

leirock avatar leirock commented on June 23, 2024

也就是说 admin_notify.notify_tpl 是除了邮件通知之外的通知模板,是这个意思吧?

from artalkgo.

qwqcode avatar qwqcode commented on June 23, 2024

之后可以做一个,通过配置 admin_notify.email.mail_tpl 指定管理员邮件使用和普通用户不同的邮件模版。

from artalkgo.

qwqcode avatar qwqcode commented on June 23, 2024

是的,admin_notify.notify_tpl 是除了邮件通知之外的通知模板

from artalkgo.

leirock avatar leirock commented on June 23, 2024

之后可以做一个,通过配置 admin_notify.email.mail_tpl 指定管理员邮件使用和普通用户不同的邮件模版。

嗯,确实。管理员的邮件通知模板是可以和给普通用户的邮件通知的模板不同的,不过我个人需求不是很强烈,😂

from artalkgo.

leirock avatar leirock commented on June 23, 2024

是的,admin_notify.notify_tpl 是除了邮件通知之外的通知模板

这个模板有像邮件模板那样的参考示例文件吗?

from artalkgo.

qwqcode avatar qwqcode commented on June 23, 2024

image

{{link_to_reply}} 现在支持已读标记了,但是链接变得比较长,就比较丑,以后我把 atk_notify_key 参数值改短一些

from artalkgo.

leirock avatar leirock commented on June 23, 2024

如果是 Telegram 的话,设置成文字的超链接应该就不影响了

from artalkgo.

leirock avatar leirock commented on June 23, 2024

对了,这个模板也是 html 文件吗?

from artalkgo.

qwqcode avatar qwqcode commented on June 23, 2024

TG 好像有自己的语法,并且不能带 < 尖括号,之前测试报了个错,然后我开了 HTML 转义

模板文件类型任意文件都可以,只要是纯文本格式就 OK

from artalkgo.

leirock avatar leirock commented on June 23, 2024

TG 的语法限制很多的,所以最好是直接把评论的内容用代码的形式包裹后输出,要不然如果评论内容里有什么不支持的语法,很容易报错。

from artalkgo.

qwqcode avatar qwqcode commented on June 23, 2024

notify_tpl 的 {{reply_content}} 我做过处理,表情图片标签 <img src 会被转为:[表情名]

然后 Artalk 前端存入数据库的数据,用户输入 Markdown 语法会直接存入数据库,不会被编译。

notify_tpl 中的 {{reply_content}} 是没编译的 Markdown 原始内容,但 mail_tpl 的是后端编译后的。

用户输入的 HTML 标签在 notify_tpl 中会被转义,使用 html.EscapeString 转义

from artalkgo.

leirock avatar leirock commented on June 23, 2024

那估计问题不大

from artalkgo.

leirock avatar leirock commented on June 23, 2024

image

{{link_to_reply}} 现在支持已读标记了,但是链接变得比较长,就比较丑,以后我把 atk_notify_key 参数值改短一些

我自己在 TG 模板里自己用提供的参数拼接里一下,这样就去掉了 notify_key 那一串

{{site_url}}{{comment.page.key}}?atk_comment={{comment.id}}

from artalkgo.

qwqcode avatar qwqcode commented on June 23, 2024

https://core.telegram.org/bots/api#formatting-options

可以试试用:

[回复]({{link_to_reply}})

from artalkgo.

leirock avatar leirock commented on June 23, 2024

不太行,好像你对通知的内容都做了转义?无论是 markdown 还是 html 语法都无法渲染出来

from artalkgo.

leirock avatar leirock commented on June 23, 2024

转义的好处是不会因为不支持的语法而出现发送错误,问题就是无法渲染格式 😂

from artalkgo.

qwqcode avatar qwqcode commented on June 23, 2024

Telegram 的 API 有毒,如果不转义的话,单独一个 _[]( 符号也会导致报错,总之非常容易报错 🥲

image

go-telegram-bot-api/telegram-bot-api#174

from artalkgo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.