Skip to content
Snippets Groups Projects
Commit a9f258de authored by insert's avatar insert
Browse files

Randomly select an avatar from id.

parent f6c52de1
No related merge requests found
assets/user_blue.png

11.3 KiB

assets/user_green.png

11.6 KiB

assets/user_red.png

7.24 KiB

assets/user_yellow.png

11.6 KiB

use rocket::response::NamedFile;
use std::path::Path;
#[get("/<_target>/avatar")]
pub async fn req(_target: String) -> Option<NamedFile> {
NamedFile::open(Path::new("avatar.png")).await.ok()
use crate::database::Ref;
#[get("/<target>/avatar")]
pub async fn req(target: Ref) -> Option<NamedFile> {
match target.id.chars().nth(25).unwrap() {
'0' |
'1' |
'2' |
'3' |
'4' |
'5' |
'6' |
'7' => NamedFile::open(Path::new("assets/user_red.png")).await.ok(),
'8' |
'9' |
'A' |
'C' |
'B' |
'D' |
'E' |
'F' => NamedFile::open(Path::new("assets/user_green.png")).await.ok(),
'G' |
'H' |
'J' |
'K' |
'M' |
'N' |
'P' |
'Q' => NamedFile::open(Path::new("assets/user_blue.png")).await.ok(),
'R' |
'S' |
'T' |
'V' |
'W' |
'X' |
'Y' |
'Z' => NamedFile::open(Path::new("assets/user_yellow.png")).await.ok(),
_ => unreachable!()
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment