diff --git a/plugins/genshin/apps/mysNews.js b/plugins/genshin/apps/mysNews.js index 83e0641..298464c 100644 --- a/plugins/genshin/apps/mysNews.js +++ b/plugins/genshin/apps/mysNews.js @@ -12,10 +12,10 @@ export class mysNews extends plugin { name: '米游社公告', dsc: '#公告 #资讯 #活动', event: 'message', - priority: 700, + priority: 7000, rule: [ { - reg: '^#*(官方|星铁|原神|崩坏三|崩三|绝区零|崩坏二|崩二|崩坏学园二|未定|未定事件簿)?(公告|资讯|活动)[0-9]*$', + reg: '^#*(官方|星铁|原神|崩坏三|崩三|绝区零|崩坏二|崩二|崩坏学园二|未定|未定事件簿)?(公告|资讯|活动)(列表|[0-9])*$', fnc: 'news' }, { @@ -138,7 +138,7 @@ export class mysNews extends plugin { } gids() { - let msg = this.e.msg.replace(/[#公告资讯活动开启关闭推送]/g, ''); + let msg = this.e.msg.replace(/[#公告资讯活动开启关闭推送列表]/g, ''); switch (msg) { case '崩坏三': case '崩三': diff --git a/plugins/genshin/model/mysNews.js b/plugins/genshin/model/mysNews.js index be5f601..de351ca 100644 --- a/plugins/genshin/model/mysNews.js +++ b/plugins/genshin/model/mysNews.js @@ -25,7 +25,7 @@ export default class MysNews extends base { typeName = '活动' } - const res = await this.postData('getNewsList', { gids: gid, page_size: 20, type }) + const res = await this.postData('getNewsList', { gids: gid, page_size: this.e.msg.includes('列表') ? 5 : 20, type }) if (!res) return const data = res.data.list @@ -33,19 +33,36 @@ export default class MysNews extends base { return true } - const page = this.e.msg.replace(/#|#|官方|星铁|原神|崩坏三|崩三|绝区零|崩坏二|崩二|崩坏学园二|未定|未定事件簿|公告|资讯|活动/g, '').trim() || 1 - if (page > data.length) { - await this.e.reply('目前只查前20条最新的公告,请输入1-20之间的整数。') - return true + let param = {} + let game = this.game(gid) + if (this.e.msg.includes('列表')) { + this.model = 'mysNews-list' + data.forEach(element => { + element.post.created_at = new Date(element.post.created_at * 1000).toLocaleString() + }) + + param = { + ...this.screenData, + saveId: this.e.user_id, + data, + game, + typeName + } + + } else { + const page = this.e.msg.replace(/#|#|官方|星铁|原神|崩坏三|崩三|绝区零|崩坏二|崩二|崩坏学园二|未定|未定事件簿|公告|资讯|活动/g, '').trim() || 1 + if (page > data.length) { + await this.e.reply('目前只查前20条最新的公告,请输入1-20之间的整数。') + return true + } + + const postId = data[page - 1].post.post_id + + param = await this.newsDetail(postId, gid) } - const postId = data[page - 1].post.post_id - - const param = await this.newsDetail(postId, gid) - const img = await this.render(param) - let game = this.game() - return this.replyMsg(img, `${game}${typeName}:${param.data.post.subject}`) + return this.replyMsg(img, `${game}${typeName}:${param?.data?.post?.subject || `米游社${game}${typeName}列表`}`) } render(param) { diff --git a/plugins/genshin/resources/StarRail/html/mysNews-list/mysNews-list.css b/plugins/genshin/resources/StarRail/html/mysNews-list/mysNews-list.css new file mode 100644 index 0000000..fd5d1cf --- /dev/null +++ b/plugins/genshin/resources/StarRail/html/mysNews-list/mysNews-list.css @@ -0,0 +1,152 @@ +* { + margin: 0; + padding: 0; + box-sizing: border-box; + user-select: none; + font-family: sans-serif; +} +@font-face { + font-family: "tttgbnumber"; + src: url("../../font/tttgbnumber.ttf"); + font-weight: normal; + font-style: normal; +} +.container { + width: 700px; + padding: 20px 15px 10px 15px; + background-color: #f5f6fb; +} +.head_box { + border-radius: 15px 50px 50px 15px; + font-family: "tttgbnumber"; + padding: 35px 40px; + position: relative; + box-shadow: 0 5px 10px 0 rgb(0 0 0 / 15%); + background: url(./蒙德.png) #fff; + background-repeat: no-repeat; + background-size: 100% auto; +} +.head_box h1 { + font-size: 30px; + line-height: 36px; + margin: 0; + word-break: break-word; + word-wrap: break-word; + display: block; +} +body { + background: #f0f1f5; + line-height: 150%; + color: #333; + font-size: 16px; + width: 700px; + transform: scale(1.2); + transform-origin: 0 0; +} +.body_box { + padding: 20px 0px; +} +.data_box { + box-shadow: 0 5px 10px 0 rgb(0 0 0 / 15%); + border-radius: 15px; + background-color: #fff; + /* font-family: "tttgbnumber"; */ + padding: 10px 0px 10px 0px; + font-size: 16px; + word-wrap: break-word; + word-break: break-word; + height: auto; + overflow-x: hidden; +} +.newscard { + display: flex; + padding: 16px 20px 16px 20px; + border-bottom: 1px solid #ddd; +} +.newscard-left { + width: 40px; + -ms-flex-negative: 0; + flex-shrink: 0; + font-size: 26px; +} +.newscard-comment { + width: 40px; + height: 30px; + position: relative; + text-align: center; + display: table-cell; + display: table; + vertical-align: middle; +} +.newscard-info { + display: block; + margin-left: 14px; + padding: 8px 0 6px; + overflow: hidden; + -webkit-box-flex: 1; + -ms-flex-positive: 1; + flex-grow: 1; +} +.newscard-title { + font-size: 22px; + line-height: 24px; + font-weight: 600; + color: #333; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} +.newscard-content { + display: -webkit-box; + margin-top: 14px; + color: #999; + overflow: hidden; + -o-text-overflow: ellipsis; + text-overflow: ellipsis; + -webkit-line-clamp: 3; + -webkit-box-orient: vertical; + line-height: 30px; + max-height: 86px; + word-break: break-word; + word-wrap: break-word; + font-size: 18px; + outline: none; +} +.newscard-num { + display: table-cell; + text-align: center; + vertical-align: middle; + font-family: "tttgbnumber"; +} +.newscard-time { + font-size: 16px; + color: #999; + line-height: 1; + margin-top: 14px; + font-family: "tttgbnumber"; +} +.newscard-cover { + margin-top: 10px; + width: 242px; + height: 124px; + -ms-flex-negative: 0; + flex-shrink: 0; + margin-left: 14px; + overflow: hidden; +} +.newscard-img { + width: 100%; + height: 100%; + border-radius: 8px; + background-position: 50%; + background-repeat: no-repeat; + /* background-size: 60%; */ + background-color: #f6f6f6; + background-size: cover; +} +.logo { + font-size: 14px; + font-family: "tttgbnumber"; + text-align: center; + color: #7994a7; +} diff --git a/plugins/genshin/resources/StarRail/html/mysNews-list/mysNews-list.html b/plugins/genshin/resources/StarRail/html/mysNews-list/mysNews-list.html new file mode 100644 index 0000000..03473b2 --- /dev/null +++ b/plugins/genshin/resources/StarRail/html/mysNews-list/mysNews-list.html @@ -0,0 +1,51 @@ + + + + + + + + + + + +
+
+
+

米游社·{{game}}{{typeName}}列表

+
+
+
+ {{each data data iCount}} + {{if iCount == data.length - 1}} +
+ {{else}} +
+ {{/if}} +
+
+ {{iCount + 1}} +
+
+
+

{{data.post.subject}}

+
{{data.post.content}}
+
{{data.post.created_at}}
+
+
+
+
+
+
+ {{/each}} +
+
+ + +
+
+ + + + \ No newline at end of file diff --git a/plugins/genshin/resources/StarRail/html/mysNews-list/蒙德.png b/plugins/genshin/resources/StarRail/html/mysNews-list/蒙德.png new file mode 100644 index 0000000..3122307 Binary files /dev/null and b/plugins/genshin/resources/StarRail/html/mysNews-list/蒙德.png differ diff --git a/plugins/genshin/resources/html/mysNews-list/mysNews-list.css b/plugins/genshin/resources/html/mysNews-list/mysNews-list.css new file mode 100644 index 0000000..fd5d1cf --- /dev/null +++ b/plugins/genshin/resources/html/mysNews-list/mysNews-list.css @@ -0,0 +1,152 @@ +* { + margin: 0; + padding: 0; + box-sizing: border-box; + user-select: none; + font-family: sans-serif; +} +@font-face { + font-family: "tttgbnumber"; + src: url("../../font/tttgbnumber.ttf"); + font-weight: normal; + font-style: normal; +} +.container { + width: 700px; + padding: 20px 15px 10px 15px; + background-color: #f5f6fb; +} +.head_box { + border-radius: 15px 50px 50px 15px; + font-family: "tttgbnumber"; + padding: 35px 40px; + position: relative; + box-shadow: 0 5px 10px 0 rgb(0 0 0 / 15%); + background: url(./蒙德.png) #fff; + background-repeat: no-repeat; + background-size: 100% auto; +} +.head_box h1 { + font-size: 30px; + line-height: 36px; + margin: 0; + word-break: break-word; + word-wrap: break-word; + display: block; +} +body { + background: #f0f1f5; + line-height: 150%; + color: #333; + font-size: 16px; + width: 700px; + transform: scale(1.2); + transform-origin: 0 0; +} +.body_box { + padding: 20px 0px; +} +.data_box { + box-shadow: 0 5px 10px 0 rgb(0 0 0 / 15%); + border-radius: 15px; + background-color: #fff; + /* font-family: "tttgbnumber"; */ + padding: 10px 0px 10px 0px; + font-size: 16px; + word-wrap: break-word; + word-break: break-word; + height: auto; + overflow-x: hidden; +} +.newscard { + display: flex; + padding: 16px 20px 16px 20px; + border-bottom: 1px solid #ddd; +} +.newscard-left { + width: 40px; + -ms-flex-negative: 0; + flex-shrink: 0; + font-size: 26px; +} +.newscard-comment { + width: 40px; + height: 30px; + position: relative; + text-align: center; + display: table-cell; + display: table; + vertical-align: middle; +} +.newscard-info { + display: block; + margin-left: 14px; + padding: 8px 0 6px; + overflow: hidden; + -webkit-box-flex: 1; + -ms-flex-positive: 1; + flex-grow: 1; +} +.newscard-title { + font-size: 22px; + line-height: 24px; + font-weight: 600; + color: #333; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} +.newscard-content { + display: -webkit-box; + margin-top: 14px; + color: #999; + overflow: hidden; + -o-text-overflow: ellipsis; + text-overflow: ellipsis; + -webkit-line-clamp: 3; + -webkit-box-orient: vertical; + line-height: 30px; + max-height: 86px; + word-break: break-word; + word-wrap: break-word; + font-size: 18px; + outline: none; +} +.newscard-num { + display: table-cell; + text-align: center; + vertical-align: middle; + font-family: "tttgbnumber"; +} +.newscard-time { + font-size: 16px; + color: #999; + line-height: 1; + margin-top: 14px; + font-family: "tttgbnumber"; +} +.newscard-cover { + margin-top: 10px; + width: 242px; + height: 124px; + -ms-flex-negative: 0; + flex-shrink: 0; + margin-left: 14px; + overflow: hidden; +} +.newscard-img { + width: 100%; + height: 100%; + border-radius: 8px; + background-position: 50%; + background-repeat: no-repeat; + /* background-size: 60%; */ + background-color: #f6f6f6; + background-size: cover; +} +.logo { + font-size: 14px; + font-family: "tttgbnumber"; + text-align: center; + color: #7994a7; +} diff --git a/plugins/genshin/resources/html/mysNews-list/mysNews-list.html b/plugins/genshin/resources/html/mysNews-list/mysNews-list.html new file mode 100644 index 0000000..03473b2 --- /dev/null +++ b/plugins/genshin/resources/html/mysNews-list/mysNews-list.html @@ -0,0 +1,51 @@ + + + + + + + + + + + +
+
+
+

米游社·{{game}}{{typeName}}列表

+
+
+
+ {{each data data iCount}} + {{if iCount == data.length - 1}} +
+ {{else}} +
+ {{/if}} +
+
+ {{iCount + 1}} +
+
+
+

{{data.post.subject}}

+
{{data.post.content}}
+
{{data.post.created_at}}
+
+
+
+
+
+
+ {{/each}} +
+
+ + +
+
+ + + + \ No newline at end of file diff --git a/plugins/genshin/resources/html/mysNews-list/蒙德.png b/plugins/genshin/resources/html/mysNews-list/蒙德.png new file mode 100644 index 0000000..3122307 Binary files /dev/null and b/plugins/genshin/resources/html/mysNews-list/蒙德.png differ