~phate/rsPhate

b87942122d943d523eabf9b8795028e87d509571 — Ash 11 months ago 096719d
LICENSE->LICENCE.md, a few new commands
11 files changed, 45 insertions(+), 63 deletions(-)

M Cargo.toml
D LICENSE
A LICENSE.md
M src/commands/mod.rs
M src/commands/quit.rs
D src/commands/star.rs
M src/commands/wipltrn.rs
M src/functions/mod.rs
M src/functions/prefix_space_check.rs
A src/functions/star.rs
M src/main.rs
M Cargo.toml => Cargo.toml +6 -5
@@ 8,11 8,12 @@ edition = "2018"

[dependencies]
date_time = "2.1.0"
env_logger = "0.6"
kankyo = "0.2"
log = "0.4"
env_logger = "0.8.1"
kankyo = "0.3.0"
log = "0.4.11"
mpd = "0.0.12"
owoify = "0.1.5"
rand = "0.7"
rand = "0.7.3"
rofl = "0.0.1"
serenity = "0.8"
\ No newline at end of file
sedregex = "0.2.4"
serenity = "0.8.7"

D LICENSE => LICENSE +0 -24
@@ 1,24 0,0 @@
This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to <https://unlicense.org>
\ No newline at end of file

A LICENSE.md => LICENSE.md +2 -0
@@ 0,0 1,2 @@
Anybody, is allowed to do anything, with this software.
*Any and all copyright restrictions are hereby revoked.*

M src/commands/mod.rs => src/commands/mod.rs +0 -1
@@ 16,6 16,5 @@ pub mod projects;
pub mod quit;
pub mod rng;
pub mod rr;
pub mod star;
pub mod wipltrn;
pub mod ww;

M src/commands/quit.rs => src/commands/quit.rs +12 -1
@@ 2,9 2,11 @@ use crate::ShardManagerContainer;
use crate::OWNER_CHECK;
use serenity::{
    framework::standard::{macros::command, CommandResult},
    http::AttachmentType,
    model::channel::Message,
    prelude::*,
};
use std::path::Path;

#[command]
#[checks(Owner)]


