File: skeleton.py

package info (click to toggle)
pyrcb2 0.6.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 932 kB
  • sloc: python: 7,385; makefile: 201; sh: 8
file content (35 lines) | stat: -rw-r--r-- 1,026 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python3
# This file contains the basic structure of a pyrcb2 bot.
# You can use this as a template.
#
# To the extent possible under law, the author(s) have dedicated all
# copyright and neighboring rights to this software to the public domain
# worldwide. This software is distributed without any warranty. See
# <http://creativecommons.org/publicdomain/zero/1.0/> for a copy of the
# CC0 Public Domain Dedication.

from pyrcb2 import IRCBot, Event
import asyncio


class MyBot:
    def __init__(self):
        # You can set log_communication to False to disable logging.
        self.bot = IRCBot(log_communication=True)
        self.bot.load_events(self)

    async def run(self):
        async def init():
            await self.bot.connect("irc.example.com", 6667)
            await self.bot.register("nickname")
            # More code here (optional)...
        await self.bot.run(init())


async def main():
    mybot = MyBot()
    await mybot.run()


if __name__ == "__main__":
    asyncio.run(main())