Skip to content

Instantly share code, notes, and snippets.

@prologic
Created September 3, 2015 16:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prologic/5bebe30d81a6cd751d3b to your computer and use it in GitHub Desktop.
Save prologic/5bebe30d81a6cd751d3b to your computer and use it in GitHub Desktop.
Quick setup of kdb (IRC Bot)

Quick setup of kdb (IRC Bot

Create virtual environment

$ mkvirtualenv testkdb
Using real prefix '/usr'
New python executable in testkdb/bin/python
Installing setuptools, pip, wheel...done.

Install dependencies

kdb:

$ pip install git+https://github.com/prologic/kdb.git#egg=kdb
Collecting kdb from git+https://github.com/prologic/kdb.git#egg=kdb
  Cloning https://github.com/prologic/kdb.git to /tmp/pip-build-vcKa0g/kdb
Collecting Mako (from kdb)
  Downloading Mako-1.0.2.tar.gz (564kB)
    100% |████████████████████████████████| 565kB 675kB/s 
Collecting funcy (from kdb)
Collecting cidict (from kdb)
Collecting pymetar (from kdb)
  Using cached pymetar-0.20.tar.gz
Collecting pymills (from kdb)
Collecting procname (from kdb)
Collecting requests (from kdb)
  Using cached requests-2.7.0-py2.py3-none-any.whl
Collecting attrdict (from kdb)
Collecting pyenchant (from kdb)
  Using cached pyenchant-1.6.6-py2.py3-none-any.whl
Collecting html2text (from kdb)
  Using cached html2text-2015.6.21.tar.gz
Collecting simpleeval (from kdb)
  Using cached simpleeval-0.8.5.tar.gz
Collecting feedparser (from kdb)
  Using cached feedparser-5.2.1.tar.bz2
Collecting jsonrpc-requests (from kdb)
Collecting MarkupSafe>=0.9.2 (from Mako->kdb)
Collecting six (from attrdict->kdb)
  Using cached six-1.9.0-py2.py3-none-any.whl
Building wheels for collected packages: Mako, pymetar, html2text, simpleeval, feedparser
  Running setup.py bdist_wheel for Mako
  Stored in directory: /home/prologic/var/lib/pip/wheels/59/8e/ba/c9ad97efd22981088330ae7044e862c618627bb4ae69026c03
  Running setup.py bdist_wheel for pymetar
  Stored in directory: /home/prologic/var/lib/pip/wheels/43/8f/ae/6cf09d78e7e78fecb267714d3c3cd8e26b5e86b45075406853
  Running setup.py bdist_wheel for html2text
  Stored in directory: /home/prologic/var/lib/pip/wheels/91/51/63/ef6cc25895e9617dd32b3a5d72170f8ffce3f19dbaf7de0d4f
  Running setup.py bdist_wheel for simpleeval
  Stored in directory: /home/prologic/var/lib/pip/wheels/a0/95/0c/5485f64f79f2305976742e1f0135904ce9fc5e1e8b15c4d602
  Running setup.py bdist_wheel for feedparser
  Stored in directory: /home/prologic/var/lib/pip/wheels/13/92/a8/21287963f9d6e303776b30bc59d6c4a850ffd0d4fa980000df
Successfully built Mako pymetar html2text simpleeval feedparser
Installing collected packages: MarkupSafe, Mako, funcy, cidict, pymetar, pymills, procname, requests, six, attrdict, pyenchant, html2text, simpleeval, feedparser, jsonrpc-requests, kdb
  Running setup.py install for kdb
Successfully installed Mako-1.0.2 MarkupSafe-0.23 attrdict-2.0.0 cidict-0.1.1 feedparser-5.2.1 funcy-1.5 html2text-2015.6.21 jsonrpc-requests-0.2 kdb-1.0.3.dev68+ng23e284e procname-0.3 pyenchant-1.6.6 pymetar-0.20 pymills-3.4.2 requests-2.7.0 simpleeval-0.8.5 six-1.9.0
You are using pip version 7.1.1, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

circuits:

$ pip install git+https://github.com/circuits/circuits.git#egg=circuits
Collecting circuits from git+https://github.com/circuits/circuits.git#egg=circuits
  Cloning https://github.com/circuits/circuits.git to /tmp/pip-build-QvFLJy/circuits
Installing collected packages: circuits
  Running setup.py install for circuits
Successfully installed circuits-3.2.dev199+ng4384d61
You are using pip version 7.1.1, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

Run kdb!

$ kdb --help
usage: kdb [-h] [-v] [--config FILE] [--debug] [--daemon] [--verbose]
           [--errorlog FILE] [--pidfile FILE] [-c CHANNELS] [-n NICK]
           [-p PLUGINS]
           [HOST] [PORT]

positional arguments:
  HOST                  Host to connect to (default: irc.freenode.net)
  PORT                  Port to connect to (default: 6667)

optional arguments:
  -h, --help            show this help message and exit
  -v, --version         show program's version number and exit
  --config FILE         read configuration from FILE (default: None)
  --debug               enable debugging mode (default: False)
  --daemon              run as a background process (default: False)
  --verbose             enable verbose logging (default: False)
  --errorlog FILE       store debug and error logs in FILE (default: None)
  --pidfile FILE        write process id to FILE (default: kdb.pid)
  -c CHANNELS, --channel CHANNELS
                        Channel to join (multiple allowed, or comma separated)
                        (default: ['#circuits'])
  -n NICK, --nick NICK  Nickname to use (default: kdb)
  -p PLUGINS, --plugin PLUGINS
                        Plugin to load (multiple allowed) (default: ['core',
                        'channels', 'help', 'irc'])

Connect it to FreeNode!

$ kdb -n testkdb -c "#circuits" irc.freenode.net 6667
Loading plugins...
Registered Component: <Core/bot 11040:MainThread (queued=0) [S]>
Loaded plugin: Core
Registered Component: <Channels/bot 11040:MainThread (queued=0) [S]>
Loaded plugin: Channels
Registered Component: <Help/bot 11040:MainThread (queued=0) [S]>
Loaded plugin: Help
Registered Component: <IRC/bot 11040:MainThread (queued=0) [S]>
Loaded plugin: IRC
@prologic
Copy link
Author

prologic commented Sep 3, 2015

Here's a sample configuration for logging a channel:

kdb.ini:

[globals]
debug = True
host = 'irc.freenode.net'
port = 6667
nick = 'kdb'
channels = ['#circuits']
plugins = ['core', 'irc', 'channels', 'ctcp', 'logging']

[logging]
logdir = '/var/www/irclogs'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment