async def init_plugin(self, wechaty: Wechaty): """listen room-join events and say welcome""" async def on_room_join(room: Room, invitees: List[Contact], *args): if room.room_id in self.welcome_ids: for invited_contact in invitees: if invited_contact.contact_id in self.welcome_ids[ room.room_id]: await room.say( self.welcome_words, mention_ids=[invited_contact.contact_id]) self.welcome_ids[room.room_id].remove( invited_contact.contact_id) wechaty.on('room-join', on_room_join)
async def main(): """ Async Main Entry """ # # Make sure we have set WECHATY_PUPPET_SERVICE_TOKEN in the environment variables. # if 'WECHATY_PUPPET_SERVICE_TOKEN' not in os.environ: print(''' Error: WECHATY_PUPPET_SERVICE_TOKEN is not found in the environment variables You need a TOKEN to run the Java Wechaty. Please goto our README for details https://github.com/wechaty/python-wechaty-getting-started/#wechaty_puppet_service_token ''') global bot bot = Wechaty() global handler handler = MessageHandler(bot) bot.on('scan', on_scan) bot.on('login', on_login) bot.on('message', on_message) await bot.start() print('[Python Wechaty] Chatroom Assistant started.')
async def main(): """ Async Main Entry """ # # Make sure we have set WECHATY_PUPPET_SERVICE_TOKEN in the environment variables. # Learn more about services (and TOKEN) from https://wechaty.js.org/docs/puppet-services/ # # It is highly recommanded to use token like [paimon] and [wxwork]. # Those types of puppet_service are supported natively. # https://wechaty.js.org/docs/puppet-services/paimon # https://wechaty.js.org/docs/puppet-services/wxwork # # Replace your token here and umcommt that line, you can just run this python file successfully! # os.environ['token'] = 'puppet_paimon_your_token' # os.environ['token'] = 'puppet_wxwork_your_token' # if 'WECHATY_PUPPET_SERVICE_TOKEN' not in os.environ: print(''' Error: WECHATY_PUPPET_SERVICE_TOKEN is not found in the environment variables You need a TOKEN to run the Python Wechaty. Please goto our README for details https://github.com/wechaty/python-wechaty-getting-started/#wechaty_puppet_service_token ''') bot = Wechaty() bot.on('scan', on_scan) bot.on('login', on_login) bot.on('message', on_message) await bot.start() print('[Python Wechaty] Ding Dong Bot started.')
async def main(): bot = Wechaty() bot.on( 'scan', lambda status, qrcode, data: print('Scan QR Code to login: {}\nhttps://wechaty.js.org/qrcode/{}'. format(status, qrcode))) bot.on('login', lambda user: print('User {} logged in'.format(user))) bot.on('message', lambda message: print('Message: {}'.format(message))) await bot.start()
async def main(): # 确保我们在环境变量中设置了WECHATY_PUPPET_SERVICE_TOKEN if 'WECHATY_PUPPET_SERVICE_TOKEN' not in os.environ: print(''' Error: WECHATY_PUPPET_SERVICE_TOKEN is not found in the environment variables You need a TOKEN to run the Python Wechaty. Please goto our README for details https://github.com/wechaty/python-wechaty-getting-started/#wechaty_puppet_service_token ''') bot = Wechaty() bot.on('scan', on_scan) bot.on('login', on_login) bot.on('message', on_message) await bot.start() print('[Python Wechaty] Ding Dong Bot started.')
async def main(): """ Async Main Entry """ # # Make sure we have set WECHATY_PUPPET_HOSTIE_TOKEN in the environment variables. # if 'WECHATY_PUPPET_HOSTIE_TOKEN' not in os.environ: print(''' Error: WECHATY_PUPPET_HOSTIE_TOKEN is not found in the environment variables You need a TOKEN to run the Java Wechaty. Please goto our README for details https://github.com/wechaty/python-wechaty-getting-started/#wechaty_puppet_hostie_token ''') bot = Wechaty() bot.on('scan', on_scan) bot.on('login', on_login) bot.on('message', on_message) await bot.start() print('[Python Wechaty] Ding Dong Bot started.')
async def main(): bot = Wechaty() bot.on('message', on_message) await bot.start()
async def wechat(): global bot bot = Wechaty() bot.on('scan', on_scan) bot.on('login', on_login) bot.on('message', on_message) bot.on('room-join', on_room_join) bot.on('room-leave', on_room_leave) bot.on('logout', on_logout) bot.on('error', on_error) await bot.start()