MCPcopy
hub / github.com/chavyleung/scripts / msg

Method msg

Env.js:645–810  ·  view source on GitHub ↗

* 系统通知 * * > 通知参数: 同时支持 QuanX 和 Loon 两种格式, EnvJs根据运行环境自动转换, Surge 环境不支持多媒体通知 * * 示例: * $.msg(title, subt, desc, 'twitter://') * $.msg(title, subt, desc, { 'open-url': 'twitter://', 'media-url': 'https://github.githubassets.com/images/modules/open_graph/github-mark.png'

(title = name, subt = '', desc = '', opts = {})

Source from the content-addressed store, hash-verified

643 *
644 */
645 msg(title = name, subt = '', desc = '', opts = {}) {
646 const toEnvOpts = (rawopts) => {
647 const { $open, $copy, $media, $mediaMime } = rawopts
648 switch (typeof rawopts) {
649 case undefined:
650 return rawopts
651 case 'string':
652 switch (this.getEnv()) {
653 case 'Surge':
654 case 'Stash':
655 case 'Egern':
656 default:
657 return { url: rawopts }
658 case 'Loon':
659 case 'Shadowrocket':
660 return rawopts
661 case 'Quantumult X':
662 return { 'open-url': rawopts }
663 case 'Node.js':
664 return undefined
665 }
666 case 'object':
667 switch (this.getEnv()) {
668 case 'Surge':
669 case 'Stash':
670 case 'Shadowrocket':
671 case 'Egern':
672 default: {
673 const options = {}
674
675 // 打开URL
676 let openUrl =
677 rawopts.openUrl || rawopts.url || rawopts['open-url'] || $open
678 if (openUrl)
679 Object.assign(options, { action: 'open-url', url: openUrl })
680
681 // 粘贴板
682 let copy =
683 rawopts['update-pasteboard'] ||
684 rawopts.updatePasteboard ||
685 $copy
686 if (copy) {
687 Object.assign(options, { action: 'clipboard', text: copy })
688 }
689
690 // 图片通知
691 let mediaUrl =
692 rawopts.mediaUrl || rawopts['media-url'] || $media
693 if (mediaUrl) {
694 let media = undefined
695 let mime = undefined
696 // http 开头的网络地址
697 if (mediaUrl.startsWith('http')) {
698 //不做任何操作
699 }
700 // 带标识的 Base64 字符串
701 // data:image/png;base64,iVBORw0KGgo...
702 else if (mediaUrl.startsWith('data:')) {

Callers 15

getcookieFunction · 0.45
signFunction · 0.45
signFunction · 0.45
signappFunction · 0.45
showmsgFunction · 0.45
GetCookieFunction · 0.45
DailyCheckinFunction · 0.45
NoviceCheckinFunction · 0.45
VideoCoinFunction · 0.45
LuckyTurnFunction · 0.45

Calls 3

getEnvMethod · 0.45
postMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected