Clean up
This commit is contained in:
parent
903ba4973b
commit
1d66b3a518
4 changed files with 1 additions and 67 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -1,5 +1,5 @@
|
|||
# python stuff
|
||||
*/__pycache__/
|
||||
__pycache__/
|
||||
|
||||
# venv stuff
|
||||
bin/
|
||||
|
|
|
|||
26
example.py
26
example.py
|
|
@ -1,26 +0,0 @@
|
|||
import yyb
|
||||
|
||||
class MyClient(yyb.Client):
|
||||
async def on_join(self, room):
|
||||
await room.say("Hello!")
|
||||
|
||||
async def on_message(self, message):
|
||||
if message.content == "reply to me"):
|
||||
reply = await message.reply("reply")
|
||||
await reply.reply("reply to the reply")
|
||||
await message.room.say("stuff going on")
|
||||
|
||||
elif message.content == "hey, join &test!":
|
||||
# returns room in phase 3, or throws JoinException
|
||||
room = await self.join("test")
|
||||
if room:
|
||||
room.say("hey, I joined!")
|
||||
else:
|
||||
message.reply("didn't work :(")
|
||||
|
||||
async def before_part(self, room):
|
||||
await room.say("Goodbye!")
|
||||
|
||||
# Something like this, I guess. It's still missing password fields though.
|
||||
c = MyClient("my:bot:")
|
||||
c.run("test", "bots")
|
||||
39
info.txt
39
info.txt
|
|
@ -1,39 +0,0 @@
|
|||
Signature of a normal function:
|
||||
|
||||
def a(b: int, c: str) -> bool:
|
||||
pass
|
||||
|
||||
a # type: Callable[[int, str], bool]
|
||||
|
||||
Signature of an async function:
|
||||
|
||||
async def a(b: int, c: str) -> bool:
|
||||
pass
|
||||
|
||||
a # type: Callable[[int, str], Awaitable[bool]]
|
||||
|
||||
|
||||
|
||||
Enable logging (from the websockets docs):
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger('websockets')
|
||||
logger.setLevel(logging.INFO)
|
||||
logger.addHandler(logging.StreamHandler())
|
||||
|
||||
Output format: See https://docs.python.org/3/library/logging.html#formatter-objects
|
||||
|
||||
Example formatting:
|
||||
|
||||
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)
|
||||
|
|
@ -1 +0,0 @@
|
|||
websockets==7.0
|
||||
Loading…
Add table
Add a link
Reference in a new issue