diff --git a/examples/sasl.py b/examples/sasl.py new file mode 100644 index 0000000..5c22cb3 --- /dev/null +++ b/examples/sasl.py @@ -0,0 +1,29 @@ +import asyncio + +from irctokens import build, Line +from ircrobots import Bot as BaseBot +from ircrobots import ConnectionParams, SASLUserPass, Server + +class Bot(BaseBot): + async def line_read(self, server: Server, line: Line): + print(f"{server.name} < {line.format()}") + + async def line_send(self, server: Server, line: Line): + print(f"{server.name} > {line.format()}") + +async def main(): + bot = Bot() + + sasl_params = SASLUserPass("myusername", "invalidpassword") + params = ConnectionParams( + "MyNickname", + host = "chat.freenode.invalid", + port = 6697, + ssl = True, + sasl = sasl_params) + + await bot.add_server("freenode", params) + await bot.run() + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/examples/simple.py b/examples/simple.py index a852731..7e61dd4 100644 --- a/examples/simple.py +++ b/examples/simple.py @@ -1,13 +1,11 @@ import asyncio from irctokens import build, Line - -from ircrobots.bot import Bot as BaseBot -from ircrobots.server import ConnectionParams, Server +from ircrobots import Bot as BaseBot +from ircrobots import ConnectionParams, Server SERVERS = [ - ("freenode", "chat.freenode.net"), - ("tilde", "ctrl-c.tilde.chat") + ("freenode", "chat.freenode.invalid") ] class Bot(BaseBot): @@ -25,6 +23,8 @@ async def main(): for name, host in SERVERS: params = ConnectionParams("BitBotNewTest", host, 6697, True) await bot.add_server(name, params) + await bot.run() + if __name__ == "__main__": asyncio.run(main())