为了账号安全,请及时绑定邮箱和手机立即绑定

您如何使用 laravel slack 通知 api 在 (@) 某人处于 slack 状态?

您如何使用 laravel slack 通知 api 在 (@) 某人处于 slack 状态?

PHP
茅侃侃 2022-07-16 16:21:12
我有一个功能正常的通知系统,可以发布到我们公司 Slack 的频道。但是,遇到的一切都只是文本。linkNames假设在您的内容中查找/链接用户名。我看到它被设置为“1”,但当它出现在频道中时没有影响。 namespace App\Notifications;use Illuminate\Bus\Queueable;use Illuminate\Contracts\Queue\ShouldQueue;use Illuminate\Notifications\Notification;use Illuminate\Notifications\Messages\SlackMessage;class Dd extends Notification{use Queueable;/** * Create a new notification instance. * * @return void */public function __construct(){    //}/** * Get the notification's delivery channels. * * @param  mixed  $notifiable * @return array */public function via($notifiable){    return ['slack'];}/** * Get the array representation of the notification. * * @param  mixed  $notifiable * @return array */public function toArray($notifiable){    return [        //    ];}/** * Get the Slack representation of the notification. * * @param  mixed  $notifiable * @return SlackMessage */public function toSlack($slackComment){       $slackMessage = new SlackMessage();    $slackMessage->linkNames();    $slackMessage->from('Christopher');    $slackMessage->to($slackComment->channel);    $slackMessage->content("Harded coded for example @christopher <- this doesn't get linked to the user in slack but should");     $slackMessage->info();    //dd($slackMessage); // this shows that the linkedNames attribute has been set to "1"    return $slackMessage;             }}这是一个已知问题,版本不匹配,还是我遗漏了什么?
查看完整描述

1 回答

?
料青山看我应如是

TA贡献1772条经验 获得超8个赞

https://api.slack.com/reference/surfaces/formatting#mentioning-users

要在应用发布的文本中提及用户,您需要按以下语法提供他们的用户 ID:

Hey <@U024BE7LH>, thanks for submitting your report.


查看完整回答
反对 回复 2022-07-16
  • 1 回答
  • 0 关注
  • 115 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号