Giter Club home page Giter Club logo

ritsucogs's Introduction

RitsuCogs

A small collection of cogs for Red-DiscordBot. If you need help or have questions that are not answered here, visit the official Red Cogs Support server and mention @kagami#6142.

Quick start

  1. Install repo: [p]cog repo add RitsuCogs https://github.com/ritsu/RitsuCogs
  2. Install cog: [p]cog install RitsuCogs COGNAME

Contents

What's new

  • 2018-04-01: Updated Pick with option to automatically DM a user when they enter a pick event. (This is disabled by deafult; use [p]picks set auto-dm on to enable.)
  • 2018-04-01: Updated Pick to allow @member and #channel mentions in event names.
  • 2018-01-07: Updated Helpless with the ability to disable global help command and help via DMs.
  • 2018-01-03: New year, new README. Also added Helpless which filters help messages based on Squid-Plugins Permissions.

CommandSearch

Lets you search for commands on your bot.

Commands

  • cmds lists all commands on your bot that contain search_string.
    [p]commandsearch|cmds|coms <search_string>
    

GNU

An attempt to emulate some common GNU utilities.

Input and Output

All commands accept input from the following:

  • Website content if a valid URL is specified
  • Chat log if @chat is specified (Chat log must be enabled for the channel, e.g. !clog on)
  • Any text following the command if none of the above are detected.

The following options for input and output apply to all non-administrative commands:

Global Options
    -p       If input is a URL, this will treat the URL content as (prettified) html instead of a DOM.
    -@       Same as -p except source is not passed through BeautifulSoup's prettify().
    -%       Print each line as a separate message; more likely to hit Discord's 5/5 rate limit.

Chat log options can be configured with the clog command.

Pipes

Output from one GNU command can be piped to the input of another GNU command. Does not work with non-GNU commands.

[p]sed "s/^.{0,20}$//" http://news.google.com | grep -i apple | sed s/apple/Orange/i | tail -n 5

Prefix is optional for commands that appear after a pipe.

Redirected output

Output can be redirected to pastebin instead of Discord chat with one of the following:

  • > paste_title creates a 24 hr pastebin
  • >> paste_title creates a permanent pastebin

A link to the generated pastebin will be posted in chat. When used with pipes, the redirect must appear at the end.

[p]cat -b http://news.google.com | grep -rm 10 .{40,} > somenews

A pastebin API key is required for this feature. Save the API key with the command:

[p]pastebin [api_key]

Commands

  • grep prints lines that contain a match for a pattern.

    grep [options] [pattern] [input]
    
    Matching Options
        -i       Ignore case distinctions, so that characters that differ only in case match each other.
        -w       Select only those lines containing matches that form whole words.
        -v       Invert the sense of matching, to select non-matching lines.
        -r       Treats search string as a regex pattern; other Matching Options are ignored.
    
    Output Options
        -c       Suppress normal output; instead print a count of matching lines for each input file.
        -n       Prefix each line of output with its line number.
        -m num   Stop reading from input after num matching lines.
        -A num   Print num lines of trailing context after matching lines.
        -B num   Print num lines of leading context before matching lines.
        -C num   Print num lines of leading and trailing context.
    
  • sed is a simple stream editor.

    sed [options] [script] [input]
    
    Options
        -g       Process entire input as a single string, rather than line by line.
        -n       Disable automatic printing; only produce output when explicitly told to.
    
    Script Address
        /.../    Returns lines that match the regular expression.
        A        Returns line number A.
        A,B      Returns lines from A to B.
        A~N      Returns every Nth line, starting from A
    
    Script Command
        a...     Append after each line.
        c...     Change lines with new line.
        d        Delete lines.
        i...     Insert before each line.
        p        Print line.
        s/././   Substitute with regular expression pattern.
        =        Print line number.
    
    Script Pattern Flag
        /i       Ignore case
        /p       Print (mostly used when -n option is active)
    
  • wc counts the number of characters, whitespace-separated words, and newlines in the given input.

    wc [option] [input]
    
    Options
        -m      Print only the character counts.
        -w      Print only the word counts.
        -l      Print only the newline counts.
    
  • cat echoes the contents of the input.

    cat [options] [input]
    
    Options
        -b      Number all nonempty output lines, starting with 1.
        -n      Number all output lines, starting with 1. This option is ignored if -b is in effect.
        -s      Suppress repeated adjacent blank lines; output just one empty line instead of several.
    
  • tac echoes input to output in reverse by line or user specified separator.

    tac [options] [input]
    
    Options
        -s sep  Use "sep" as the record separator, instead of newline.
        -r      Treat the separator string as a regular expression.
    
  • tail prints the last part (10 lines by default) of input.

    tail [options] [input]
    
    Options
        -n [+]num   Output the last num lines. However, if num is prefixed with a '+'
                    start printing with line num from the start of input, instead of from the end.
    

