-
Notifications
You must be signed in to change notification settings - Fork 359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(vercel): Telegram notification support #83
Conversation
喜欢 |
Markdown 的话可以把这里修改一下,改成 https://github.com/lizheming/waline/blob/master/packages/server/src/controller/comment.js#L230 |
其实作为代码小白,并不是很懂,前面那些都是一点点探索出来的 😂 话说,这样修改以后通知这边 Telegram 要引用哪个变量作为 Markdown 的评论呢, |
嗯,用 |
telegramNotify = await this.telegram({contentTG}, comment, parent); | ||
} | ||
|
||
if(!isAuthorComment && !isReplyAuthor && (think.isEmpty(wechatNotify) || think.isEmpty(telegramNotify)) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
有个问题,为啥我这里已经设置了,但是刚才我部署后,还是会出现 Telegram 和邮件都收到通知的情况?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
你收到的是新评论通知,还是子评论回复的邮件通知?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
最新评论通知,就是非博主的邮箱地址用户评论会同时收到通知
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
那应该是你这条件写的有问题了,应该是 &&
不是 ||
,微信和 Telegram 通知都没有设置的时候才需要,现在你是其一不设置就会走邮件通知。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
啊,好像是弄混了 😂😂 你改一下吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嗯,等下个 feat 我带上去吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
另外之前提到那个 self.rawComment
没搞定,你有空可以再看看,不过目前也不影响 Telegram 通知
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我已经改了
有问题,用了你修改后的版本,提交评论会弹窗报错 |
@waline/vercel@0.15.1 发了 |
docker 这边似乎没更新? npm 那边有看到更新的~ |
Docker 要等 CI 自动构建,等半个小时再看看吧 |
似乎你 GitHub 上 @waline/vercel 的版本号也没改到 @0.15.1 呀 |
@lei2rock https://github.com/easychen/telechan 可以看看这个喔,用这个 API ,CloudBase 版本也可以用 Telegram 通知了。 |
实现了 Telegram 机器人的评论通知功能,文档那边也相应修改了。
不过实现的过程个人感觉十分简陋。评论通知这里读取的变量
{{self.comment | safe}}
已经被渲染成 HTML 了,如果直接发送该段内容,Telegram 有可能不会接受而报错,因为其只支持部分 HTML 标签。Telegram 机器人是可以接受 MarkDown 内容 的,所以我这里干脆把发送消息的内容写成了 MarkDown,然而因为变量
{{self.comment | safe}}
依然是 HTML,我这里只能做了一点简单的处理:把<p>
、换行符、表情这几个剔除,然后让评论内容变成代码格式。这样发送消息时候就不会报错,消息内容也会简洁一些。当然最好的方式是,直接把用户在评论框中的 MarkDown 评论传递给 Telegram 机器人,这样就不会出现上面这样评论经过了 MarkDown-HTML-MarkDown 几个阶段转换的过程了。技术有限,我是搞不定了😂😂 如果可以的话可以进一步改进~
评论通知效果如下: