-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add generated types #6
Conversation
return json.loads(response) | ||
parsed_response = json.loads(response) | ||
if "error" in parsed_response: | ||
raise Exception(parsed_response["error"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pass errors from the service through
examples/2_get_paid.py
Outdated
@@ -30,13 +31,17 @@ class Handler: | |||
async def __call__(self, bot, event): | |||
if event.type != EventType.WALLET: | |||
return | |||
if event.notification.statusDescription != PaymentStatusStr.COMPLETED: | |||
print(event.notification) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
|
||
logging.basicConfig(level=logging.DEBUG) | ||
|
||
|
||
async def handler(bot, event): | ||
if event.msg.content.type != ContentType.TEXT: | ||
if event.msg.content.type_name != chat1.MessageTypeStrings.TEXT.value: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chat1.MessageTypeStrings.TEXT.value
<-- this is pretty unfortunate for something as common as this '__'
return | ||
channel = event.msg.channel | ||
msg_id = event.msg.id | ||
await bot.chat.react(channel.replyable_dict(), msg_id, ":clap:") | ||
await bot.chat.react(channel, msg_id, ":clap:") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is nicer though :)
|
||
logging.basicConfig(level=logging.DEBUG) | ||
|
||
|
||
class Handler: | ||
async def __call__(self, bot, event): | ||
if event.msg.content.type != ContentType.TEXT: | ||
if event.msg.content.type_name != chat1.MessageTypeStrings.TEXT.value: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i feel like no one is actually going to do this. they'll just write "text"
here instead. 🙃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
14k lines changed. what could possibly go wrong??
Adds generated types to the python bot.
I tried to add type hinting where it makes sense, but we won't get full type coverage at least until lidatong/dataclasses-json#23 is resolved. We still get the big win of having all dataclasses defined.
All examples and tests should work. A few dataclass field names were changed in the process.
Note that chat methods now take dataclasses and input and return dataclasses as output, as opposed to dicts as we did previously.