Helpless

Allows owner to disable the global help command, disallow help via DMs, and/or hide help based on Squid-Plugins Permissions. If you are the bot owner, you will not notice any difference when you use the help command because you always have permissions for everything. If you want to test the help filters, login as a different Discord user.

Commands

  • helpless bot on turns on bot help filtering (aka global help). This disables [p]help when used without any arguments.

    helpless bot on
    
  • helpless bot off turns off bot help filtering (aka global help). This allows [p]help to be used without any arguments.

    helpless bot off
    
  • helpless bot msg sets the placeholder message that is displayed when bot help is disabled.

    helpless bot msg <msg>
    
  • helpless dm on turns on DM help filtering. This prevents users from using the help command in DMs.

    helpless dm on
    
  • helpless dm off turns off DM help filtering. This allows users to use the help command in DMs.

    helpless dm off
    
  • helpless dm msg sets the placeholder message that is displayed when DM help is disabled.

    helpless dm msg <msg>
    
  • helpless p on turns on help filtering based on Squid-Plugins Permissions cog.

    helpless p on
    
  • helpless p off turns off help filtering based on Squid-Plugins Permissions cog.

    helpless p off
    
  • helpless p msg sets the placeholder message that is displayed when help is disabled by Permissions.

    helpless p msg <msg>
    
  • helpless config shows current Helpless config.

    helpless config
    

Pick

Pick random users from your channel. Use this to perform giveaways, raffles, and other types of contests. This can instantly pick from members currently in channel, or create an "event" users can enter by typing a keyword in chat.

Commands

  • pick will pick random users instantly from the channel (ignores bots).

    pick [num] +[role] -[role] +[status] -[status]
    
    num       Number of users to pick (default is 1)
    +role     Users must have at least one of these roles
    -role     Users cannot have any of these roles
    +status   Users must have at least one of these statuses
    -status   Users cannot have any of these statuses
      
    Examples  pick 2
              pick 3 +mod +online
              pick 3 +sub +patreon -mod -admin -offline -invisible
    
  • pickfor creates a pick event that users can enter by typing the name of the event in chat.

    pickfor <event> <duration> [num] +[role] -[role]
    
    event     Name of the event
    duration  How long event will last before bot picks winners
              Duration is any number followed by 's', 'm', or 'h'
    num       Number of users to pick (default is 1)
    +role     Users must have at least one of these roles
    -role     Users cannot have any of these roles
    
    Examples  pickfor raffle 60s 2
              pickfor giveaway 24h 3
              pickfor myteam 2m 4 +mod +sub
    
  • pickfrom will pick from a list of names typed in the command

    pickfrom <names> [num]
    
    names     Names to pick from
    num       Number of names to pick
    
    Examples  pickfrom a b c     (Pick 1 from a, b, c)
              pickfrom a b c 2   (Pick 2 from a, b, c)
    
  • picks check will DM you if you are entered into any pick events.

    picks check
    
  • picks delete will delete a pick event you created.

    picks delete <name> [channel]
    
    name      Name of event
    channel   Channel event is in (optional)
    
    Examples  picks delete giveaway
              picks delete giveaway #contests
    
  • picks force will force the bot to pick for an event you created (and end the event).

    picks force <name> [channel]
    
    name      Name of event
    channel   Channel event is in (optional)
       
    Examples  picks force giveaway
              picks force giveaway #contests
    
  • picks list will list all currently running pick events on the server.

    picks list
    
  • picks show will show details about a pick event.

    picks show <name> [channel]
    
    name      Name of event
    channel   Channel event is in (optional)
    
    Examples  picks show giveaway
              picks show giveaway #contests
    
  • picks set auto-dm toggles the option to automatically DM users when they enter a pick event.

    picks set auto-dm on   Turn auto-dm on
    picks set auto-dm off  Turn auto-dm off
    picks set auto-dm      Show current auto-dm setting
    

SysInfo

