add async hello

This commit is contained in:
randomuser 2021-08-03 22:42:41 -05:00
parent 2f7d632287
commit 5ad8f7d130
1 changed files with 7 additions and 2 deletions

View File

@ -6,7 +6,7 @@ from ircrobots import Server as BaseServer
from ircrobots import ConnectionParams from ircrobots import ConnectionParams
SERVERS = [ SERVERS = [
("freenode", "chat.freenode.invalid") ("beep", "beepboop.systems")
] ]
class Server(BaseServer): class Server(BaseServer):
@ -15,8 +15,13 @@ class Server(BaseServer):
if line.command == "001": if line.command == "001":
print(f"connected to {self.isupport.network}") print(f"connected to {self.isupport.network}")
await self.send(build("JOIN", ["#testchannel"])) await self.send(build("JOIN", ["#testchannel"]))
task = asyncio.create_task(self.async_hello())
await self.send(build("PRIVMSG", ["#testchannel", "task started"]))
async def line_send(self, line: Line): async def line_send(self, line: Line):
print(f"{self.name} > {line.format()}") print(f"{self.name} > {line.format()}")
async def async_hello(self):
await asyncio.sleep(10)
self.send(build("PRIVMSG", ["#testchannel", "hello"]))
class Bot(BaseBot): class Bot(BaseBot):
def create_server(self, name: str): def create_server(self, name: str):
@ -25,7 +30,7 @@ class Bot(BaseBot):
async def main(): async def main():
bot = Bot() bot = Bot()
for name, host in SERVERS: for name, host in SERVERS:
params = ConnectionParams("BitBotNewTest", host, 6697, True) params = ConnectionParams("BitBotNewTest", host, 6667, False)
await bot.add_server(name, params) await bot.add_server(name, params)
await bot.run() await bot.run()