Skip to content

Commit 5bebefb

Browse files
committed
Wow. Why didn't I commit this in smaller parts?
Lots of changes. This started as a small change to split the classes in ib3 into a few sub-modules. That led to fixing up the generated documentation a bit. Then I just kept running in a circle of refactoring, updating docs, and creating new sub-modules. The neat thing though is that the library is looking pretty useful and the example saslbot.py class does things that none of the live bots I started extracting this from can do yet.
1 parent 6d59a20 commit 5bebefb

File tree

12 files changed

+496
-298
lines changed

12 files changed

+496
-298
lines changed

README.rst

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,34 @@ IRC Bot Behavior Bundle (IB3)
44

55
IRC bot framework using mixins to provide commonly desired functionality.
66

7-
Mixins
8-
======
9-
* DisconnectOnError: Handle ERROR message by logging and disconnecting
10-
* FreenodePasswdAuth: Authenticate with NickServ before joining channels
11-
* Ping: Add checks for connection liveness using PING commands
12-
* RejoinOnBan: Handle ERR_BANNEDFROMCHAN by attempting to rejoin channel
13-
* RejoinOnKick: Handle KICK by attempting to rejoin channel
7+
About
8+
=====
9+
The `irc`_ python library's ``irc.bot.SingleServerIRCBot`` provides a nice
10+
base for making a new bot, but there are many common tasks needed by a robust
11+
bot that it does not handle out of the box. IB3 collects some commonly desired
12+
behaviors for a bot as `mixin`_ classes that can be used via `multiple
13+
inheritance`_::
14+
15+
from ib3 import Bot
16+
from ib3.auth import SASL
17+
from ib3.connections import SSL
18+
from ib3.mixins import DisconnectOnError
19+
20+
class TestBot(SASL, SSL, DisconnectOnError, Bot):
21+
pass
1422

1523
License
1624
=======
17-
`GNU GPLv3+`_
25+
IB3 is licensed under the `GNU GPLv3+`_ license.
1826

19-
Some code and much inspiration taken from:
20-
21-
* `Adminbot`_
22-
* `Jouncebot`_
23-
* `Stashbot`_
27+
Credits
28+
=======
29+
Some code and much inspiration taken from Wikimedia irc bots `Adminbot`_,
30+
`Jouncebot`_, and `Stashbot`_.
2431

32+
.. _irc: https://pypi.org/project/irc/
33+
.. _mixin: https://en.wikipedia.org/wiki/Mixin
34+
.. _multiple inheritance: https://docs.python.org/3/tutorial/classes.html#multiple-inheritance
2535
.. _GNU GPLv3+: https://www.gnu.org/copyleft/gpl.html
2636
.. _Adminbot: https://phabricator.wikimedia.org/diffusion/ODAC/
2737
.. _Jouncebot: https://phabricator.wikimedia.org/diffusion/GJOU/

doc/about.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.. include:: ../README.rst

doc/conf.py

100755100644
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,16 @@
1515

1616
extensions = [
1717
'sphinx.ext.autodoc',
18+
'sphinx.ext.intersphinx',
1819
'sphinx.ext.viewcode',
1920
]
2021

21-
# General information about the project.
22+
intersphinx_mapping = {
23+
'python': ('https://docs.python.org/3', None),
24+
'irc': ('https://python-irc.readthedocs.io/en/stable/', None),
25+
}
2226

27+
# General information about the project.
2328
root = os.path.join(os.path.dirname(__file__), '..')
2429
setup_script = os.path.join(root, 'setup.py')
2530
fields = ['--name', '--version', '--author']

doc/ib3.rst

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
ib3 package
2+
===========
3+
4+
Module contents
5+
---------------
6+
7+
.. automodule:: ib3
8+
:members:
9+
:special-members: __init__
10+
:private-members:
11+
:show-inheritance:
12+
13+
Submodules
14+
----------
15+
16+
ib3.auth module
17+
---------------
18+
19+
.. automodule:: ib3.auth
20+
:members:
21+
:special-members: __init__
22+
:private-members:
23+
:show-inheritance:
24+
25+
ib3.connection module
26+
---------------------
27+
28+
.. automodule:: ib3.connection
29+
:members:
30+
:special-members: __init__
31+
:private-members:
32+
:show-inheritance:
33+
34+
35+
ib3.mixins module
36+
---------------------
37+
38+
.. automodule:: ib3.mixins
39+
:members:
40+
:special-members: __init__
41+
:private-members:
42+
:show-inheritance:
43+
44+
45+
ib3.nick module
46+
---------------------
47+
48+
.. automodule:: ib3.nick
49+
:members:
50+
:special-members: __init__
51+
:private-members:
52+
:show-inheritance:

doc/index.rst

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1+
IRC Bot Behavior Bundle (IB3) Documentation
2+
===========================================
3+
14
.. toctree::
25
:maxdepth: 2
36

4-
.. include:: ../README.rst
5-
6-
ib3 package
7-
===========
8-
9-
.. automodule:: ib3
10-
:members:
11-
:undoc-members:
12-
:show-inheritance:
13-
:noindex:
7+
about
8+
ib3

examples/nickserv.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@
2020
import logging
2121

2222
from ib3 import Bot
23-
from ib3 import DisconnectOnError
24-
from ib3 import FreenodePasswdAuth
25-
from ib3 import Ping
26-
from ib3 import RejoinOnBan
27-
from ib3 import RejoinOnKick
23+
from ib3.auth import NickServ
2824

2925

3026
logging.basicConfig(
@@ -35,10 +31,7 @@
3531
logging.captureWarnings(True)
3632

3733

38-
class TestBot(
39-
FreenodePasswdAuth, Ping, DisconnectOnError,
40-
RejoinOnBan, RejoinOnKick, Bot
41-
):
34+
class TestBot(NickServ, Bot):
4235
pass
4336

4437

examples/saslbot.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
import irc.strings
2323

2424
import ib3
25+
import ib3.auth
26+
import ib3.connection
27+
import ib3.nick
2528

2629

2730
logging.basicConfig(
@@ -34,8 +37,8 @@
3437
logger = logging.getLogger('saslbot')
3538

3639

37-
class SaslBot(ib3.SASL, ib3.SSL, ib3.Bot):
38-
"""Example bot showing use of SASL auth and SSL encryption."""
40+
class SaslBot(ib3.auth.SASL, ib3.nick.Regain, ib3.connection.SSL, ib3.Bot):
41+
"""Example bot showing use of SASL auth, REGAIN, and SSL encryption."""
3942
def on_privmsg(self, conn, event):
4043
self.do_command(conn, event, event.arguments[0])
4144

0 commit comments

Comments
 (0)