added support for DIRCORD_POLARIAN_MODE compile time env var

This commit is contained in:
delta 2022-07-11 08:59:47 +02:00
parent ba49971dd0
commit e0f896e23e
3 changed files with 20 additions and 9 deletions

View file

@ -12,3 +12,5 @@ TODO:
- [x] handle multiple pings
- [x] multiple channels
- [x] IRC and Discord formatting
<sub>For extra fun set the DIRCORD_POLARIAN_MODE environmental variable to any value ;)</sub>

View file

@ -60,14 +60,19 @@ impl<'a> StrChunks<'a> {
}
async fn create_prefix(msg: &Message, is_reply: bool, http: impl CacheHttp) -> (String, usize) {
// let nick = match msg.member(http).await {
// Ok(Member {
// nick: Some(nick), ..
// }) => Cow::Owned(nick),
// _ => Cow::Borrowed(&msg.author.name),
// };
let nick = "polarbear";
let mut nick = match msg.member(http).await {
Ok(Member {
nick: Some(nick), ..
}) => Cow::Owned(nick),
_ => Cow::Borrowed(&msg.author.name),
};
if option_env!("DIRCORD_POLARIAN_MODE").is_some() {
nick = Cow::Owned("polarbear".to_string());
}
let mut chars = nick.char_indices();
let first_char = chars.next().unwrap().1;
let second_char_offset = chars.next().unwrap().0;

View file

@ -68,7 +68,11 @@ pub async fn irc_loop(
continue;
};
let nickname = "polarbear";
let mut nickname = unwrap_or_continue!(orig_message.source_nickname());
if option_env!("DIRCORD_POLARIAN_MODE").is_some() {
nickname = "polarbear";
}
if let Command::PRIVMSG(ref channel, ref message) = orig_message.command {
let channel_id = ChannelId::from(*unwrap_or_continue!(mapping.get(channel)));