https://github.com/minus7/asif
Asyncio-powered IRC Bot Framework
https://github.com/minus7/asif
asyncio irc library python-3-5
Last synced: 8 months ago
JSON representation
Asyncio-powered IRC Bot Framework
- Host: GitHub
- URL: https://github.com/minus7/asif
- Owner: minus7
- License: mit
- Created: 2016-06-17T16:35:14.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2022-06-14T18:57:05.000Z (over 3 years ago)
- Last Synced: 2025-06-16T10:21:34.370Z (8 months ago)
- Topics: asyncio, irc, library, python-3-5
- Language: Python
- Size: 42 KB
- Stars: 10
- Watchers: 0
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Asyncio-powered IRC Bot Framework
asif allows you to write an IRC bot that listens to commands in a **Flask**-like manner. Commands are functions, registered to the framework via decorators. Writing long-running background processes is possible because the whole framework is based on asyncio, just use `asyncio.ensure_future` on your function as usual.
Requires Python 3.6 for the **async/await** syntax.
## Example Code
```python
#!/usr/bin/env python3
from bot import Client, Channel
import asyncio
import re
bot = Client(
host="localhost",
port=6667,
user="bot",
realname="The Bot",
nick="TheBot",
)
@bot.on_connected()
async def connected():
await bot.join("#mychan")
@bot.on_message(re.compile("^!ping"))
async def pong(message):
"""
A simple ping/pong command. Replies to your !ping messages
"""
await message.reply("pong" + message.text[5:])
loop = asyncio.get_event_loop()
loop.run_until_complete(bot.run())
```
## License
This software is published under the MIT license, see [LICENSE](LICENSE)