forked from karx/dircord
added support for DIRCORD_POLARIAN_MODE compile time env var
This commit is contained in:
parent
ba49971dd0
commit
e0f896e23e
|
@ -12,3 +12,5 @@ TODO:
|
||||||
- [x] handle multiple pings
|
- [x] handle multiple pings
|
||||||
- [x] multiple channels
|
- [x] multiple channels
|
||||||
- [x] IRC and Discord formatting
|
- [x] IRC and Discord formatting
|
||||||
|
|
||||||
|
<sub>For extra fun set the DIRCORD_POLARIAN_MODE environmental variable to any value ;)</sub>
|
||||||
|
|
|
@ -60,14 +60,19 @@ impl<'a> StrChunks<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn create_prefix(msg: &Message, is_reply: bool, http: impl CacheHttp) -> (String, usize) {
|
async fn create_prefix(msg: &Message, is_reply: bool, http: impl CacheHttp) -> (String, usize) {
|
||||||
// let nick = match msg.member(http).await {
|
|
||||||
// Ok(Member {
|
let mut nick = match msg.member(http).await {
|
||||||
// nick: Some(nick), ..
|
Ok(Member {
|
||||||
// }) => Cow::Owned(nick),
|
nick: Some(nick), ..
|
||||||
// _ => Cow::Borrowed(&msg.author.name),
|
}) => Cow::Owned(nick),
|
||||||
// };
|
_ => Cow::Borrowed(&msg.author.name),
|
||||||
let nick = "polarbear";
|
};
|
||||||
|
|
||||||
|
if option_env!("DIRCORD_POLARIAN_MODE").is_some() {
|
||||||
|
nick = Cow::Owned("polarbear".to_string());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
let mut chars = nick.char_indices();
|
let mut chars = nick.char_indices();
|
||||||
let first_char = chars.next().unwrap().1;
|
let first_char = chars.next().unwrap().1;
|
||||||
let second_char_offset = chars.next().unwrap().0;
|
let second_char_offset = chars.next().unwrap().0;
|
||||||
|
|
|
@ -68,7 +68,11 @@ pub async fn irc_loop(
|
||||||
continue;
|
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 {
|
if let Command::PRIVMSG(ref channel, ref message) = orig_message.command {
|
||||||
let channel_id = ChannelId::from(*unwrap_or_continue!(mapping.get(channel)));
|
let channel_id = ChannelId::from(*unwrap_or_continue!(mapping.get(channel)));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue