aboutsummaryrefslogtreecommitdiff
path: root/src/hooks/pet.rs
blob: 990329df2a5e2746fde04fd6d22444e1f6e1b188 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use anyhow::{Context, Result};
use irc::client::prelude::*;
use macros::privmsg;

use rand::{prelude::IndexedRandom, rng};

const PET_RESPONSE: [&str; 5] = [
    "purrs",
    "meows loudly",
    "walks away",
    "snuggles back",
    "strikes you with it's sharp claws",
];

/// Pet the cat, get rekt
///
/// Sends some random action when petted.
pub fn pet(bot: &crate::Bot, msg: Message) -> Result<()> {
    privmsg!(msg, {
        bot.send_action(
            msg.response_target()
                .context("failed to get response target")?,
            PET_RESPONSE
                .choose(&mut rng())
                .context("failed choosing a pet response")?,
        )?;
    })
}
rsion to 1.6.2Max Audron-3/+2 2021-10-20prepare for release on crates.ioMax Audron-39/+65 2021-10-20add async docs to macro crate and bump versionMax Audron-9/+10 2021-10-20change hook errors to be logged as warningsMax Audron-3/+3 they in nearly all cases aren't critical enough to warrant an actual error messages 2021-10-20fix configuration not loading correctly on release buildsMax Audron-8/+23 2021-10-19replace sedregex crate8-rework-sedMax Audron-20/+358 This replaces the sedregex crate with our own implementation for multiple reasons: 1. We required to access the parsed regex, this required a patch to the sedregex crate which did not get merged due to an inactive dev, blocking us from publishing on crates.Io 2. We wanted to highlight the changes done in bold 3. We want to add execution of multiple chained sed commands in the future which would require more modification 2021-10-19add formatting trait for irc codesMax Audron-0/+129 add an impl off the formatting trait on String to format Strings with the typical irc formatting codes for bold, italic etc 2021-10-17fix links in readmeMax Audron-2/+2