Merge branch 'master' of github.com:yoimiya-kokomi/Miao-Yunzai

This commit is contained in:
Kokomi 2023-06-07 05:39:36 +08:00
commit 4cd5558f8d
4 changed files with 304 additions and 294 deletions

View File

@ -64,28 +64,28 @@ function mkdirs (dirname) {
* @param e icqq消息e
* @param msg 消息数组
* @param dec 转发描述
* @param msgsscr 转发信息是否为Bot
*/
async function makeForwardMsg (e, msg = [], dec = '') {
async function makeForwardMsg (e, msg = [], dec = '', msgsscr = false) {
// 是频道直接返回 join
if (e.isGuild) return msg.join("\n")
let nickname = e.bot.nickname
let name = msgsscr ? this.e.sender.card || this.e.user_id : Bot.nickname
let id = msgsscr ? this.e.user_id : Bot.uin
if (e.isGroup) {
let info = await e.bot.getGroupMemberInfo(e.group_id, e.bot.uin)
nickname = info.card || info.nickname
}
let userInfo = {
user_id: e.bot.uin,
nickname
user_id: id
nickname: name
}
let forwardMsg = []
msg.forEach(v => {
msg.forEach(msg => {
forwardMsg.push({
...userInfo,
message: v
message: msg
})
})

View File

@ -1,6 +1,6 @@
import plugin from '../../../lib/plugins/plugin.js'
import MysNews from '../model/mysNews.js'
import srNews from '../model/srmysNews.js'
import MysSrNews from '../model/mysSrNews.js'
import fs from 'node:fs'
import lodash from 'lodash'
import gsCfg from '../model/gsCfg.js'
@ -25,16 +25,16 @@ export class mysNews extends plugin {
},
{
reg: '^(#*铁道(公告|资讯|活动)|#*星铁(公告|资讯|活动)|#星穹公告|#星穹资讯|#星穹活动)[0-9]*$',
fnc: 'srnews'
fnc: 'srNews'
},
{
reg: '^#*(开启|关闭)(铁道|星铁|星穹)(公告|资讯)推送$',
fnc: 'srsetPush'
fnc: 'srSetPush'
},
{
reg: '^#推送(铁道|星铁|星穹)(公告|资讯)$',
permission: 'master',
fnc: 'srmysNewsTask'
fnc: 'srMysNewsTask'
},
{
reg: '(.*)(bbs.mihoyo.com|miyoushe.com)/ys(.*)/article(.*)',
@ -70,7 +70,7 @@ export class mysNews extends plugin {
{
cron: gsCfg.getConfig('mys', 'pushNews').pushTime,
name: '崩坏星穹铁道公告推送任务',
fnc: () => this.srmysNewsTask(),
fnc: () => this.srMysNewsTask(),
log: false
}
]
@ -88,8 +88,8 @@ export class mysNews extends plugin {
await this.reply(data)
}
async srnews () {
let data = await new srNews(this.e).getNews()
async srNews () {
let data = await new MysSrNews(this.e).getNews()
if (!data) return
await this.reply(data)
}
@ -99,8 +99,8 @@ export class mysNews extends plugin {
await mysNews.mysNewsTask()
}
async srmysNewsTask () {
let mysNews = new srNews(this.e)
async srMysNewsTask () {
let mysNews = new MysSrNews(this.e)
await mysNews.mysNewsTask()
}
@ -123,7 +123,7 @@ export class mysNews extends plugin {
await this.reply(data)
}
async srsetPush () {
async srSetPush () {
if (!this.e.isGroup) {
await this.reply('推送请在群聊中设置')
return

View File

@ -5,10 +5,9 @@ import puppeteer from '../../../lib/puppeteer/puppeteer.js'
import common from '../../../lib/common/common.js'
import gsCfg from '../model/gsCfg.js'
const _path = process.cwd()
let emoticon
export default class MysNews extends base {
export default class MysSrNews extends base {
constructor (e) {
super(e)
this.model = 'mysNews'
@ -245,6 +244,15 @@ export default class MysNews extends base {
let sended = await redis.get(`${this.key}${groupId}:${postId}`)
if (sended) return
// TODO: 暂时处理,后续待更好的解决方案 定时任务无法获取e.bot
this.e.bot = Bot
// 判断是否存在群关系
if (!this.e.bot.gl.get(Number(groupId))) {
logger.mark(`[崩坏星穹铁道${typeName}推送] 群${groupId}未关联`)
return
}
if (!this[postId]) {
const param = await this.newsDetail(postId)
@ -269,6 +277,8 @@ export default class MysNews extends base {
}
redis.set(`${this.key}${groupId}:${postId}`, '1', { EX: 3600 * 10 })
// 随机延迟10-90秒
await common.sleep(lodash.random(10, 90) * 1000)
await this.e.group.sendMsg(tmp)
}
}

View File

@ -108,7 +108,7 @@ export class update extends plugin {
}
if (plugin) {
cm = `git -C ./plugins/${plugin}/ pull --no-rebase`
cm = `git -C ./plugins/${plugin}/ fetch --all && git -C ./plugins/${plugin}/ reset --hard && git -C ./plugins/${plugin}/ pull`
}
this.oldCommitId = await this.getcommitId(plugin)