A set of commands that display system information for the machine running the bot. Note that some of these commands may not not be available depending on your system environment.

This cog will install psutil, which is used to retrieve system information. If this does not happen automatically, you can manually install it with pip3 install psutil

Commands

  • sys info displays a summary of cpu, memory, disk and network information.

    sys info
    
  • sys df shows file system disk space usage, similar to "df -h" on linux.

    sys df
    
  • sys free shows the amount of free and used memory in the system, similar to "free" on linux.

    sys free
    
  • sys ifconfig shows network interface information, similar to "ifconfig" on linux.

    sys ifconfig
    
  • sys iotop shows I/O usage information output by the kernel, like a snapshot of "iotop" on linux.

    sys iotop
    
  • sys meminfo shows system memory information.

    sys meminfo
    
  • sys netstat shows information about the networking subsystem, similar to "netstat -antp" on linux.

    sys netstat
    
  • sys nettop shows a snapshot of real-time network statistics.

    sys nettop
    
  • sys mem shows physical memory usage, taking shared memory pages into account, similar to "smem" on linux.

    sys smem
    
  • sys ps shows information about active processes, similar to "ps -aux" on linux.

    sys ps
    
  • sys top shows real-time system information and tasks, like a snapshot of "top" on linux.

    sys top
    
  • sys who shows which users are currently logged in, similar to "who" on linux

    sys who
    

TokyoTosho

Allows you to search TokyoTosho from discord and configure custom RSS alerts that notify you when new torrents matching user defined criteria appear on the site.

This cog will install js2py to access TokyoTosho behind CloudFlare. If this does not happen automatically, you can manually install it with pip3 install js2py

Commands

  • tt search will search for torrents based on search terms and category.

    tt search <terms> [#category]
    
    terms      Regular search strings. Use '-' to exclude terms.
    category   One of the categories defined on TokyoTosho.
               Type '[p]tt cats' to see a list of valid categories.
    
    Examples   tt search horriblesubs madoka 1080
               tt search madoka rebellion -dub #anime
               tt search madoka #music
    
  • tt add will add an RSS alert to your channel. The bot will display torrent name and link when a new torrent matching the configured terms and categories (optional) appears in TokyoTosho's RSS feed. Note you can specify

    tt add <terms> [#categories]
    
    terms      Regular search strings. Use '-' to exclude terms.
    category   One of the categories defined on TokyoTosho.
               Type '[p]tt cats' to see a list of valid categories.
    
    Examples   tt add horriblesubs madoka 1080
               tt add madoka -horriblesubs -dub
               tt add madoka #anime #music
               tt add shokugeki 1080 -raw #anime
    
  • tt list will lists existing alerts configured for your channel.

    tt list
    
  • tt check will check existing alerts against the current RSS feed. The RSS feed only contains the last 150 items, so old items may not appear.

    tt check
    
  • tt remove will remove alerts matching (exactly) the specified terms and categories if they exist in your channel. If no matching alerts are found, nothing happens.

    tt remove [terms] [#categories]
    
  • tt set is used for configuring various options for the cog.

    tt set [option] [value]
    
    OPTIONS
        check_interval      Number of seconds between RSS updates
        comment_length      Max length of search result and RSS feed comments
        ignore              List of categories that are ignored in all search and RSS alerts
        items_per_message   Max number of items the bot will mention in one message
    

ritsucogs's People

Contributors

ritsu avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ritsucogs's Issues

sysinfo who when no users are logged in

Currently bot does not say anything if no users are logged in.
Make it so bot says something like, "No users currently logged in"

P.S. fix typo in info.json

Possible sysinfo exception when there are open files on different drives

Collecting psutil
  Using cached psutil-5.2.2-cp35-cp35m-win32.whl
Installing collected packages: psutil
Successfully installed psutil-5.2.2
Copying sysinfo...
[18/06/2017 18:00] ERROR red on_command_error 369: Exception in command 'sysinfo'
Traceback (most recent call last):
  File "lib\discord\ext\commands\core.py", line 50, in wrapped
    ret = yield from coro(*args, **kwargs)
  File "G:\Software\Red-DiscordBot\cogs\sysinfo.py", line 62, in psutil
    common = os.path.commonpath([f.path for f in open_f])
  File "G:\Software\Python35-32\lib\ntpath.py", line 632, in commonpath
    raise ValueError("Paths don't have the same drive")
ValueError: Paths don't have the same drive

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.