2013-03-14 23:27:33 +02:00
|
|
|
Supybot Irccat Plugin
|
|
|
|
=====================
|
|
|
|
This is a plugin for the IRC bot Supybot that introduces the ability to
|
2013-03-15 13:32:31 +02:00
|
|
|
listen to a TCP port and relay incoming text to one or more IRC channels,
|
|
|
|
using some primitive security mechanisms.
|
2013-03-14 23:27:33 +02:00
|
|
|
|
2013-03-19 07:40:02 +02:00
|
|
|
I have used it to integrate supybot with a Jenkins build server (jenkins
|
|
|
|
built-in irc plugin sucks). The build script send messages when build
|
|
|
|
is completed, and we find in the irc channel:
|
|
|
|
|
|
|
|
Jenkins: build OK. http://jenkins.cloud.fedoraproject.org/job/FedoraReview_F17_py2.7
|
|
|
|
|
|
|
|
Obviously, the plugin is generic and could be used to a variety of things.
|
|
|
|
It's similar to the notify plugin, but does not require the client to be on
|
|
|
|
the same host as the supybot server.
|
|
|
|
|
2013-03-19 10:30:59 +02:00
|
|
|
Here is also a simple script which can be used to send data to a server
|
|
|
|
running subybot with irccat
|
|
|
|
|
2013-03-14 23:27:33 +02:00
|
|
|
Dependencies
|
|
|
|
------------
|
2013-03-15 13:32:31 +02:00
|
|
|
- python-twisted (tested with 12.1)
|
|
|
|
- supybot (tested with 0.83.4)
|
2013-03-17 15:58:27 +02:00
|
|
|
- ncat for unit tests
|
2013-03-14 23:27:33 +02:00
|
|
|
|
|
|
|
Getting started
|
|
|
|
---------------
|
|
|
|
* Refer to the supybot documentation to install supybot and configure
|
|
|
|
your server e. g., using supybot-wizard. Verify that you can start and
|
|
|
|
contact your bot.
|
|
|
|
|
|
|
|
* Unpack the plugin into the plugins directory (created by
|
|
|
|
supybot-wizard):
|
|
|
|
```
|
|
|
|
$ cd plugins
|
|
|
|
$ git clone https://github.com/leamas/supybot-irccat Irccat
|
2013-03-29 05:13:43 +02:00
|
|
|
$ cd Irccat
|
|
|
|
$ git-hooks/post-commit
|
2013-03-14 23:27:33 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
* Identify yourself for the bot in a *private window*. Creating user +
|
|
|
|
password is part of the supybot-wizard process.
|
|
|
|
```
|
|
|
|
<leamas> identify al my-secret-pw
|
|
|
|
<al-bot-test> The operation succeeded.
|
|
|
|
```
|
2013-03-19 10:30:59 +02:00
|
|
|
|
|
|
|
* Load plugin and use `list` to verify that the plugin is loaded (still in
|
|
|
|
private window):
|
|
|
|
```
|
|
|
|
<leamas> load Irccat
|
|
|
|
<al-bot-test> The operation succeeded.
|
|
|
|
<leamas> list
|
|
|
|
<al-bot-test> leamas: Admin, Channel, Config, Irccat, Owner, and User
|
|
|
|
```
|
|
|
|
|
2013-03-14 23:27:33 +02:00
|
|
|
* Define the port you want to use as listener port (still in private window):
|
|
|
|
```
|
|
|
|
<leamas> config plugins.irccat.port 12345
|
|
|
|
<al-bot-test> The operation succeeded.
|
|
|
|
```
|
|
|
|
|
|
|
|
* In order to use irccat you need to define a section. A section has a name,
|
|
|
|
a password and a list of channels to feed. Define your first section
|
|
|
|
named foo with password pwfoo sending data to the channel #al-bot-test:
|
|
|
|
```
|
2013-03-15 10:08:43 +02:00
|
|
|
<leamas> sectiondata foo pwfoo #al-bot-test
|
2013-03-14 23:27:33 +02:00
|
|
|
<al-bot-test> leamas: The operation succeeded.
|
|
|
|
```
|
|
|
|
|
2013-04-22 21:44:01 +03:00
|
|
|
* By default irccat will use *notice* messages, but some users will prefer
|
|
|
|
to use *privmsg* messages. To do so (still in private window):
|
|
|
|
```
|
|
|
|
<leamas> config plugins.irccat.privmsg True
|
|
|
|
<al-bot-test> The operation succeeded.
|
|
|
|
```
|
|
|
|
|
2013-03-18 10:27:47 +02:00
|
|
|
* Your bot must join the channel(s) you want to feed. Do this with
|
|
|
|
`join`, still in private window:
|
|
|
|
```
|
|
|
|
<leamas> join #al-bot-test
|
|
|
|
```
|
|
|
|
|
2013-03-19 10:30:59 +02:00
|
|
|
Use the companion script to send a message...
|
2013-03-14 23:27:33 +02:00
|
|
|
```
|
2013-03-19 10:30:59 +02:00
|
|
|
$ plugins/Irccat/irccat localhost -s 12345 foo footext to show
|
|
|
|
pwfoo
|
2013-03-14 23:27:33 +02:00
|
|
|
$
|
|
|
|
```
|
2013-03-19 10:30:59 +02:00
|
|
|
|
|
|
|
...and you will see a line in the selected channel:
|
2013-03-14 23:27:33 +02:00
|
|
|
```
|
|
|
|
*al-bot-test* footext to show
|
|
|
|
```
|
|
|
|
|
|
|
|
Configuration
|
|
|
|
-------------
|
|
|
|
|
2013-03-15 10:08:43 +02:00
|
|
|
The configuration is done completely in IRC. There are general settings
|
|
|
|
and section specific ones. To see the general settings:
|
2013-03-14 23:27:33 +02:00
|
|
|
```
|
|
|
|
@config list plugins.irccat
|
2013-03-15 10:08:43 +02:00
|
|
|
leamas: port, public, and sectionspath
|
2013-03-14 23:27:33 +02:00
|
|
|
```
|
|
|
|
|
2013-03-15 10:08:43 +02:00
|
|
|
Each general setting has help info and could be inspected and set using
|
|
|
|
the config plugin, see it's documents. Quick crash course using port as
|
|
|
|
example:
|
|
|
|
|
2013-03-14 23:27:33 +02:00
|
|
|
* Getting help: `@config help plugins.irccat.port`
|
|
|
|
* See actual value: `@config plugins.irccat.port`
|
2013-03-15 10:08:43 +02:00
|
|
|
* Setting value: `@config plugins.irccat.port 6060`
|
|
|
|
|
|
|
|
The `public`, option is internal, please don't touch.
|
2013-03-14 23:27:33 +02:00
|
|
|
|
2013-03-15 10:08:43 +02:00
|
|
|
NOTE! After modifying the variables use `@reload Irccat` to make them
|
|
|
|
effective.
|
2013-03-14 23:27:33 +02:00
|
|
|
|
|
|
|
The available sections can be listed using
|
|
|
|
```
|
2013-03-15 10:08:43 +02:00
|
|
|
<leamas> sectionlist
|
|
|
|
<al-bot-test> yngve ivar
|
2013-03-14 23:27:33 +02:00
|
|
|
```
|
|
|
|
|
2013-03-18 11:02:09 +02:00
|
|
|
To see actual settings (password is encrypted):
|
2013-03-14 23:27:33 +02:00
|
|
|
```
|
2013-03-15 10:08:43 +02:00
|
|
|
@sectionshow ivar
|
2013-03-18 11:02:09 +02:00
|
|
|
leamas: fjdk;fdsa #al-bot-test
|
2013-03-14 23:27:33 +02:00
|
|
|
```
|
|
|
|
|
2013-03-18 11:02:09 +02:00
|
|
|
These settings can be manipulated using `sectiondata` as explained in Getting Started.
|
2013-03-14 23:27:33 +02:00
|
|
|
|
|
|
|
|
|
|
|
Input line format
|
|
|
|
-----------------
|
|
|
|
Each line read from the input port should have the following format:
|
|
|
|
|
|
|
|
<name>;<password>;<any text>
|
|
|
|
|
|
|
|
- name: The name of a configuration section i. e., a value from
|
2013-03-15 10:08:43 +02:00
|
|
|
`@sectionlist`.
|
2013-03-18 11:02:09 +02:00
|
|
|
- password: As defined when using `sectiondata`, see below. Stored
|
|
|
|
passwords are encrypted and cannot be displayed, so you need to
|
|
|
|
remember these.
|
2013-03-14 23:27:33 +02:00
|
|
|
- The text after the second ';' is sent verbatim to the channel(s) listed
|
|
|
|
in the section.
|
|
|
|
|
2013-03-15 13:32:31 +02:00
|
|
|
Unparsable lines are logged but otherwise silently dropped. Blacklisted
|
|
|
|
clients are not even logged.
|
2013-03-14 23:27:33 +02:00
|
|
|
|
|
|
|
|
|
|
|
Command List
|
|
|
|
------------
|
2013-03-19 07:40:02 +02:00
|
|
|
Plugin commands:
|
|
|
|
|
2013-03-15 10:08:43 +02:00
|
|
|
* `sectiondata`: Takes a section name, a password and a comma-separated
|
|
|
|
list of channels to feed. Creates section if it doesn't exist.
|
2013-03-14 23:27:33 +02:00
|
|
|
|
2013-03-15 10:08:43 +02:00
|
|
|
* `sectionkill`: Delete a section given it's name.
|
2013-03-14 23:27:33 +02:00
|
|
|
|
2013-03-15 10:08:43 +02:00
|
|
|
* `sectionlist`: List available sections.
|
2013-03-14 23:27:33 +02:00
|
|
|
|
2013-03-18 11:02:09 +02:00
|
|
|
* `sectionshow`: Show encrypted password and channels for a section.
|
2013-03-14 23:27:33 +02:00
|
|
|
|
2013-03-15 13:44:52 +02:00
|
|
|
* `sectionhelp`: Show help URL i. e., this file.
|
|
|
|
|
2013-03-19 10:30:59 +02:00
|
|
|
Other useful supybot commands:
|
2013-03-19 07:40:02 +02:00
|
|
|
|
2013-03-18 10:27:47 +02:00
|
|
|
* `config plugins.irccat.port`: Show the TCP port irccat listens to.
|
2013-03-14 23:27:33 +02:00
|
|
|
|
2013-03-19 07:40:02 +02:00
|
|
|
* `reload Irccat`: Make changes in e. g., plugins.irccat.port effective
|
|
|
|
|
|
|
|
* `join #channel`: Make bot join a channel, required when feeding one.
|
|
|
|
|
2013-03-19 10:30:59 +02:00
|
|
|
Scripts:
|
|
|
|
|
|
|
|
* irccat [-s|-h] \<host\> \<port\> \<section\> \<text...\>.
|
|
|
|
Sends \<text..\>. to a supybot \<host\> running irccat on \<port\> using the
|
|
|
|
given \<section\>. Reads password from stdin when using [-s] Use
|
|
|
|
-h/--help for details.
|
|
|
|
|
2013-03-14 23:27:33 +02:00
|
|
|
|
2013-03-15 13:32:31 +02:00
|
|
|
Security
|
|
|
|
--------
|
|
|
|
Irc servers are normally not Fort Knox, so this is not the place for ssl or
|
|
|
|
2-factor authentication. That said, leaving a TCP port open as a relay to
|
|
|
|
irc channel(s) certainly requires some precaution. The steps here are:
|
|
|
|
|
|
|
|
- The client must know the section and it's password as described above.
|
2013-03-18 10:27:47 +02:00
|
|
|
- Managing passwords and channels requires 'owner' capability in irc.
|
2013-03-19 10:30:59 +02:00
|
|
|
- Password cleartext is not saved anywhere.
|
2013-03-15 13:32:31 +02:00
|
|
|
- Clients which repeatedly fails to send correct data are blacklisted for a
|
|
|
|
while.
|
|
|
|
|
|
|
|
|
2013-03-18 10:27:47 +02:00
|
|
|
Static checking and unit tests.
|
|
|
|
-------------------------------
|
2013-03-14 23:27:33 +02:00
|
|
|
|
|
|
|
pep8 (in the Git directory):
|
|
|
|
```
|
|
|
|
$ pep8 --config pep8.conf . > pep8.log
|
|
|
|
```
|
|
|
|
pylint: (in the Git directory):
|
|
|
|
```
|
|
|
|
$ pylint --rcfile pylint.conf \*.py > pylint.log
|
|
|
|
```
|
2013-03-17 15:58:27 +02:00
|
|
|
Unit tests:
|
|
|
|
```
|
|
|
|
$ supybot-test plugins/Irccat
|
|
|
|
```
|
|
|
|
|