Skip to content

Commit 049fdef

Browse files
committed
Fix broken banner images
1 parent 2e091f5 commit 049fdef

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

src/commands/misc/banners.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import config from "../../data/config.json"
44
import client from "../../main"
55
import Command from "../../utils/Command"
66
import { CommandSource, SendMessage, StoredNews } from "../../utils/Types"
7-
import { Colors, findFuzzy, findFuzzyBestCandidates, parseNewsContent, sendMessage, simplePaginator } from "../../utils/Utils"
7+
import { Colors, findFuzzy, findFuzzyBestCandidates, getLink, parseNewsContent, sendMessage, simplePaginator } from "../../utils/Utils"
88

99

1010
const Logger = log4js.getLogger("main")
@@ -23,31 +23,31 @@ let eventWishes: Wish[] = [
2323
{
2424
title: "Event Wish \"Ballad in Goblets\" - Boosted Drop Rate for \"Windborne Bard\" Venti (Anemo)!",
2525
roughDate: 1601244000,
26-
img: "https://static.wikia.nocookie.net/gensin-impact/images/e/e9/Wish_Ballad_in_Goblets_2020-09-28.jpg/revision/latest?cb=20201006234432",
26+
img: "img/banners/1.0/char1.png",
2727
duration: "2020/09/28 12:00:00 – 2020/10/18 12:00:00",
2828
main: ["Venti"],
2929
other: ["Barbara", "Fischl", "Xiangling"]
3030
},
3131
{
3232
title: "Event Wish \"Epitome Invocation\" - Boosted Drop Rate for Aquila Favonia (Sword) and Amos' Bow (Bow)!",
3333
roughDate: 1601244000,
34-
img: "https://static.wikia.nocookie.net/gensin-impact/images/3/3d/Wish_Epitome_Invocation_2020-09-28.jpg/revision/latest?cb=20200929014948",
34+
img: "img/banners/1.0/weapon1.png",
3535
duration: "2020/09/28 12:00:00 – 2020/10/18 12:00:00",
3636
main: ["Aquila Favonia", "Amos' Bow"],
3737
other: ["The Flute", "The Bell", "The Widsith", "The Stringless", "Favonius Lance" ]
3838
},
3939
{
4040
title: "Event Wish \"Sparkling Steps\" - Boosted Drop Rate for \"Fleeing Sunlight\" Klee (Pyro)!",
4141
roughDate: 1603209600,
42-
img: "https://static.wikia.nocookie.net/gensin-impact/images/0/0c/Wish_Sparkling_Steps_2020-10-20.jpg/revision/latest?cb=20201018122142",
42+
img: "img/banners/1.0/char2.png",
4343
duration: "2020/10/20 18:00:00 – 2020/11/10 14:59:59",
4444
main: ["Klee"],
4545
other: ["Xingqiu", "Noelle", "Sucrose"]
4646
},
4747
{
4848
title: "Event Wish \"Epitome Invocation\" - Boosted Drop Rate for Lost Prayer to the Sacred Winds (Catalyst) and Wolf's Gravestone (Claymore)!",
4949
roughDate: 1603209600,
50-
img: "https://static.wikia.nocookie.net/gensin-impact/images/b/be/Wish_Epitome_Invocation_2020-10-20.jpg/revision/latest?cb=20201018052455",
50+
img: "img/banners/1.0/weapon2.png",
5151
duration: "2020/10/20 18:00:00 – 2020/11/10 14:59:59",
5252
main: ["Lost Prayer to the Sacred Winds", "Wolf's Gravestone"],
5353
other: ["Sacrificial Sword", "Sacrificial Bow", "Sacrificial Greatsword", "Sacrificial Fragments", "Dragon's Bane"]
@@ -71,15 +71,15 @@ let eventWishes: Wish[] = [
7171
{
7272
title: "Event Wish \"Gentry of Hermitage\" - Boosted Drop Rate for Zhongli!",
7373
roughDate: 1606842000,
74-
img: "https://static.wikia.nocookie.net/gensin-impact/images/4/41/Wish_Gentry_of_Hermitage_2020-12-01.png/revision/latest?cb=20201129051143",
74+
img: "img/banners/1.1/char2.png",
7575
duration: "2020-12-01 18:00:00 – 2020-12-22 14:59:59",
7676
main: ["Zhongli"],
7777
other: ["Xinyan", "Razor", "Chongyun"]
7878
},
7979
{
8080
title: "Event Wish \"Epitome Invocation\" - Boosted Drop Rates for Vortex Vanquisher (Polearm) and The Unforged (Claymore)!",
8181
roughDate: 1606842000,
82-
img: "https://static.wikia.nocookie.net/gensin-impact/images/a/a2/Wish_Epitome_Invocation_2020-12-01.jpg/revision/latest?cb=20201129051133",
82+
img: "img/banners/1.1/weapon2.png",
8383
duration: "2020-12-01 18:00:00 – 2020-12-22 14:59:59",
8484
main: ["Vortex Vanquisher", "The Unforged"],
8585
other: ["Lion's Roar", "The Bell", "Favonius Codex", "Favonius Warbow", "Dragon's Bane"]
@@ -119,15 +119,15 @@ let eventWishes: Wish[] = [
119119
{
120120
title: "Event Wish \"Invitation to Mundane Life\" - Boosted Drop Rate for Xiao!",
121121
roughDate: 1612342140,
122-
img: "https://static.wikia.nocookie.net/gensin-impact/images/3/36/Wish_Invitation_to_Mundane_Life_2021-02-03.jpg/revision/latest?cb=20210201040314",
122+
img: "img/banners/1.3/char1.png",
123123
duration: "After Version 1.3 update – 2021/02/17 15:59:59",
124124
main: ["Xiao"],
125125
other: ["Diona", "Beidou", "Xinyan"]
126126
},
127127
{
128128
title: "Event Wish \"Epitome Invocation\" - Boosted Drop Rates for Primordial Jade Cutter (Sword) and Primordial Jade Winged-Spear (Polearm)!",
129129
roughDate: 1612342140,
130-
img: "https://static.wikia.nocookie.net/gensin-impact/images/6/62/Wish_Epitome_Invocation_2021-02-03.jpg/revision/latest?cb=20210201040313",
130+
img: "img/banners/1.3/weapon1.png",
131131
duration: "After Version 1.3 update – 2021/02/23 15:59:59",
132132
main: ["Primordial Jade Cutter", "Primordial Jade Winged-Spear"],
133133
other: ["Rust", "Eye of Perception", "Favonius Lance", "Sacrificial Greatsword", "The Flute"]
@@ -357,7 +357,7 @@ Note: this command supports fuzzy search.`,
357357

358358
const embed = new MessageEmbed()
359359
.setTitle(wish.title)
360-
.setImage(wish.img)
360+
.setImage(getLink(wish.img))
361361
.addField("Duration", wish.duration)
362362
.addField("Main", wish.main.join("\n"), true)
363363
.addField("Other", wish.other.join("\n"), true)
@@ -368,6 +368,10 @@ Note: this command supports fuzzy search.`,
368368
}
369369
}
370370

371+
export function getEventWishes() {
372+
return eventWishes
373+
}
374+
371375
export function parseEventWishNews(news: StoredNews, recent = true): void {
372376
const { data } = client
373377
const wish: {
@@ -410,8 +414,10 @@ export function parseEventWishNews(news: StoredNews, recent = true): void {
410414
const lines = page.text.split("\n")
411415
for (const i in lines) {
412416
const line = lines[i].trim()
413-
if (line.includes("Event Wish Duration"))
417+
if (line.includes("Event Wish Duration")) {
414418
wish.duration = lines[+i + 1].trim()
419+
wish.duration += lines[+i + 2]?.trim() ?? ""
420+
}
415421

416422
const mainMatch = line.match(/.*?5-star.*?(?:weapons?|characters?) (.*?) will (?:receive|get|recieve) a huge/)
417423
if (mainMatch)
@@ -435,7 +441,7 @@ export function parseEventWishNews(news: StoredNews, recent = true): void {
435441
eventWishes = eventWishes.sort((a, b) => {
436442
if (Math.abs(a.roughDate - b.roughDate) < 3600) {
437443
if (a.duration == b.duration)
438-
return a.title.includes("Epitome") ? 1 : -1
444+
return a.title.includes("Epitome") ? 1 : b.title.includes("Epitome") ? -1 : 0
439445

440446
return b.duration.localeCompare(a.duration)
441447
} else

src/utils/WebManager.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import bodyParser from "body-parser"
22
import express, { Express, NextFunction, Request, Response } from "express"
33
import log4js from "log4js"
4+
import { getEventWishes } from "../commands/misc/banners"
45
import config from "../data/config.json"
56
import client from "../main"
67
import { parseDuration } from "./Utils"
@@ -28,14 +29,25 @@ export default class WebManager {
2829
res.sendStatus(403)
2930
})
3031

32+
// List banners
33+
this.app.get("/banners", this.getBanners)
34+
35+
// Reminders
3136
this.app.get("/reminders/:user/get", this.getReminder)
3237
this.app.post("/reminders/:user/create", this.addReminder)
3338
this.app.post("/reminders/:user/delete", this.deleteReminder)
39+
40+
// Test
3441
this.app.post("/testmessage/:user", this.testMessage)
3542

3643
this.app.listen(config.webPort)
3744
}
3845

46+
getBanners(req: Req<{ user: string }>, res: Res): void {
47+
Logger.info("Getting banners from remote")
48+
res.send(getEventWishes())
49+
}
50+
3951
getReminder(req: Req<{ user: string }>, res: Res): void {
4052
const userid = req.params.user
4153

0 commit comments

Comments
 (0)