Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kylef/irctk
A Python IRC client library
https://github.com/kylef/irctk
Last synced: 14 days ago
JSON representation
A Python IRC client library
- Host: GitHub
- URL: https://github.com/kylef/irctk
- Owner: kylef
- License: bsd-3-clause
- Created: 2014-08-23T13:49:48.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2024-11-30T00:10:12.000Z (about 2 months ago)
- Last Synced: 2024-12-31T18:16:10.004Z (25 days ago)
- Language: Python
- Homepage: http://irctk.readthedocs.org/en/latest/
- Size: 152 KB
- Stars: 7
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
irc-toolkit
===========An IRC client toolkit in Python.
## Installation
```bash
$ pip install irc-toolkit
```## Usage
There are a few parts of irc-toolkit, depending on your goals.
[`irctk.Message`](https://irctk.readthedocs.io/en/latest/message.html)
offers IRC message parsing,
[`irctk.Client`](https://irctk.readthedocs.io/en/latest/client.html) offers an
IRC client which handles connection/channel/nick tracking giving you a callback
based interface for IRC messages, for example:```python
#!/usr/bin/env pythonimport asyncio
import loggingimport irctk
class Bot:
async def connect(self, hostname, port=6697, secure=True):
client = irctk.Client()
client.delegate = self
await client.connect(hostname, port, secure)def irc_registered(self, client):
client.send('MODE', client.nick, '+B')
client.send('JOIN', '#test')def irc_private_message(self, client, nick, message):
if message == 'ping':
client.send('PRIVMSG', nick, 'pong')def irc_channel_message(self, client, nick, channel, message):
if message == 'ping':
client.send('PRIVMSG', channel, f'{nick}: pong')
elif message == 'quit':
client.quit()if __name__ == '__main__':
# Enable debug logging
logging.basicConfig(level='DEBUG')bot = Bot()
asyncio.run(bot.connect('irc.darkscience.net'))
```