python-wechaty icon indicating copy to clipboard operation
python-wechaty copied to clipboard

Every class should be imported from `wechaty` repo

Open wj-Mcat opened this issue 5 years ago • 0 comments

Describe the bug As described in : https://github.com/wechaty/wechaty.js.org/pull/684#discussion_r588297559

There are some class that are also imported from wechaty-puppet package, so we should fix them.

To Reproduce

  • example code:
from wechaty import Wechaty
from wechaty_puppet import EventReadyPayload
import asyncio

# method one
async def on_ready(payload: EventReadyPayload):
    """Any initialization work can be put in here
    Args:
        payload (EventReadyPayload): ready data
    """
    print(f'receive ready event<{payload}>')

bot = Wechaty()
bot.on('ready', on_ready)
asyncio.run(bot.start())

# method two (suggested)

class MyBot(Wechaty):
    async def on_ready(self, payload: EventReadyPayload):
        """Any initialization work can be put in here
        Args:
            payload (EventReadyPayload): ready data
        """
        print(f'receive ready event<{payload}>')
        
asyncio.run(MyBot().start())

We should keep ths

Additional context

  • https://github.com/wechaty/wechaty.js.org/pull/684#discussion_r588297559
  • https://github.com/wechaty/python-wechaty-puppet/blob/master/src/wechaty_puppet/exceptions.py

wj-Mcat avatar Mar 07 '21 01:03 wj-Mcat