aboutsummaryrefslogtreecommitdiff
path: root/src/hooks
diff options
context:
space:
mode:
Diffstat (limited to 'src/hooks')
-rw-r--r--src/hooks/intensify.rs1
-rw-r--r--src/hooks/mod.rs20
-rw-r--r--src/hooks/pet.rs9
-rw-r--r--src/hooks/sed/mod.rs19
-rw-r--r--src/hooks/sed/parser.rs2
-rw-r--r--src/hooks/shifty_eyes.rs2
-rw-r--r--src/hooks/wolfram_alpha.rs8
7 files changed, 41 insertions, 20 deletions
diff --git a/src/hooks/intensify.rs b/src/hooks/intensify.rs
index 8e8a817..bbed9d9 100644
--- a/src/hooks/intensify.rs
+++ b/src/hooks/intensify.rs
@@ -2,6 +2,7 @@ use anyhow::{Context, Result};
use irc::client::prelude::*;
use macros::privmsg;
+/// \[Turn things up to eleven\]. Intensifies things written in brackets.
pub fn intensify(bot: &crate::Bot, msg: Message) -> Result<()> {
privmsg!(msg, {
let mut chars = text.chars();
diff --git a/src/hooks/mod.rs b/src/hooks/mod.rs
index 86d5697..822f839 100644
--- a/src/hooks/mod.rs
+++ b/src/hooks/mod.rs
@@ -1,17 +1,22 @@
-extern crate rand;
+//! The bots hooks, commands and matchers. For explanation of different types see [crate::catinator]
+//!
+//! # Implementing hooks
use anyhow::Result;
use irc::client::prelude::*;
-pub mod intensify;
-pub mod pet;
+mod intensify;
+mod pet;
+mod shifty_eyes;
+
+pub use intensify::*;
+pub use pet::*;
+pub use shifty_eyes::*;
+
pub mod sed;
-pub mod shifty_eyes;
pub mod wolfram_alpha;
-pub use intensify::intensify;
-pub use shifty_eyes::shifty_eyes;
-
+/// Replies with some information about the bot
pub fn about(bot: &crate::Bot, msg: Message) -> Result<()> {
bot.send_privmsg(
msg.response_target().unwrap(),
@@ -26,6 +31,7 @@ pub fn about(bot: &crate::Bot, msg: Message) -> Result<()> {
Ok(())
}
+/// Listen to AUTHENTICATE messages and perform SASL authentication
pub fn sasl(bot: &crate::Bot, msg: Message) -> Result<()> {
match msg.command {
Command::AUTHENTICATE(text) => {
diff --git a/src/hooks/pet.rs b/src/hooks/pet.rs
index 3e2defe..d11f562 100644
--- a/src/hooks/pet.rs
+++ b/src/hooks/pet.rs
@@ -1,5 +1,3 @@
-use std::str;
-
use anyhow::{Context, Result};
use irc::client::prelude::*;
use macros::privmsg;
@@ -15,14 +13,9 @@ const PET_RESPONSE: [&str; 5] = [
"strikes you with it's sharp claws",
];
-/// Pet cat
+/// Pet the cat, get rekt
///
/// Sends some random action when petted.
-///
-/// # See also
-///
-/// - [`Bot::send_action`]
-/// - RESPONSE
pub fn pet(bot: &crate::Bot, msg: Message) -> Result<()> {
privmsg!(msg, {
bot.send_action(
diff --git a/src/hooks/sed/mod.rs b/src/hooks/sed/mod.rs
index 3128372..7b7906c 100644
--- a/src/hooks/sed/mod.rs
+++ b/src/hooks/sed/mod.rs
@@ -1,3 +1,22 @@
+//! sed for irc. replace text in past messages
+//!
+//! Perform sed replaces on single messages in the buffers history, up to 10k messages old.
+//!
+//! ```text
+//! <+basso> crystalmett: welcome back
+//! <%audron> s/wel/whale/
+//! <\__{^-_-^}> <basso> crystalmett: whalecome back
+//! ```
+//!
+//! # Supported flags
+//! ```text
+//! g global: match every occurrence of the regex in a line
+//! i case-insensitive: letters match both upper and lower case
+//! s allow . to match \n
+//! U swap the meaning of x* and x*?
+//! x ignore whitespace and allow line comments (starting with `#`)
+//! ```
+
use anyhow::{anyhow, bail, Context, Result};
use irc::client::prelude::*;
diff --git a/src/hooks/sed/parser.rs b/src/hooks/sed/parser.rs
index eb7ef3e..815803c 100644
--- a/src/hooks/sed/parser.rs
+++ b/src/hooks/sed/parser.rs
@@ -3,7 +3,7 @@ use std::{borrow::Cow, str::Chars};
use bitflags::bitflags;
use regex::Regex;
-use crate::util::formatting::Formatting;
+use crate::util::Formatting;
type Commands = Vec<Command>;
diff --git a/src/hooks/shifty_eyes.rs b/src/hooks/shifty_eyes.rs
index 4680007..6203075 100644
--- a/src/hooks/shifty_eyes.rs
+++ b/src/hooks/shifty_eyes.rs
@@ -4,6 +4,7 @@ use irc::client::prelude::*;
const EYES: [char; 11] = ['^', 'v', 'V', '>', '<', 'x', 'X', '-', 'o', 'O', '.'];
const NOSE: [char; 7] = ['.', '_', '-', ';', '\'', '"', '~'];
+/// you are being watched <.<
pub fn shifty_eyes(bot: &crate::Bot, msg: Message) -> Result<()> {
if let Command::PRIVMSG(_, text) = msg.command.clone() {
if text.len() == 3 {
@@ -41,6 +42,7 @@ fn invert(input: char) -> Result<char> {
'>' => Ok('<'),
'<' => Ok('>'),
'x' => Ok('o'),
+ '.' => Ok('o'),
'X' => Ok('O'),
'-' => Ok('o'),
'o' => Ok('-'),
diff --git a/src/hooks/wolfram_alpha.rs b/src/hooks/wolfram_alpha.rs
index cdd32ca..9f56df4 100644
--- a/src/hooks/wolfram_alpha.rs
+++ b/src/hooks/wolfram_alpha.rs
@@ -1,7 +1,7 @@
-use crate::util::{
- formatting::truncate,
- web::{quote_plus, IsgdUrlShortener, UrlShortener},
-};
+//! ask wolfram alpha a query
+
+use crate::util::{quote_plus, truncate};
+// use crate::util::{url_shorteners::Isgd, UrlShortener};
use anyhow::{bail, Context, Error, Result};
use figment::providers::Env;
use futures::join;