Implement domain system

main
Elnu 9 months ago
parent 60d6eff39b
commit 9857504705

@ -1,3 +1,4 @@
DOMAIN=tegakituesday.com
DISCORD_TOKEN=
PREFIX="-h "
HUGO=/path/to/hugo

@ -20,7 +20,8 @@ use std::path::Path;
)]
pub async fn challenge(ctx: Context<'_>) -> Result<(), Error> {
ctx.say(format!(
"Tegaki Tuesday #{n}: <https://tegakituesday.com/{n}>",
"Tegaki Tuesday #{n}: <https://{domain}/{n}>",
domain = get_domain(),
n = get_challenge_number()
))
.await?;
@ -178,7 +179,7 @@ pub async fn submit(ctx: Context<'_>, submission: serenity::Attachment) -> Resul
set_submission_data(submission_data);
let mut message = String::new();
if requires_rebuild {
let thank_you = &format!("Thank you for submitting! You can view your submission at <https://tegakituesday.com/{}>", challenge_number);
let thank_you = &format!("Thank you for submitting! You can view your submission at <https://{domain}/{}>", challenge_number, domain = get_domain());
let mut repost_here = true;
match ctx {
Context::Application(_) => message.push_str(thank_you),
@ -230,8 +231,9 @@ pub async fn submit(ctx: Context<'_>, submission: serenity::Attachment) -> Resul
channel.send_message(&ctx.serenity_context().http, |m| {
m.embed(|e| {
let username = format!("{}#{}", author.name, author.discriminator);
let domain = get_domain();
let n = get_challenge_number();
let mut description = format!("New submission to [Tegaki Tuesday #{n}](https://tegakituesday.com/{n})!");
let mut description = format!("New submission to [Tegaki Tuesday #{n}](https://{domain}/{n})!");
if !here {
description.push_str(&if let Some(invite) = invite {
format!("\nCrossposted from [{}](https://discord.gg/{invite})", guild.name)
@ -246,7 +248,7 @@ pub async fn submit(ctx: Context<'_>, submission: serenity::Attachment) -> Resul
.name(username)
.url(format!("https://discord.com/users/{}", author.id));
e.set_author(embed_author);
e.image(format!("https://tegakituesday.com/{n}/{image}#{timestamp}"));
e.image(format!("https://{domain}/{n}/{image}#{timestamp}"));
if let Some(accent_color) = accent_color {
e.color(accent_color);
}
@ -300,10 +302,11 @@ pub async fn images(ctx: Context<'_>) -> Result<(), Error> {
));
for (i, image) in images.iter().enumerate() {
message.push_str(&format!(
"{}<https://tegakituesday.com/{}/{}>\n",
"{}<https://{domain}/{}/{}>\n",
to_fullwidth(&(i + 1).to_string()),
challenge_number,
image
image,
domain = get_domain()
));
}
ctx.say(message).await?;

@ -1,5 +1,6 @@
use crate::Context;
use crate::Error;
use crate::utils::get_domain;
use poise::command;
use std::env;
@ -13,10 +14,9 @@ use std::env;
description_localized("en-US", "Get help for the 字ちゃん Tegaki Tuesday bot")
)]
pub async fn help(ctx: Context<'_>) -> Result<(), Error> {
let p = env::var("PREFIX").unwrap();
let message = format!(
"<:jichan:943336845637480478> Hello! I'm (Ji-chan), the Tegaki Tuesday bot (and mascot!).
For more information about the challenge, check out the website at <https://tegakituesday.com>
For more information about the challenge, check out the website at <https://{domain}>
__**Tegaki Tuesday **__
:ballot_box: `{p}submit` Submit to the latest handwriting challenge.
@ -32,7 +32,9 @@ __**Kanji 漢字**__
:game_die: `{p}joyo` Random Jōyō kanji
:game_die: `{p}kyoiku <grade|all>` Random Kyōiku kanji
:game_die: `{p}jlpt <level|all>` Random JLPT kanji
:game_die: `{p}hyogai <group|all>` Random Hyōgai kanji"
:game_die: `{p}hyogai <group|all>` Random Hyōgai kanji",
p = env::var("PREFIX").unwrap(),
domain = get_domain(),
);
ctx.say(message).await?;
Ok(())

@ -97,9 +97,10 @@ pub async fn announce(
#[command(prefix_command, hide_in_help, ephemeral, owners_only)]
pub async fn announcechallenge(ctx: Context<'_>) -> Result<(), Error> {
let challenge_number = get_challenge_number();
let message = format!("Welcome to the **{n}{th}** weekly **Tegaki Tuesday** () handwriting challenge! :pen_fountain: The prompt is available in both Japanese and English on the website at <https://tegakituesday.com/{n}>.
let message = format!("Welcome to the **{n}{th}** weekly **Tegaki Tuesday** () handwriting challenge! :pen_fountain: The prompt is available in both Japanese and English on the website at <https://{domain}/{n}>.
You can make submissions in both languages, but please submit in your target language first. Submissions can be submitted by uploading the image to this channel along with the `{p}submit` command. By submitting, you agree to having your work posted to the website under the Attribution-ShareAlike 4.0 Unported (CC BY-SA 4.0) license, attributed to your Discord account. (<https://creativecommons.org/licenses/by-sa/4.0>).",
domain = get_domain(),
n = challenge_number,
th = match challenge_number % 10 {
1 => "ˢᵗ",

@ -34,6 +34,10 @@ pub fn get_challenge_number() -> i32 {
max
}
pub fn get_domain() -> String {
env::var("DOMAIN").unwrap()
}
pub fn get_hugo_path() -> String {
env::var("HUGO").unwrap()
}

Loading…
Cancel
Save