forked from jmug/stoatchat
Randomly select an avatar from id.
This commit is contained in:
BIN
assets/user_blue.png
Normal file
BIN
assets/user_blue.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
BIN
assets/user_green.png
Normal file
BIN
assets/user_green.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
BIN
assets/user_red.png
Normal file
BIN
assets/user_red.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.2 KiB |
BIN
assets/user_yellow.png
Normal file
BIN
assets/user_yellow.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@@ -1,7 +1,43 @@
|
|||||||
use rocket::response::NamedFile;
|
use rocket::response::NamedFile;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
#[get("/<_target>/avatar")]
|
use crate::database::Ref;
|
||||||
pub async fn req(_target: String) -> Option<NamedFile> {
|
|
||||||
NamedFile::open(Path::new("avatar.png")).await.ok()
|
#[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!()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user