@@ 16,7 18,16 @@ fn quit(ctx: &mut Context, msg: &Message) -> CommandResult {
    if let Some(manager) = data.get::<ShardManagerContainer>() {
        // Shush, it'll make me feel better when I can't get the bot to work how I want.
        if message.contains("^foad") {
            let _ = msg.reply(&ctx, "I'm terribly sorry for being a failure. Expunging myself to robot hell as we speak.");
            let _ = msg.channel_id.send_message(&ctx.http, |m| {
                m.embed(|e| {
                    e.title("I'm terribly sorry for being a failure.");
                    e.description("Expunging myself to robot hell as we speak.");
                    e.image("attachment://external-content.duckduckgo.com.gif");
                    e
                });
                m.add_file(AttachmentType::Path(Path::new("/home/valley/downloads/external-content.duckduckgo.com.gif")));
                m
            });
        } else {
            let _ = msg.reply(&ctx, "Hai, Phate-senpai~");
        }

D src/commands/star.rs => src/commands/star.rs +0 -22
@@ 1,22 0,0 @@
use log::{error, info};
use serenity::{
    framework::standard::{macros::command, CommandResult},
    model::channel::Message,
    prelude::*,
};

#[command]
#[description = "Bot will star the user's message. Useful for starring your own messages with Hoshi bot."]
#[usage = "message"]
#[example = "message goes here"]
fn star(ctx: &mut Context, msg: &Message) -> CommandResult {
    info!(
        "starring the message: {}, sent by user: {}",
        msg.content, msg.author.name
    );
    if let Err(why) = msg.react(&ctx.http, '⭐') {
        error!("could not star the message");
    }

    Ok(())
}

M src/commands/wipltrn.rs => src/commands/wipltrn.rs +9 -5
@@ 1,4 1,5 @@
use mpd::{Client, Song};
use sedregex::find_and_replace;
use serenity::{
    framework::standard::{macros::command, CommandResult},
    http::AttachmentType,


@@ 12,12 13,15 @@ use std::path::Path;
fn wipltrn(ctx: &mut Context, msg: &Message) -> CommandResult {
    let mut c = Client::connect("127.0.0.1:6600").unwrap();
    let song: Song = c.currentsong().unwrap().unwrap();
    let fil = song.file;
    let format = find_and_replace(&fil, &["s/.*\\.//"]).unwrap();
    let tit = song.title.as_ref().unwrap();
    let art = song.tags.get("Artist").unwrap();
    let alb = song.tags.get("Album").unwrap();
    let dat = song.tags.get("Date").unwrap();
    let mus_title = art.to_owned() + &" - ".to_string() + tit;
    let mus_album = alb.to_owned() + &" (".to_string() + &dat + &")".to_string();
    let na = "N/A".to_string();
    let art = song.tags.get("Artist").unwrap_or(&na);
    let alb = song.tags.get("Album").unwrap_or(&na);
    let dat = song.tags.get("Date").unwrap_or(&na);
    let mus_title = [art, " - ", tit, " [", &format, "]"].concat();
    let mus_album = [alb, " (", dat, ")"].concat();
    let msg = msg.channel_id.send_message(&ctx.http, |m| {
        m.embed(|e| {
            e.title(&mus_title);

M src/functions/mod.rs => src/functions/mod.rs +1 -0
@@ 1,2 1,3 @@
pub mod prefix_space_check;
pub mod star;
pub mod yt_tw_check;

M src/functions/prefix_space_check.rs => src/functions/prefix_space_check.rs +2 -0
@@ 5,6 5,8 @@ use serenity::{model::channel::Message, prelude::*};
pub fn prefix_space_check(ctx: &mut Context, msg: &Message, unknown_command_name: &str) {
    if msg.content.contains("^ ") {
        info!("There was a space after the prefix, assuming the bot was not intended to be used.");
    } else if msg.content.contains("^\n") {
        info!("There was a newline after the prefix, assuming the bot was not intended to be used.");
    } else {
        error!("Invalid command: '{}'", unknown_command_name);
        let msg = msg.channel_id.send_message(&ctx.http, |m| {

A src/functions/star.rs => src/functions/star.rs +9 -0
@@ 0,0 1,9 @@
use log::{error, info};
use serenity::{model::channel::{Message, ReactionType}, prelude::*};

// If the user's message is starred, copy it and send it as an embed in #starboard.
pub fn star(ctx: &mut Context, msg: &Message) {
    let sent_message = &msg.content;
    let reactions = &msg.reactions;
    info!("Content: {}, Reactions: {:#?}", sent_message, reactions);
}

M src/main.rs => src/main.rs +4 -5
@@ 21,12 21,12 @@ use std::{
mod commands;
use commands::{
    about::*, date::*, embed::*, fortune::*, git::*, hmm::*, iv::*, math::*, meme::*, noice::*,
    owo::*, projects::*, quit::*, rng::*, rr::*, star::*, wipltrn::*, ww::*,
    owo::*, projects::*, quit::*, rng::*, rr::*, wipltrn::*, ww::*,
};

// Load and use extra functions from src/functions/
mod functions;
use functions::{prefix_space_check::prefix_space_check, yt_tw_check::yt_tw_check};
use functions::{prefix_space_check::prefix_space_check, star::star};

// A container type is created for inserting into the Client's `data`, which
// allows for data to be accessible across all events and framework commands, or


@@ 88,7 88,7 @@ struct Numbers;

#[group]
#[description = "Functions that are related to message operations."]
#[commands(embed, git, owo, star)]
#[commands(embed, git, owo)]
struct Messages;

#[help]


@@ 106,7 106,7 @@ fn my_help(

fn main() {
    // This will load the environment variables located at `./.env`, relative to the CWD.
    kankyo::load().expect("Failed to load .env file");
    kankyo::load(true).expect("Failed to load .env file");

    // Initialize the logger to use environment variables.
    env_logger::init();


@@ 175,7 175,6 @@ fn main() {
                prefix_space_check(ctx, msg, unknown_command_name);
            })
            .normal_message(|ctx, msg| {
                yt_tw_check(ctx, msg);
            })
            // Set a function that's called whenever a command's execution didn't complete for one
            // reason or another. For example, when a user has exceeded a rate-limit or a command