yaboli/test.py
Joscha c3fa1bf396 Add Client
Some functionality is yet to be tested.
2019-04-10 14:07:22 +00:00

38 lines
967 B
Python

# These tests are not intended as serious tests, just as small scenarios to
# give yaboli something to do.
import asyncio
import logging
import yaboli
FORMAT = "{asctime} [{levelname:<7}] <{name}> {funcName}(): {message}"
DATE_FORMAT = "%F %T"
handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter(
fmt=FORMAT,
datefmt=DATE_FORMAT,
style="{"
))
logger = logging.getLogger('yaboli')
logger.setLevel(logging.DEBUG)
logger.addHandler(handler)
class TestClient(yaboli.Client):
DEFAULT_NICK = "testbot"
async def started(self):
await self.join("test")
async def on_send(self, room, message):
if message.content == "!test":
await message.reply(f"You said {message.content!r}.")
msg1 = await room.send(f"{message.sender.atmention} said something.")
await msg1.reply("Yes, they really did.")
async def main():
tc = TestClient()
await tc.run()
asyncio.run(main())