Code Monkey home page Code Monkey logo

bobbit's Introduction

Bobbit

bobbit is a simple and modular asynchronous IRC / Slack bot written in Python. The current version uses asyncio as its core networking and event processing backend.

Requirements

Configuration

Bobbit requires a configuration YAML file (bobbit.yaml) to run, which should be in the directory specified by config-dir (default: ~/.config/bobbit). An example config file looks like this:

nick:       "bobbit"
password:   <password>
owners:
    - <owner>
host:       <irc server>
port:       6667
channels:
    - <channel>

The following modules also require configuration files (in config-dir):

  • lookup: requires lookup.yaml. Here's an example:

    cool kids:
    - I wish that I could be like the cool kids \\ 'Cause all the cool kids, they seem to fit in
    
  • weather: optionally reads weather.yaml. Here's an example:

    default:    <zipcode>
    

Slack

TODO: Describe how to get Slack token.

https://medium.com/@andrewarrow/how-to-get-slack-api-tokens-with-client-scope-e311856ebe9

Execution

To start the the bot, run bin/bobbit:

$ ./bin/bobbit -h
usage: bobbit [--config-dir CONFIG_DIR] [--log-path LOG_PATH] [--debug]
              [--local] [-h]

Simple Asynchronous IRC/Slack Bot

optional arguments:
  --config-dir CONFIG_DIR  Configuration directory (default: ~/.config/bobbit)
  --log-path LOG_PATH      Path to log file (default: None)
  --debug                  Enable debug logging (default: False)
  --local                  Enable local client (default: False)
  -h, --help               Show this help message and exit

Note: The local client (ie. --local) allows you to test the modules directly in the terminal by using standard input rather than connecting to an actual IRC or Slack network.

Docker

You can also start application using docker:

Building container

docker build --no-cache -t 'bobbit' .

Running:

docker run -it bobbit

You can pass args to application directly, also you can mount your config file using docker volumes, for example:

docker run -v /my-config-dir:/tmp/my-config-dir bobbit --config-dir /tmp/config-dir

And change default user with using --env argument, for example:

docker run -e USER=MYFANCYUSER bobbit --config-dir /tmp/config-dir

bobbit's People

Contributors

andrewlitteken avatar androidkitkat avatar annaklempay avatar antithalian avatar catvajiac avatar colinmckechney avatar errmeier avatar evstar3 avatar ginglis13 avatar jporubci avatar noyoshi avatar nuolong avatar pbui avatar pkruk avatar sambattalio avatar sarahchaaaaa avatar shawalli avatar tfaughnan avatar tinawu-23 avatar zmenciso avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

bobbit's Issues

Update Dockerfile

The current Dockerfile works for bobbit-0.1.x, but needs to be update for bobbit-0.2.x. In particular, it is missing some modules like aiohttp and the proper commmand-line invocation.

Unit Tests

Modifying bobbit can be a bit tricky because of the lack of tests. Fortunately, bobbit-0.2.x was redesigned to make it easier to test locally (ie. without an actual connection to a network). That said, there are only a few unit tests for some modules, and not unit tests for the package itself.

I would like to add unit tests for as many parts of bobbit as possible:

  • bobbit.bot
  • bobbit.config
  • bobbit.history
  • bobbit.message
  • bobbit.utils
  • bobbit.protocol.irc
  • bobbit.protocol.local
  • bobbit.protocol.slack
  • bobbit.modules.events
  • bobbit.modules.feeds
  • bobbit.modules.tweets

I would like to use a mixture of doctests and unittests.

Blank lines in USAGE produce unwanted behavior with !help

Overview

Calling !help on a module with a blank line in its USAGE produces unwanted behavior.

Okay, why?

When !help is called, Bobbit produces a message with message.copy() for each line in USAGE. When there is a blank line in USAGE, one of these calls will be message.copy(body=''). In the copy method, the body evaluates to false and the original body of the !help command is copied. Because message.copy() also copies the nick, Bobbit sees this message as a command invocation and replies to it.

Affected Modules

Note: this list was made with the following dope one-liner
find src/bobbit/modules -maxdepth 1 -type f | xargs -I {} sh -c "sed -ne \"/USAGE[^=]*=/,/'''/p\" {} | grep -qE '^$' && echo \$(basename {})"

archive.py
bodule.py
brainfuck.py
clap.py
copypasta.py
googletranslate.py
grab.py
humanity.py
karma.py
metar.py
mock.py
rpcs.py
weather.py
wttr.py

./bin/bobbit Does not work on MacOS as readlink has different behavior

Issue

Running the current script at ./bin/bobbit will fail on MacOS as the readlink for MacOS does not have a -f flag.

Potential Solution

Check uname for OS, if Darwin, use stat -f. If Linux, use readlink -f. I did not test on my Linux machine, so there is a possibility that simply changing readlink to stat will work for both OSes.

This isn't that important of an issue as I doubt anyone will run bobbit on MacOS for anything other than local dev.

Twitter Link Previews

Currently the title module will fetch the titles of various URLs. This only works for links that use the <title> HTML tag. Unfortunately, twitter links do not use that tag (at least not without JavaScript).

I would like for someone to enhance the title module to support twitter link previews. They can pull some code (or refactor) from the existing tweet module.

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.