Merge pull request 'yandere-fixes' (#5) from yandere-fixes into main
Reviewed-on: https://gitea.fzzin.31718216.xyz/fzzinchemical/HotDog/pulls/5
This commit is contained in:
@@ -54,19 +54,3 @@ export function getPosts(search? : string){
|
||||
const url = prepareURLObjectForRequest("post")
|
||||
return handlePostRequest(url, search)
|
||||
}
|
||||
|
||||
Deno.test("Empty Post Request", async() => {
|
||||
console.debug(await getPosts())
|
||||
})
|
||||
|
||||
Deno.test("Post Request with tag", async() => {
|
||||
console.debug(await getPosts("[tags:love_live!_(series)]"))
|
||||
})
|
||||
|
||||
Deno.test("Post Request with limit", async() => {
|
||||
console.debug(await getPosts("[limit: 1)]"))
|
||||
})
|
||||
|
||||
Deno.test("Post Request with page", async() => {
|
||||
console.debug(await getPosts("[page: 30)]"))
|
||||
})
|
||||
@@ -1,16 +1,16 @@
|
||||
import { Bot, Embed, Message } from "npm:discordeno@18.0.1";
|
||||
import { Bot, Message, transformEmbed } from "npm:discordeno@18.0.1";
|
||||
import { defaultString } from "@root/defaultString.ts";
|
||||
import { logMessage } from "@root/logging.ts";
|
||||
import { getPosts } from "@root/plugins/yandere/api/api.ts";
|
||||
import { debug } from "node:console";
|
||||
|
||||
export async function yandereMessageHandler(bot: Bot, message: Message) {
|
||||
const command = message.content.split(" ").slice(1).join(" ");
|
||||
const args = command.match(/(\[\.+\])/g)
|
||||
if (command === "drop") {
|
||||
const embed = await getPosts("[limit: 1]")
|
||||
const embed = (await getPosts("[limit: 1]"))[0]
|
||||
if (embed === undefined) throw Error("undefined embed")
|
||||
bot.helpers.sendMessage(message.channelId, {
|
||||
embeds: [embed as Embed]
|
||||
embeds: [transformEmbed(bot, embed)]
|
||||
})
|
||||
} else if (command.startsWith("drop [") && command.endsWith("]")) {
|
||||
logMessage(message);
|
||||
@@ -18,7 +18,7 @@ export async function yandereMessageHandler(bot: Bot, message: Message) {
|
||||
const generatedEmbeds = await getPosts(args[0]);
|
||||
for (const embed of generatedEmbeds) {
|
||||
bot.helpers.sendMessage(message.channelId, {
|
||||
embeds: [embed as Embed],
|
||||
embeds: [transformEmbed(bot, embed)],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
import { assert } from "@std/assert/assert";
|
||||
import {
|
||||
dropYandere,
|
||||
getPage,
|
||||
refresh,
|
||||
setPage,
|
||||
} from "./api/api.ts";
|
||||
import { assertEquals } from "@std/assert/equals";
|
||||
//tests
|
||||
/*
|
||||
get page,
|
||||
switch page,
|
||||
drop,
|
||||
*/
|
||||
|
||||
Deno.test("Get default Page", async () => {
|
||||
assertEquals(getPage(), 1);
|
||||
});
|
||||
|
||||
Deno.test("Switching page", async () => {
|
||||
assertEquals(getPage(), 1);
|
||||
await setPage(2);
|
||||
assertEquals(getPage(), 2);
|
||||
await setPage(100);
|
||||
assertEquals(getPage(), 100);
|
||||
});
|
||||
|
||||
Deno.test("Test Drop", async () => {
|
||||
await refresh();
|
||||
const link = await dropYandere();
|
||||
assert(link !== "", "Empty String was dropped!");
|
||||
});
|
||||
|
||||
17
src/plugins/yandere/tests/api.ts
Normal file
17
src/plugins/yandere/tests/api.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { getPosts } from "@root/plugins/yandere/api/api.ts"
|
||||
|
||||
Deno.test("Empty Post Request", async() => {
|
||||
console.debug(await getPosts())
|
||||
})
|
||||
|
||||
Deno.test("Post Request with tag", async() => {
|
||||
console.debug(await getPosts("[tags:love_live!_(series)]"))
|
||||
})
|
||||
|
||||
Deno.test("Post Request with limit", async() => {
|
||||
console.debug(await getPosts("[limit: 1)]"))
|
||||
})
|
||||
|
||||
Deno.test("Post Request with page", async() => {
|
||||
console.debug(await getPosts("[page: 30)]"))
|
||||
})
|
||||
Reference in New Issue
Block a user