Git Product home page Git Product logo

ircbot's Introduction

ircbot

Small bloated IRC bot ๐Ÿค–

Tested with irc.snoonet.org

Features

  • Automatic reconnect on connection loss
  • Live injection of new responses at runtime
  • Persistent user database
  • Variable command prefix
  • Easy new command addition
    • As simple as creating a new subclass in command.py
  • Many built-in commands
  • Dynamic overly-long message splitting (Thanks primitve IRC protocol)

Usage

Start it once on your server and use the commands within your IRC client.

Server

./start.py

Configure settings (nick, server, channel, command prefix, etc.) in .env.
(This file isn't read but the environment variables must be set. Source them via e.g. export $(cat .env | xargs).)

Client

\help
\cmds
\about
\uptime
\date
\time
\sentiment <text>|<user>
\lastmessage <user>
\words <user>
\wordcloud <user>
...

Only the last 1000 messages of users are stored. This parameter can be changed.

Container

# Prepare
docker pull ghcr.io/lolei/ircbot:<tag>
# or
docker build -f Containerfile . -t ghcr.io/lolei/ircbot:<tag>

# Run
docker run --env-file .env.local -v $(pwd)/storage:/app/storage ghcr.io/lolei/ircbot:<tag>

Deployment

The bot can either be run from the git repo itself, as a container with e.g. docker or docker-compose, or within Kubernetes.
It has been deployed for a long time (> 1 year) on a Raspberry Pi (therefore it works on ARM, which is made sure by some version requirements), and it is currently deployed on Kubernetes. (See k8s/)

Example User Word Cloud

ircbot's People

Contributors

dependabot[bot] avatar lolei avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

ircbot's Issues

Fix message receive bug

So PING's aren't missed sometimes. Auto-reconnect takes care of that but still.

Idea:

  • Split incoming socket bytes at the IRC line breaks, return multiple messages.
    • More advanced: Thread for reading the incoming stream and save it into a temp variable until it sees a CRLF, and only then process that message. Saves rare issue of message being split up between two reads.
  • Change buffer size to new protocol standard.
  • Change line break separator to \r\n, is wrong way round rn.

Change misleading top words message

The current message starts with:

Top words (of last 1000) for...

This makes it seem it's only out of the last 1000 words, but in actuality it's the last 1000 messages.

Raspberry Pi numpy

Installation of requirements on Raspberry Pi requires pip3 uninstall numpy afterwards and using the apt package.

make muh_bot shrug

simply as the title states. just do it. don't let your dreams be dreams.

Running \words on someone without words in the db crashes it

/usr/lib/python3/dist-packages/sklearn/externals/joblib.py:1: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp
Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.7/threading.py", line 865, in run
    self._target(*self._args, **self._kwargs)
  File "/home/pi/git/ircbot/ircbot.py", line 246, in receive_and_parse_msg_loop
    self.receive_and_parse_msg()
  File "/home/pi/git/ircbot/ircbot.py", line 251, in receive_and_parse_msg
    self.receive_and_parse_irc_msg(ircmsg)
  File "/home/pi/git/ircbot/ircbot.py", line 313, in receive_and_parse_irc_msg
    self.execute_command(name, message)
  File "/home/pi/git/ircbot/ircbot.py", line 382, in execute_command
    self.commands_[command_name].execute([name, message])
  File "/home/pi/git/ircbot/command.py", line 247, in execute
    bow = cv.fit_transform(msgs)
  File "/usr/lib/python3/dist-packages/sklearn/feature_extraction/text.py", line 1032, in fit_transform
    self.fixed_vocabulary_)
  File "/usr/lib/python3/dist-packages/sklearn/feature_extraction/text.py", line 961, in _count_vocab
    raise ValueError("empty vocabulary; perhaps the documents only"
ValueError: empty vocabulary; perhaps the documents only contain stop words

Message split error

Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.5/threading.py", line 862, in run
    self._target(*self._args, **self._kwargs)
  File "/home/pi/git/ircbot/ircbot.py", line 247, in receive_and_parse_msg_loop
    self.receive_and_parse_msg()
  File "/home/pi/git/ircbot/ircbot.py", line 252, in receive_and_parse_msg
    self.receive_and_parse_irc_msg(ircmsg)
  File "/home/pi/git/ircbot/ircbot.py", line 263, in receive_and_parse_irc_msg
    message = ircmsg.split('PRIVMSG', 1)[1].split(':', 1)[1]
IndexError: list index out of range

Possibly occurs due to rare split-up message between socket recvs.

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.