How to use register_event method in Lemoncheesecake

Best Python code snippet using lemoncheesecake

46085___init__.py

Source:46085___init__.py Github

copy

Full Screen

...187 if self.config.show_events:188 self.event_manager.event_report()189 sys.exit(1)190 # Registering event:191 # self.event_manager.register_event("location", parameters=['lat', 'lng'])192 #193 # Emitting event should be enough to add logging and send websocket194 # message: :195 # self.event_manager.emit('location', 'level'='info', data={'lat': 1, 'lng':1}),196 def _register_events(self):197 self.event_manager.register_event(198 'location_found',199 parameters=('position', 'location')200 )201 self.event_manager.register_event('api_error')202 self.event_manager.register_event('config_error')203 self.event_manager.register_event('captcha')204 self.event_manager.register_event('login_started')205 self.event_manager.register_event('login_failed')206 self.event_manager.register_event('login_successful')207 self.event_manager.register_event('niantic_warning')208 self.event_manager.register_event('set_start_location')209 self.event_manager.register_event('load_cached_location')210 self.event_manager.register_event('location_cache_ignored')211 self.event_manager.register_event('debug')212 self.event_manager.register_event('refuse_to_sit')213 self.event_manager.register_event('reset_destination')214 self.event_manager.register_event('new_destination')215 self.event_manager.register_event('moving_to_destination')216 self.event_manager.register_event('arrived_at_destination')217 self.event_manager.register_event('staying_at_destination')218 self.event_manager.register_event('buddy_pokemon', parameters=('pokemon', 'iv', 'cp'))219 self.event_manager.register_event('buddy_reward', parameters=('pokemon', 'family', 'candy_earned', 'candy'))220 self.event_manager.register_event('buddy_walked', parameters=('pokemon', 'distance_walked', 'distance_needed'))221 # ignore candy above threshold222 self.event_manager.register_event(223 'ignore_candy_above_thresold',224 parameters=(225 'name',226 'amount',227 'threshold'228 )229 )230 self.event_manager.register_event('followpath_output_disabled')231 self.event_manager.register_event(232 'position_update',233 parameters=(234 'current_position',235 'last_position',236 'distance', # optional237 'distance_unit' # optional238 )239 )240 self.event_manager.register_event(241 'path_lap_update',242 parameters=(243 'number_lap',244 'number_lap_max'245 )246 )247 self.event_manager.register_event(248 'path_lap_end',249 parameters=(250 'duration',251 'resume'252 )253 )254 self.event_manager.register_event('location_cache_error')255 self.event_manager.register_event('security_check')256 self.event_manager.register_event('bot_start')257 self.event_manager.register_event('bot_exit')258 self.event_manager.register_event('bot_interrupted')259 # sleep stuff260 self.event_manager.register_event(261 'next_sleep',262 parameters=(263 'time',264 'duration'265 )266 )267 self.event_manager.register_event(268 'bot_sleep',269 parameters=(270 'time_hms',271 'wake'272 )273 )274 # random pause275 self.event_manager.register_event(276 'next_random_pause',277 parameters=(278 'time',279 'duration'280 )281 )282 self.event_manager.register_event(283 'bot_random_pause',284 parameters=(285 'time_hms',286 'resume'287 )288 )289 # recycle stuff290 self.event_manager.register_event(291 'next_force_recycle',292 parameters=(293 'time'294 )295 )296 self.event_manager.register_event('force_recycle')297 # random alive pause298 self.event_manager.register_event(299 'next_random_alive_pause',300 parameters=(301 'time',302 'duration'303 )304 )305 self.event_manager.register_event(306 'bot_random_alive_pause',307 parameters=(308 'time_hms',309 'resume'310 )311 )312 # fort stuff313 self.event_manager.register_event(314 'spun_fort',315 parameters=(316 'fort_id',317 'latitude',318 'longitude'319 )320 )321 self.event_manager.register_event(322 'lured_pokemon_found',323 parameters=(324 'fort_id',325 'fort_name',326 'encounter_id',327 'latitude',328 'longitude'329 )330 )331 self.event_manager.register_event(332 'moving_to_hunter_target',333 parameters=(334 'target_name',335 'distance'336 )337 )338 self.event_manager.register_event(339 'moving_to_fort',340 parameters=(341 'fort_name',342 'target_type',343 'distance'344 )345 )346 self.event_manager.register_event(347 'moving_to_lured_fort',348 parameters=(349 'fort_name',350 'target_type',351 'distance',352 'lure_distance'353 )354 )355 self.event_manager.register_event(356 'spun_pokestop',357 parameters=(358 'pokestop', 'exp', 'items', 'stop_kind', 'spin_amount_now'359 )360 )361 self.event_manager.register_event(362 'pokestop_empty',363 parameters=('pokestop',)364 )365 self.event_manager.register_event(366 'pokestop_out_of_range',367 parameters=('pokestop',)368 )369 self.event_manager.register_event(370 'pokestop_on_cooldown',371 parameters=('pokestop', 'minutes_left')372 )373 self.event_manager.register_event(374 'unknown_spin_result',375 parameters=('status_code',)376 )377 self.event_manager.register_event('pokestop_searching_too_often')378 self.event_manager.register_event('arrived_at_fort')379 # pokemon stuff380 self.event_manager.register_event(381 'catchable_pokemon',382 parameters=(383 'pokemon_id',384 'spawn_point_id',385 'encounter_id',386 'latitude',387 'longitude',388 'expiration_timestamp_ms',389 'pokemon_name'390 )391 )392 self.event_manager.register_event(393 'incensed_pokemon_found',394 parameters=(395 'pokemon_id',396 'encounter_id',397 'encounter_location',398 'latitude',399 'longitude'400 )401 )402 self.event_manager.register_event(403 'pokemon_appeared',404 parameters=(405 'pokemon',406 'ncp',407 'cp',408 'iv',409 'iv_display',410 'encounter_id',411 'latitude',412 'longitude',413 'pokemon_id',414 'shiny'415 )416 )417 self.event_manager.register_event('no_pokeballs')418 self.event_manager.register_event('enough_ultraballs')419 self.event_manager.register_event('lure_success')420 self.event_manager.register_event('lure_failed')421 self.event_manager.register_event('lure_not_enough')422 self.event_manager.register_event('lure_info')423 self.event_manager.register_event(424 'pokemon_catch_rate',425 parameters=(426 'catch_rate',427 'ball_name',428 'berry_name',429 'berry_count'430 )431 )432 self.event_manager.register_event(433 'threw_berry',434 parameters=(435 'berry_name',436 'ball_name',437 'new_catch_rate'438 )439 )440 self.event_manager.register_event(441 'threw_pokeball',442 parameters=(443 'throw_type',444 'spin_label',445 'ball_name',446 'success_percentage',447 'count_left'448 )449 )450 self.event_manager.register_event(451 'pokemon_capture_failed',452 parameters=('pokemon',)453 )454 self.event_manager.register_event(455 'pokemon_vanished',456 parameters=(457 'pokemon',458 'encounter_id',459 'latitude',460 'longitude',461 'pokemon_id'462 )463 )464 self.event_manager.register_event(465 'vanish_limit_reached',466 parameters=(467 'duration',468 'resume'469 )470 )471 self.event_manager.register_event('pokemon_not_in_range')472 self.event_manager.register_event('pokemon_inventory_full')473 self.event_manager.register_event(474 'pokemon_caught',475 parameters=(476 'pokemon',477 'ncp', 'cp', 'iv', 'iv_display', 'exp',478 'shiny',479 'stardust',480 'encounter_id',481 'latitude',482 'longitude',483 'pokemon_id',484 'daily_catch_limit',485 'caught_last_24_hour',486 )487 )488 self.event_manager.register_event(489 'pokemon_vip_caught',490 parameters=(491 'pokemon',492 'ncp', 'cp', 'iv', 'iv_display', 'exp',493 'shiny',494 'stardust',495 'encounter_id',496 'latitude',497 'longitude',498 'pokemon_id',499 'daily_catch_limit',500 'caught_last_24_hour',501 )502 )503 self.event_manager.register_event(504 'pokemon_evolved',505 parameters=('pokemon', 'new', 'iv', 'old_cp', 'cp', 'candy', 'xp')506 )507 self.event_manager.register_event(508 'pokemon_favored',509 parameters=('pokemon', 'iv', 'cp')510 )511 self.event_manager.register_event(512 'pokemon_unfavored',513 parameters=('pokemon', 'iv', 'cp')514 )515 self.event_manager.register_event(516 'pokemon_evolve_check',517 parameters=('has', 'needs')518 )519 self.event_manager.register_event(520 'pokemon_upgraded',521 parameters=('pokemon', 'iv', 'cp', 'new_cp', 'candy', 'stardust')522 )523 self.event_manager.register_event('skip_evolve')524 self.event_manager.register_event('threw_berry_failed', parameters=('status_code',))525 self.event_manager.register_event('vip_pokemon')526 self.event_manager.register_event('gained_candy', parameters=('gained_candy', 'quantity', 'type'))527 self.event_manager.register_event('catch_limit')528 self.event_manager.register_event('spin_limit')529 self.event_manager.register_event('show_best_pokemon', parameters=('pokemons'))530 self.event_manager.register_event('revived_pokemon')531 self.event_manager.register_event('healing_pokemon')532 # level up stuff533 self.event_manager.register_event(534 'level_up',535 parameters=(536 'previous_level',537 'current_level'538 )539 )540 self.event_manager.register_event(541 'level_up_reward',542 parameters=('items',)543 )544 # lucky egg545 self.event_manager.register_event(546 'used_lucky_egg',547 parameters=('amount_left',)548 )549 self.event_manager.register_event('lucky_egg_error')550 # softban551 self.event_manager.register_event('softban')552 self.event_manager.register_event('softban_fix')553 self.event_manager.register_event('softban_fix_done')554 # egg incubating555 self.event_manager.register_event(556 'incubate_try',557 parameters=(558 'incubator_id',559 'egg_id'560 )561 )562 self.event_manager.register_event(563 'incubate',564 parameters=('distance_in_km',)565 )566 self.event_manager.register_event(567 'next_egg_incubates',568 parameters=('eggs_left', 'eggs_inc', 'eggs')569 )570 self.event_manager.register_event('incubator_already_used')571 self.event_manager.register_event('egg_already_incubating')572 self.event_manager.register_event(573 'egg_hatched',574 parameters=(575 'name', 'cp', 'ncp', 'iv_ads', 'iv_pct', 'exp', 'stardust', 'candy'576 )577 )578 self.event_manager.register_event('egg_hatched_fail')579 # discard item580 self.event_manager.register_event(581 'item_discarded',582 parameters=(583 'amount', 'item', 'maximum'584 )585 )586 self.event_manager.register_event(587 'item_discard_skipped',588 parameters=('space',)589 )590 self.event_manager.register_event(591 'item_discard_fail',592 parameters=('item',)593 )594 # inventory595 self.event_manager.register_event('inventory_full')596 # release597 self.event_manager.register_event(598 'keep_best_release',599 parameters=(600 'amount', 'pokemon', 'criteria'601 )602 )603 self.event_manager.register_event(604 'future_pokemon_release',605 parameters=(606 'pokemon', 'cp', 'iv', 'ivcp', 'below_iv', 'below_cp', 'below_ivcp', 'cp_iv_logic'607 )608 )609 self.event_manager.register_event(610 'pokemon_release',611 parameters=('pokemon', 'iv', 'cp', 'ivcp', 'candy', 'candy_type')612 )613 self.event_manager.register_event(614 'pokemon_keep',615 parameters=('pokemon', 'iv', 'cp', 'ivcp')616 )617 # polyline walker618 self.event_manager.register_event(619 'polyline_request',620 parameters=('url',)621 )622 # cluster623 self.event_manager.register_event(624 'found_cluster',625 parameters=(626 'num_points', 'forts', 'radius', 'distance'627 )628 )629 self.event_manager.register_event(630 'arrived_at_cluster',631 parameters=(632 'num_points', 'forts', 'radius'633 )634 )635 # rename636 self.event_manager.register_event(637 'rename_pokemon',638 parameters=('old_name', 'current_name',)639 )640 self.event_manager.register_event(641 'pokemon_nickname_invalid',642 parameters=('nickname',)643 )644 self.event_manager.register_event(645 'unset_pokemon_nickname',646 parameters=('old_name',)647 )648 # Move To map pokemon649 self.event_manager.register_event(650 'move_to_map_pokemon_fail',651 parameters=('message',)652 )653 self.event_manager.register_event(654 'move_to_map_pokemon_updated_map',655 parameters=('lat', 'lon')656 )657 self.event_manager.register_event(658 'move_to_map_pokemon_teleport_to',659 parameters=('poke_name', 'poke_dist', 'poke_lat', 'poke_lon',660 'disappears_in')661 )662 self.event_manager.register_event(663 'move_to_map_pokemon_encounter',664 parameters=('poke_name', 'poke_dist', 'poke_lat', 'poke_lon',665 'disappears_in')666 )667 self.event_manager.register_event(668 'move_to_map_pokemon_move_towards',669 parameters=('poke_name', 'poke_dist', 'poke_lat', 'poke_lon',670 'disappears_in')671 )672 self.event_manager.register_event(673 'move_to_map_pokemon_teleport_back',674 parameters=('last_lat', 'last_lon')675 )676 self.event_manager.register_event(677 'moving_to_pokemon_throught_fort',678 parameters=('fort_name', 'distance','poke_name','poke_dist')679 )680 self.event_manager.register_event(681 'move_to_map_pokemon',682 parameters=('message')683 )684 # cached recent_forts685 self.event_manager.register_event('loaded_cached_forts')686 self.event_manager.register_event('cached_fort')687 self.event_manager.register_event(688 'no_cached_forts',689 parameters=('path', )690 )691 self.event_manager.register_event(692 'error_caching_forts',693 parameters=('path', )694 )695 # database shit696 self.event_manager.register_event('catch_log')697 self.event_manager.register_event('vanish_log')698 self.event_manager.register_event('evolve_log')699 self.event_manager.register_event('login_log')700 self.event_manager.register_event('transfer_log')701 self.event_manager.register_event('pokestop_log')702 self.event_manager.register_event('softban_log')703 self.event_manager.register_event('eggs_hatched_log')704 self.event_manager.register_event(705 'badges',706 parameters=('badge', 'level')707 )708 self.event_manager.register_event(709 'player_data',710 parameters=('player_data', )711 )712 self.event_manager.register_event(713 'forts_found',714 parameters=('json')715 )716 # UseIncense717 self.event_manager.register_event(718 'use_incense',719 parameters=('type', 'incense_count')720 )721 # BuddyPokemon722 self.event_manager.register_event(723 'buddy_update',724 parameters=('name')725 )726 self.event_manager.register_event(727 'buddy_update_fail',728 parameters=('name', 'error')729 )730 self.event_manager.register_event(731 'buddy_candy_earned',732 parameters=('candy', 'family', 'quantity', 'candy_earned', 'candy_limit')733 )734 self.event_manager.register_event('buddy_candy_fail')735 self.event_manager.register_event(736 'buddy_next_reward',737 parameters=('name', 'km_walked', 'km_total')738 )739 self.event_manager.register_event('buddy_keep_active')740 self.event_manager.register_event(741 'buddy_not_available',742 parameters=('name')743 )744 # Sniper745 self.event_manager.register_event('sniper_log', parameters=('message', 'message'))746 self.event_manager.register_event('sniper_error', parameters=('message', 'message'))747 self.event_manager.register_event('sniper_teleporting', parameters=('latitude', 'longitude', 'name'))748 # Catch-limiter749 self.event_manager.register_event('catch_limit_on')750 self.event_manager.register_event('catch_limit_off')751 self.event_manager.register_event(752 'pokemon_knock_out_gym',753 parameters=('pokemon', 'gym_name', 'notification_date', 'awarded_coins', 'awarded_coins_today')754 )755 self.event_manager.register_event(756 'pokemon_hungy',757 parameters=('pokemon', 'gym_name', 'notification_date')758 )759 def tick(self):760 self.health_record.heartbeat()761 self.cell = self.get_meta_cell()762 if self.sleep_schedule:763 self.sleep_schedule.work()764 now = time.time() * 1000765 for fort in self.cell["forts"]:766 timeout = fort.get("cooldown_complete_timestamp_ms", 0)767 if timeout >= now:768 self.fort_timeouts[fort["id"]] = timeout769 self._refresh_inventory()...

Full Screen

Full Screen

__init__.py

Source:__init__.py Github

copy

Full Screen

...150 if self.config.show_events:151 self.event_manager.event_report()152 sys.exit(1)153 # Registering event:154 # self.event_manager.register_event("location", parameters=['lat', 'lng'])155 #156 # Emitting event should be enough to add logging and send websocket157 # message: :158 # self.event_manager.emit('location', 'level'='info', data={'lat': 1, 'lng':1}),159 def _register_events(self):160 self.event_manager.register_event(161 'location_found',162 parameters=('position', 'location')163 )164 self.event_manager.register_event('api_error')165 self.event_manager.register_event('config_error')166 self.event_manager.register_event('login_started')167 self.event_manager.register_event('login_failed')168 self.event_manager.register_event('login_successful')169 self.event_manager.register_event('set_start_location')170 self.event_manager.register_event('load_cached_location')171 self.event_manager.register_event('location_cache_ignored')172 self.event_manager.register_event('debug')173 self.event_manager.register_event('refuse_to_sit')174 self.event_manager.register_event('reset_destination')175 self.event_manager.register_event('new_destination')176 self.event_manager.register_event('moving_to_destination')177 self.event_manager.register_event('arrived_at_destination')178 self.event_manager.register_event('staying_at_destination')179 self.event_manager.register_event('buddy_pokemon', parameters=('pokemon', 'iv', 'cp'))180 self.event_manager.register_event('buddy_reward', parameters=('pokemon', 'family', 'candy_earned', 'candy'))181 self.event_manager.register_event('buddy_walked', parameters=('pokemon', 'distance_walked', 'distance_needed'))182 # ignore candy above threshold183 self.event_manager.register_event(184 'ignore_candy_above_thresold',185 parameters=(186 'name',187 'amount',188 'threshold'189 )190 )191 self.event_manager.register_event(192 'position_update',193 parameters=(194 'current_position',195 'last_position',196 'distance', # optional197 'distance_unit' # optional198 )199 )200 self.event_manager.register_event(201 'path_lap_update',202 parameters=(203 'number_lap',204 'number_lap_max'205 )206 )207 self.event_manager.register_event(208 'path_lap_end',209 parameters=(210 'duration',211 'resume'212 )213 )214 self.event_manager.register_event('location_cache_error')215 self.event_manager.register_event('bot_start')216 self.event_manager.register_event('bot_exit')217 self.event_manager.register_event('bot_interrupted')218 # sleep stuff219 self.event_manager.register_event(220 'next_sleep',221 parameters=(222 'time',223 'duration'224 )225 )226 self.event_manager.register_event(227 'bot_sleep',228 parameters=(229 'time_hms',230 'wake'231 )232 )233 # random pause234 self.event_manager.register_event(235 'next_random_pause',236 parameters=(237 'time',238 'duration'239 )240 )241 self.event_manager.register_event(242 'bot_random_pause',243 parameters=(244 'time_hms',245 'resume'246 )247 )248 # recycle stuff249 self.event_manager.register_event(250 'next_force_recycle',251 parameters=(252 'time'253 )254 )255 self.event_manager.register_event('force_recycle')256 # random alive pause257 self.event_manager.register_event(258 'next_random_alive_pause',259 parameters=(260 'time',261 'duration'262 )263 )264 self.event_manager.register_event(265 'bot_random_alive_pause',266 parameters=(267 'time_hms',268 'resume'269 )270 )271 # fort stuff272 self.event_manager.register_event(273 'spun_fort',274 parameters=(275 'fort_id',276 'latitude',277 'longitude'278 )279 )280 self.event_manager.register_event(281 'lured_pokemon_found',282 parameters=(283 'fort_id',284 'fort_name',285 'encounter_id',286 'latitude',287 'longitude'288 )289 )290 self.event_manager.register_event(291 'moving_to_fort',292 parameters=(293 'fort_name',294 'distance'295 )296 )297 self.event_manager.register_event(298 'moving_to_lured_fort',299 parameters=(300 'fort_name',301 'distance',302 'lure_distance'303 )304 )305 self.event_manager.register_event(306 'spun_pokestop',307 parameters=(308 'pokestop', 'exp', 'items'309 )310 )311 self.event_manager.register_event(312 'pokestop_empty',313 parameters=('pokestop',)314 )315 self.event_manager.register_event(316 'pokestop_out_of_range',317 parameters=('pokestop',)318 )319 self.event_manager.register_event(320 'pokestop_on_cooldown',321 parameters=('pokestop', 'minutes_left')322 )323 self.event_manager.register_event(324 'unknown_spin_result',325 parameters=('status_code',)326 )327 self.event_manager.register_event('pokestop_searching_too_often')328 self.event_manager.register_event('arrived_at_fort')329 # pokemon stuff330 self.event_manager.register_event(331 'catchable_pokemon',332 parameters=(333 'pokemon_id',334 'spawn_point_id',335 'encounter_id',336 'latitude',337 'longitude',338 'expiration_timestamp_ms',339 'pokemon_name'340 )341 )342 self.event_manager.register_event(343 'incensed_pokemon_found',344 parameters=(345 'pokemon_id',346 'encounter_id',347 'encounter_location',348 'latitude',349 'longitude'350 )351 )352 self.event_manager.register_event(353 'pokemon_appeared',354 parameters=(355 'pokemon',356 'ncp',357 'cp',358 'iv',359 'iv_display',360 'encounter_id',361 'latitude',362 'longitude',363 'pokemon_id'364 )365 )366 self.event_manager.register_event('no_pokeballs')367 self.event_manager.register_event('enough_ultraballs')368 self.event_manager.register_event(369 'pokemon_catch_rate',370 parameters=(371 'catch_rate',372 'ball_name',373 'berry_name',374 'berry_count'375 )376 )377 self.event_manager.register_event(378 'threw_berry',379 parameters=(380 'berry_name',381 'ball_name',382 'new_catch_rate'383 )384 )385 self.event_manager.register_event(386 'threw_pokeball',387 parameters=(388 'throw_type',389 'spin_label',390 'ball_name',391 'success_percentage',392 'count_left'393 )394 )395 self.event_manager.register_event(396 'pokemon_capture_failed',397 parameters=('pokemon',)398 )399 self.event_manager.register_event(400 'pokemon_vanished',401 parameters=(402 'pokemon',403 'encounter_id',404 'latitude',405 'longitude',406 'pokemon_id'407 )408 )409 self.event_manager.register_event(410 'vanish_limit_reached',411 parameters=(412 'duration',413 'resume'414 )415 )416 self.event_manager.register_event('pokemon_not_in_range')417 self.event_manager.register_event('pokemon_inventory_full')418 self.event_manager.register_event(419 'pokemon_caught',420 parameters=(421 'pokemon',422 'ncp', 'cp', 'iv', 'iv_display', 'exp',423 'stardust',424 'encounter_id',425 'latitude',426 'longitude',427 'pokemon_id',428 'daily_catch_limit',429 'caught_last_24_hour',430 )431 )432 self.event_manager.register_event(433 'pokemon_vip_caught',434 parameters=(435 'pokemon',436 'ncp', 'cp', 'iv', 'iv_display', 'exp',437 'stardust',438 'encounter_id',439 'latitude',440 'longitude',441 'pokemon_id',442 'daily_catch_limit',443 'caught_last_24_hour',444 )445 )446 self.event_manager.register_event(447 'pokemon_evolved',448 parameters=('pokemon', 'iv', 'cp', 'candy', 'xp')449 )450 self.event_manager.register_event(451 'pokemon_evolve_check',452 parameters=('has', 'needs')453 )454 self.event_manager.register_event(455 'pokemon_upgraded',456 parameters=('pokemon', 'iv', 'cp', 'candy', 'stardust')457 )458 self.event_manager.register_event('skip_evolve')459 self.event_manager.register_event('threw_berry_failed', parameters=('status_code',))460 self.event_manager.register_event('vip_pokemon')461 self.event_manager.register_event('gained_candy', parameters=('quantity', 'type'))462 self.event_manager.register_event('catch_limit')463 self.event_manager.register_event('spin_limit')464 self.event_manager.register_event('show_best_pokemon', parameters=('pokemons'))465 # level up stuff466 self.event_manager.register_event(467 'level_up',468 parameters=(469 'previous_level',470 'current_level'471 )472 )473 self.event_manager.register_event(474 'level_up_reward',475 parameters=('items',)476 )477 # lucky egg478 self.event_manager.register_event(479 'used_lucky_egg',480 parameters=('amount_left',)481 )482 self.event_manager.register_event('lucky_egg_error')483 # softban484 self.event_manager.register_event('softban')485 self.event_manager.register_event('softban_fix')486 self.event_manager.register_event('softban_fix_done')487 # egg incubating488 self.event_manager.register_event(489 'incubate_try',490 parameters=(491 'incubator_id',492 'egg_id'493 )494 )495 self.event_manager.register_event(496 'incubate',497 parameters=('distance_in_km',)498 )499 self.event_manager.register_event(500 'next_egg_incubates',501 parameters=('eggs_left', 'eggs_inc', 'eggs')502 )503 self.event_manager.register_event('incubator_already_used')504 self.event_manager.register_event('egg_already_incubating')505 self.event_manager.register_event(506 'egg_hatched',507 parameters=(508 'name', 'cp', 'ncp', 'iv_ads', 'iv_pct', 'exp', 'stardust', 'candy'509 )510 )511 self.event_manager.register_event('egg_hatched_fail')512 # discard item513 self.event_manager.register_event(514 'item_discarded',515 parameters=(516 'amount', 'item', 'maximum'517 )518 )519 self.event_manager.register_event(520 'item_discard_skipped',521 parameters=('space',)522 )523 self.event_manager.register_event(524 'item_discard_fail',525 parameters=('item',)526 )527 # inventory528 self.event_manager.register_event('inventory_full')529 # release530 self.event_manager.register_event(531 'keep_best_release',532 parameters=(533 'amount', 'pokemon', 'criteria'534 )535 )536 self.event_manager.register_event(537 'future_pokemon_release',538 parameters=(539 'pokemon', 'cp', 'iv', 'ivcp', 'below_iv', 'below_cp', 'below_ivcp', 'cp_iv_logic'540 )541 )542 self.event_manager.register_event(543 'pokemon_release',544 parameters=('pokemon', 'iv', 'cp', 'ivcp', 'candy', 'candy_type')545 )546 self.event_manager.register_event(547 'pokemon_keep',548 parameters=('pokemon', 'iv', 'cp', 'ivcp')549 )550 # polyline walker551 self.event_manager.register_event(552 'polyline_request',553 parameters=('url',)554 )555 # cluster556 self.event_manager.register_event(557 'found_cluster',558 parameters=(559 'num_points', 'forts', 'radius', 'distance'560 )561 )562 self.event_manager.register_event(563 'arrived_at_cluster',564 parameters=(565 'num_points', 'forts', 'radius'566 )567 )568 # rename569 self.event_manager.register_event(570 'rename_pokemon',571 parameters=('old_name', 'current_name',)572 )573 self.event_manager.register_event(574 'pokemon_nickname_invalid',575 parameters=('nickname',)576 )577 self.event_manager.register_event(578 'unset_pokemon_nickname',579 parameters=('old_name',)580 )581 # Move To map pokemon582 self.event_manager.register_event(583 'move_to_map_pokemon_fail',584 parameters=('message',)585 )586 self.event_manager.register_event(587 'move_to_map_pokemon_updated_map',588 parameters=('lat', 'lon')589 )590 self.event_manager.register_event(591 'move_to_map_pokemon_teleport_to',592 parameters=('poke_name', 'poke_dist', 'poke_lat', 'poke_lon',593 'disappears_in')594 )595 self.event_manager.register_event(596 'move_to_map_pokemon_encounter',597 parameters=('poke_name', 'poke_dist', 'poke_lat', 'poke_lon',598 'disappears_in')599 )600 self.event_manager.register_event(601 'move_to_map_pokemon_move_towards',602 parameters=('poke_name', 'poke_dist', 'poke_lat', 'poke_lon',603 'disappears_in')604 )605 self.event_manager.register_event(606 'move_to_map_pokemon_teleport_back',607 parameters=('last_lat', 'last_lon')608 )609 self.event_manager.register_event(610 'moving_to_pokemon_throught_fort',611 parameters=('fort_name', 'distance','poke_name','poke_dist')612 )613 self.event_manager.register_event(614 'move_to_map_pokemon',615 parameters=('message')616 )617 # cached recent_forts618 self.event_manager.register_event('loaded_cached_forts')619 self.event_manager.register_event('cached_fort')620 self.event_manager.register_event(621 'no_cached_forts',622 parameters=('path', )623 )624 self.event_manager.register_event(625 'error_caching_forts',626 parameters=('path', )627 )628 # database shit629 self.event_manager.register_event('catch_log')630 self.event_manager.register_event('vanish_log')631 self.event_manager.register_event('evolve_log')632 self.event_manager.register_event('login_log')633 self.event_manager.register_event('transfer_log')634 self.event_manager.register_event('pokestop_log')635 self.event_manager.register_event('softban_log')636 self.event_manager.register_event('eggs_hatched_log')637 self.event_manager.register_event(638 'badges',639 parameters=('badge', 'level')640 )641 self.event_manager.register_event(642 'player_data',643 parameters=('player_data', )644 )645 self.event_manager.register_event(646 'forts_found',647 parameters=('json')648 )649 # UseIncense650 self.event_manager.register_event(651 'use_incense',652 parameters=('type', 'incense_count')653 )654 # BuddyPokemon655 self.event_manager.register_event(656 'buddy_update',657 parameters=('name')658 )659 self.event_manager.register_event(660 'buddy_update_fail',661 parameters=('name', 'error')662 )663 self.event_manager.register_event(664 'buddy_candy_earned',665 parameters=('candy', 'family', 'quantity', 'candy_earned', 'candy_limit')666 )667 self.event_manager.register_event('buddy_candy_fail')668 self.event_manager.register_event(669 'buddy_next_reward',670 parameters=('name', 'km_walked', 'km_total')671 )672 self.event_manager.register_event('buddy_keep_active')673 self.event_manager.register_event(674 'buddy_not_available',675 parameters=('name')676 )677 # Sniper678 self.event_manager.register_event('sniper_log', parameters=('message', 'message'))679 self.event_manager.register_event('sniper_error', parameters=('message', 'message'))680 self.event_manager.register_event('sniper_teleporting', parameters=('latitude', 'longitude', 'name'))681 # Catch-limiter682 self.event_manager.register_event('catch_limit_on')683 self.event_manager.register_event('catch_limit_off')684 def tick(self):685 self.health_record.heartbeat()686 self.cell = self.get_meta_cell()687 if self.sleep_schedule:688 self.sleep_schedule.work()689 now = time.time() * 1000690 for fort in self.cell["forts"]:691 timeout = fort.get("cooldown_complete_timestamp_ms", 0)692 if timeout >= now:693 self.fort_timeouts[fort["id"]] = timeout694 self._refresh_inventory()695 self.tick_count += 1696 # Check if session token has expired697 self.check_session(self.position)...

Full Screen

Full Screen

26857_events.py

Source:26857_events.py Github

copy

Full Screen

...16 DateTimeField17)18from wechatpy.messages import BaseMessage19EVENT_TYPES = {}20def register_event(event_type):21 """22 Register the event class so that they can be accessed from EVENT_TYPES23 :param event_type: Event type24 """25 def register(cls):26 EVENT_TYPES[event_type] = cls27 return cls28 return register29class BaseEvent(BaseMessage):30 """Base class for all events"""31 type = 'event'32 event = ''33@register_event('subscribe')34class SubscribeEvent(BaseEvent):35 """36 用户关注事件37 详情请参阅38 http://mp.weixin.qq.com/wiki/2/5baf56ce4947d35003b86a9805634b1e.html39 """40 event = 'subscribe'41 key = StringField('EventKey', '')42@register_event('unsubscribe')43class UnsubscribeEvent(BaseEvent):44 """45 用户取消关注事件46 详情请参阅47 http://mp.weixin.qq.com/wiki/2/5baf56ce4947d35003b86a9805634b1e.html48 """49 event = 'unsubscribe'50@register_event('subscribe_scan')51class SubscribeScanEvent(BaseEvent):52 """53 用户扫描二维码关注事件54 详情请参阅55 http://mp.weixin.qq.com/wiki/2/5baf56ce4947d35003b86a9805634b1e.html56 """57 event = 'subscribe_scan'58 scene_id = StringField('EventKey')59 ticket = StringField('Ticket')60@register_event('scan')61class ScanEvent(BaseEvent):62 """63 用户扫描二维码事件64 详情请参阅65 http://mp.weixin.qq.com/wiki/2/5baf56ce4947d35003b86a9805634b1e.html66 """67 event = 'scan'68 scene_id = StringField('EventKey')69 ticket = StringField('Ticket')70@register_event('location')71class LocationEvent(BaseEvent):72 """73 上报地理位置事件74 详情请参阅75 http://mp.weixin.qq.com/wiki/2/5baf56ce4947d35003b86a9805634b1e.html76 """77 event = 'location'78 latitude = FloatField('Latitude', 0.0)79 longitude = FloatField('Longitude', 0.0)80 precision = FloatField('Precision', 0.0)81@register_event('click')82class ClickEvent(BaseEvent):83 """84 点击菜单拉取消息事件85 详情请参阅86 http://mp.weixin.qq.com/wiki/2/5baf56ce4947d35003b86a9805634b1e.html87 """88 event = 'click'89 key = StringField('EventKey')90@register_event('view')91class ViewEvent(BaseEvent):92 """93 点击菜单跳转链接事件94 详情请参阅95 http://mp.weixin.qq.com/wiki/2/5baf56ce4947d35003b86a9805634b1e.html96 """97 event = 'view'98 url = StringField('EventKey')99@register_event('masssendjobfinish')100class MassSendJobFinishEvent(BaseEvent):101 """102 群发消息任务完成事件103 详情请参阅104 http://mp.weixin.qq.com/wiki/15/5380a4e6f02f2ffdc7981a8ed7a40753.html105 """106 id = IntegerField('MsgID', 0)107 event = 'masssendjobfinish'108 status = StringField('Status')109 total_count = IntegerField('TotalCount', 0)110 filter_count = IntegerField('FilterCount', 0)111 sent_count = IntegerField('SentCount', 0)112 error_count = IntegerField('ErrorCount', 0)113@register_event('templatesendjobfinish')114class TemplateSendJobFinishEvent(BaseEvent):115 """116 模板消息任务完成事件117 详情请参阅118 http://mp.weixin.qq.com/wiki/17/304c1885ea66dbedf7dc170d84999a9d.html119 """120 id = IntegerField('MsgID')121 event = 'templatesendjobfinish'122 status = StringField('Status')123class BaseScanCodeEvent(BaseEvent):124 key = StringField('EventKey')125 scan_code_info = BaseField('ScanCodeInfo', {})126 @property127 def scan_type(self):128 return self.scan_code_info['ScanType']129 @property130 def scan_result(self):131 return self.scan_code_info['ScanResult']132@register_event('scancode_push')133class ScanCodePushEvent(BaseScanCodeEvent):134 """135 扫码推事件136 详情请参阅137 http://mp.weixin.qq.com/wiki/9/981d772286d10d153a3dc4286c1ee5b5.html138 """139 event = 'scancode_push'140@register_event('scancode_waitmsg')141class ScanCodeWaitMsgEvent(BaseScanCodeEvent):142 """143 扫码推事件且弹出“消息接收中”提示框的事件144 详情请参阅145 http://mp.weixin.qq.com/wiki/9/981d772286d10d153a3dc4286c1ee5b5.html146 """147 event = 'scancode_waitmsg'148class BasePictureEvent(BaseEvent):149 key = StringField('EventKey')150 pictures_info = BaseField('SendPicsInfo', {})151 @property152 def count(self):153 return int(self.pictures_info['Count'])154 @property155 def pictures(self):156 if self.pictures_info['PicList']:157 items = self.pictures_info['PicList']['item']158 if self.count > 1:159 return items160 return [items]161 return []162@register_event('pic_sysphoto')163class PicSysPhotoEvent(BasePictureEvent):164 """165 弹出系统拍照发图的事件166 详情请参阅167 http://mp.weixin.qq.com/wiki/9/981d772286d10d153a3dc4286c1ee5b5.html168 """169 event = 'pic_sysphoto'170@register_event('pic_photo_or_album')171class PicPhotoOrAlbumEvent(BasePictureEvent):172 """173 弹出拍照或者相册发图的事件174 详情请参阅175 http://mp.weixin.qq.com/wiki/9/981d772286d10d153a3dc4286c1ee5b5.html176 """177 event = 'pic_photo_or_album'178@register_event('pic_weixin')179class PicWeChatEvent(BasePictureEvent):180 """181 弹出微信相册发图器的事件182 详情请参阅183 http://mp.weixin.qq.com/wiki/9/981d772286d10d153a3dc4286c1ee5b5.html184 """185 event = 'pic_weixin'186@register_event('location_select')187class LocationSelectEvent(BaseEvent):188 """189 弹出地理位置选择器的事件190 详情请参阅191 http://mp.weixin.qq.com/wiki/9/981d772286d10d153a3dc4286c1ee5b5.html192 """193 event = 'location_select'194 key = StringField('EventKey')195 location_info = BaseField('SendLocationInfo', {})196 @property197 def location_x(self):198 return self.location_info['Location_X']199 @property200 def location_y(self):201 return self.location_info['Location_Y']202 @property203 def location(self):204 return self.location_x, self.location_y205 @property206 def scale(self):207 return self.location_info['Scale']208 @property209 def label(self):210 return self.location_info['Label']211 @property212 def poiname(self):213 return self.location_info['Poiname']214@register_event('card_pass_check')215class CardPassCheckEvent(BaseEvent):216 event = 'card_pass_check'217 card_id = StringField('CardId')218@register_event('card_not_pass_check')219class CardNotPassCheckEvent(BaseEvent):220 event = 'card_not_pass_check'221 card_id = StringField('CardId')222@register_event('user_get_card')223class UserGetCardEvent(BaseEvent):224 """225 领取事件推送226 详情请参阅227 http://mp.weixin.qq.com/wiki/16/28b34ee91675a04cb24853768debded4.html#.E9.A2.86.E5.8F.96.E4.BA.8B.E4.BB.B6.E6.8E.A8.E9.80.81228 """229 event = 'user_get_card'230 card_id = StringField('CardId')231 is_given_by_friend = IntegerField('IsGiveByFriend')232 friend = StringField('FriendUserName')233 code = StringField('UserCardCode')234 old_code = StringField('OldUserCardCode')235 outer_id = StringField('OuterId')236@register_event('user_del_card')237class UserDeleteCardEvent(BaseEvent):238 """239 卡券删除事件推送240 详情请参阅241 http://mp.weixin.qq.com/wiki/16/28b34ee91675a04cb24853768debded4.html#.E5.88.A0.E9.99.A4.E4.BA.8B.E4.BB.B6.E6.8E.A8.E9.80.81242 """243 event = 'user_del_card'244 card_id = StringField('CardId')245 code = StringField('UserCardCode')246@register_event('user_consume_card')247class UserConsumeCardEvent(BaseEvent):248 """249 卡券核销事件推送250 详情请参阅251 http://mp.weixin.qq.com/wiki/16/28b34ee91675a04cb24853768debded4.html#.E6.A0.B8.E9.94.80.E4.BA.8B.E4.BB.B6.E6.8E.A8.E9.80.81252 """253 event = 'user_consume_card'254 card_id = StringField('CardId')255 code = StringField('UserCardCode')256 consume_source = StringField('ConsumeSource')257 location_id = StringField('LocationId')258 staff = StringField('StaffOpenId')259@register_event('merchant_order')260class MerchantOrderEvent(BaseEvent):261 event = 'merchant_order'262 order_id = StringField('OrderId')263 order_status = IntegerField('OrderStatus')264 product_id = StringField('ProductId')265 sku_info = StringField('SkuInfo')266@register_event('kf_create_session')267class KfCreateSessionEvent(BaseEvent):268 event = 'kf_create_session'269 account = StringField('KfAccount')270@register_event('kf_close_session')271class KfCloseSessionEvent(BaseEvent):272 event = 'kf_close_session'273 account = StringField('KfAccount')274@register_event('kf_switch_session')275class KfSwitchSessionEvent(BaseEvent):276 event = 'kf_switch_session'277 from_account = StringField('FromKfAccount')278 to_account = StringField('ToKfAccount')279@register_event('device_text')280class DeviceTextEvent(BaseEvent):281 event = 'device_text'282 device_type = StringField('DeviceType')283 device_id = StringField('DeviceID')284 session_id = StringField('SessionID')285 content = Base64DecodeField('Content')286 open_id = StringField('OpenID')287@register_event('device_bind')288class DeviceBindEvent(BaseEvent):289 event = 'device_bind'290 device_type = StringField('DeviceType')291 device_id = StringField('DeviceID')292 session_id = StringField('SessionID')293 content = Base64DecodeField('Content')294 open_id = StringField('OpenID')295@register_event('device_unbind')296class DeviceUnbindEvent(BaseEvent):297 event = 'device_unbind'298 device_type = StringField('DeviceType')299 device_id = StringField('DeviceID')300 session_id = StringField('SessionID')301 content = Base64DecodeField('Content')302 open_id = StringField('OpenID')303@register_event('device_subscribe_status')304class DeviceSubscribeStatusEvent(BaseEvent):305 event = 'device_subscribe_status'306 device_type = StringField('DeviceType')307 device_id = StringField('DeviceID')308 open_id = StringField('OpenID')309 op_type = IntegerField('OpType')310@register_event('device_unsubscribe_status')311class DeviceUnsubscribeStatusEvent(BaseEvent):312 event = 'device_unsubscribe_status'313 device_type = StringField('DeviceType')314 device_id = StringField('DeviceID')315 open_id = StringField('OpenID')316 op_type = IntegerField('OpType')317@register_event('shakearoundusershake')318class ShakearoundUserShakeEvent(BaseEvent):319 event = 'shakearound_user_shake'320 _chosen_beacon = BaseField('ChosenBeacon', {})321 _around_beacons = BaseField('AroundBeacons', {})322 @property323 def chosen_beacon(self):324 beacon = self._chosen_beacon325 if not beacon:326 return {}327 return {328 'uuid': beacon['Uuid'],329 'major': beacon['Major'],330 'minor': beacon['Minor'],331 'distance': float(beacon['Distance']),332 }333 @property334 def around_beacons(self):335 beacons = self._around_beacons336 if not beacons:337 return []338 ret = []339 for beacon in beacons['AroundBeacon']:340 ret.append({341 'uuid': beacon['Uuid'],342 'major': beacon['Major'],343 'minor': beacon['Minor'],344 'distance': float(beacon['Distance']),345 })346 return ret347@register_event('poi_check_notify')348class PoiCheckNotifyEvent(BaseEvent):349 event = 'poi_check_notify'350 poi_id = StringField('PoiId')351 uniq_id = StringField('UniqId')352 result = StringField('Result')353 message = StringField('Msg')354@register_event('wificonnected')355class WiFiConnectedEvent(BaseEvent):356 event = 'wificconnected'357 connect_time = IntegerField('ConnectTime')358 expire_time = IntegerField('ExpireTime')359 vendor_id = StringField('VendorId')360 shop_id = StringField('PlaceId')361 bssid = StringField('DeviceNo')362# ============================================================================363# 微信认证事件推送364# ============================================================================365@register_event('qualification_verify_success')366class QualificationVerifySuccessEvent(BaseEvent):367 """368 资质认证成功事件369 详情请参阅370 http://mp.weixin.qq.com/wiki/1/7f81dec16b801b34629091094c099439.html371 """372 event = 'qualification_verify_success'373 expired_time = DateTimeField('ExpiredTime')374@register_event('qualification_verify_fail')375class QualificationVerifyFailEvent(BaseEvent):376 """377 资质认证失败事件378 详情请参阅379 http://mp.weixin.qq.com/wiki/1/7f81dec16b801b34629091094c099439.html380 """381 event = 'qualification_verify_fail'382 fail_time = DateTimeField('FailTime')383 fail_reason = StringField('FailReason')384@register_event('naming_verify_success')385class NamingVerifySuccessEvent(BaseEvent):386 """387 名称认证成功事件388 详情请参阅389 http://mp.weixin.qq.com/wiki/1/7f81dec16b801b34629091094c099439.html390 """391 event = 'naming_verify_success'392 expired_time = DateTimeField('ExpiredTime')393@register_event('naming_verify_fail')394class NamingVerifyFailEvent(BaseEvent):395 """396 名称认证失败事件397 客户端不打勾,但仍有接口权限。详情请参阅398 http://mp.weixin.qq.com/wiki/1/7f81dec16b801b34629091094c099439.html399 """400 event = 'naming_verify_fail'401 fail_time = DateTimeField('FailTime')402 fail_reason = StringField('FailReason')403@register_event('annual_renew')404class AnnualRenewEvent(BaseEvent):405 """406 年审通知事件407 详情请参阅408 http://mp.weixin.qq.com/wiki/1/7f81dec16b801b34629091094c099439.html409 """410 event = 'annual_renew'411 expired_time = DateTimeField('ExpiredTime')412@register_event('verify_expired')413class VerifyExpiredEvent(BaseEvent):414 """415 认证过期失效通知416 详情请参阅417 http://mp.weixin.qq.com/wiki/1/7f81dec16b801b34629091094c099439.html418 """419 event = 'verify_expired'420 expired_time = DateTimeField('ExpiredTime')421@register_event('user_scan_product')422class UserScanProductEvent(BaseEvent):423 """424 打开商品主页事件425 详情请参考426 http://mp.weixin.qq.com/wiki/15/f4109a5e44b4bfbc7eb1337eb739f3e3.html427 """428 event = 'user_scan_product'429 standard = StringField('KeyStandard')430 key = StringField('KeyStr')431 country = StringField('Country')432 province = StringField('Province')433 city = StringField('City')434 sex = IntegerField('Sex')435 scene = IntegerField('Scene')436@register_event('user_scan_product_enter_session')437class UserScanProductEnterSessionEvent(BaseEvent):438 """439 进入公众号事件440 详情请参考441 http://mp.weixin.qq.com/wiki/15/f4109a5e44b4bfbc7eb1337eb739f3e3.html442 """443 event = 'user_scan_product_enter_session'444 standard = StringField('KeyStandard')445 key = StringField('KeyStr')446@register_event('user_scan_product_async')447class UserScanProductAsyncEvent(BaseEvent):448 """449 地理位置信息异步推送事件450 详情请参考451 http://mp.weixin.qq.com/wiki/15/f4109a5e44b4bfbc7eb1337eb739f3e3.html452 """453 event = 'user_scan_product_async'454 standard = StringField('KeyStandard')455 key = StringField('KeyStr')456 region_code = StringField('RegionCode')457@register_event('user_scan_product_verify_action')458class UserScanProductVerifyActionEvent(BaseEvent):459 """460 商品审核结果事件461 详情请参考462 http://mp.weixin.qq.com/wiki/15/f4109a5e44b4bfbc7eb1337eb739f3e3.html463 """464 event = 'user_scan_product_verify_action'465 standard = StringField('KeyStandard')466 key = StringField('KeyStr')467 result = StringField('Result')468 reason = StringField('ReasonMsg')469@register_event('subscribe_scan_product')470class SubscribeScanProductEvent(BaseEvent):471 """472 用户在商品主页中关注公众号事件473 详情请参考474 http://mp.weixin.qq.com/wiki/15/f4109a5e44b4bfbc7eb1337eb739f3e3.html475 """476 event = 'subscribe_scan_product'477 event_key = StringField('EventKey')478 @property479 def scene(self):480 return self.event_key.split('|', 1)[0]481 @property482 def standard(self):483 return self.event_key.split('|')[1]484 @property485 def key(self):486 return self.event_key.split('|')[2]487@register_event('user_authorize_invoice')488class UserAuthorizeInvoiceEvent(BaseEvent):489 """490 用户授权发票事件491 (会包含一个订单号,不成功就失败)492 详情请参考493 https://mp.weixin.qq.com/wiki?id=mp1497082828_r1cI2494 """495 event = 'user_authorize_invoice'496 success_order_id = StringField('SuccOrderId') # 授权成功的订单号497 fail_order_id = StringField('FailOrderId') # 授权失败的订单号498 app_id = StringField('AppId') # 用于接收事件推送的公众号的AppId499 auth_source = StringField('Source') # 授权来源,web表示来自微信内H5,app标识来自app500@register_event('update_invoice_status')501class UpdateInvoiceStatusEvent(BaseEvent):502 """503 发票状态更新事件504 详情请参考505 https://mp.weixin.qq.com/wiki?id=mp1497082828_r1cI2506 """507 event = 'update_invoice_status'508 status = StringField('Status') # 发票报销状态509 card_id = StringField('CardId') # 发票 Card ID510 code = StringField('Code') # 发票 Code511@register_event('submit_invoice_title')512class SubmitInvoiceTitleEvent(BaseEvent):513 """514 用户提交发票抬头事件515 详情请参考516 https://mp.weixin.qq.com/wiki?id=mp1496554912_vfWU0517 """518 event = 'submit_invoice_title'519 title = StringField('title') # 抬头520 phone = StringField('phone') # 联系方式521 tax_no = StringField('tax_no') # 税号522 addr = StringField('addr') # 地址523 bank_type = StringField('bank_type') # 银行类型524 bank_no = StringField('bank_no') # 银行号码525 attach = StringField('attach') # 附加字段...

Full Screen

Full Screen

events.py

Source:events.py Github

copy

Full Screen

...16 DateTimeField17)18from wechatpy.messages import BaseMessage19EVENT_TYPES = {}20def register_event(event_type):21 """22 Register the event class so that they can be accessed from EVENT_TYPES23 :param event_type: Event type24 """25 def register(cls):26 EVENT_TYPES[event_type] = cls27 return cls28 return register29class BaseEvent(BaseMessage):30 """Base class for all events"""31 type = 'event'32 event = ''33@register_event('subscribe')34class SubscribeEvent(BaseEvent):35 """36 用户关注事件37 详情请参阅38 https://mp.weixin.qq.com/wiki?id=mp142114045439 """40 event = 'subscribe'41 key = StringField('EventKey', '')42@register_event('unsubscribe')43class UnsubscribeEvent(BaseEvent):44 """45 用户取消关注事件46 详情请参阅47 https://mp.weixin.qq.com/wiki?id=mp142114045448 """49 event = 'unsubscribe'50@register_event('subscribe_scan')51class SubscribeScanEvent(BaseEvent):52 """53 用户扫描二维码关注事件54 详情请参阅55 https://mp.weixin.qq.com/wiki?id=mp142114045456 """57 event = 'subscribe_scan'58 scene_id = StringField('EventKey')59 ticket = StringField('Ticket')60@register_event('scan')61class ScanEvent(BaseEvent):62 """63 用户扫描二维码事件64 详情请参阅65 https://mp.weixin.qq.com/wiki?id=mp142114045466 """67 event = 'scan'68 scene_id = StringField('EventKey')69 ticket = StringField('Ticket')70@register_event('location')71class LocationEvent(BaseEvent):72 """73 上报地理位置事件74 详情请参阅75 https://mp.weixin.qq.com/wiki?id=mp142114045476 """77 event = 'location'78 latitude = FloatField('Latitude', 0.0)79 longitude = FloatField('Longitude', 0.0)80 precision = FloatField('Precision', 0.0)81@register_event('click')82class ClickEvent(BaseEvent):83 """84 点击菜单拉取消息事件85 详情请参阅86 https://mp.weixin.qq.com/wiki?id=mp142114045487 """88 event = 'click'89 key = StringField('EventKey')90@register_event('view')91class ViewEvent(BaseEvent):92 """93 点击菜单跳转链接事件94 详情请参阅95 https://mp.weixin.qq.com/wiki?id=mp142114045496 """97 event = 'view'98 url = StringField('EventKey')99@register_event('masssendjobfinish')100class MassSendJobFinishEvent(BaseEvent):101 """102 群发消息任务完成事件103 详情请参阅104 https://mp.weixin.qq.com/wiki?id=mp1481187827_i0l21105 """106 id = IntegerField('MsgID', 0)107 event = 'masssendjobfinish'108 status = StringField('Status')109 total_count = IntegerField('TotalCount', 0)110 filter_count = IntegerField('FilterCount', 0)111 sent_count = IntegerField('SentCount', 0)112 error_count = IntegerField('ErrorCount', 0)113@register_event('templatesendjobfinish')114class TemplateSendJobFinishEvent(BaseEvent):115 """116 模板消息任务完成事件117 详情请参阅118 https://mp.weixin.qq.com/wiki?id=mp1433751277119 """120 id = IntegerField('MsgID')121 event = 'templatesendjobfinish'122 status = StringField('Status')123class BaseScanCodeEvent(BaseEvent):124 key = StringField('EventKey')125 scan_code_info = BaseField('ScanCodeInfo', {})126 @property127 def scan_type(self):128 return self.scan_code_info['ScanType']129 @property130 def scan_result(self):131 return self.scan_code_info['ScanResult']132@register_event('scancode_push')133class ScanCodePushEvent(BaseScanCodeEvent):134 """135 扫码推事件136 详情请参阅137 https://mp.weixin.qq.com/wiki?id=mp1421141016138 """139 event = 'scancode_push'140@register_event('scancode_waitmsg')141class ScanCodeWaitMsgEvent(BaseScanCodeEvent):142 """143 扫码推事件且弹出“消息接收中”提示框的事件144 详情请参阅145 https://mp.weixin.qq.com/wiki?id=mp1421141016146 """147 event = 'scancode_waitmsg'148class BasePictureEvent(BaseEvent):149 key = StringField('EventKey')150 pictures_info = BaseField('SendPicsInfo', {})151 @property152 def count(self):153 return int(self.pictures_info['Count'])154 @property155 def pictures(self):156 if self.pictures_info['PicList']:157 items = self.pictures_info['PicList']['item']158 if self.count > 1:159 return items160 return [items]161 return []162@register_event('pic_sysphoto')163class PicSysPhotoEvent(BasePictureEvent):164 """165 弹出系统拍照发图的事件166 详情请参阅167 https://mp.weixin.qq.com/wiki?id=mp1421141016168 """169 event = 'pic_sysphoto'170@register_event('pic_photo_or_album')171class PicPhotoOrAlbumEvent(BasePictureEvent):172 """173 弹出拍照或者相册发图的事件174 详情请参阅175 https://mp.weixin.qq.com/wiki?id=mp1421141016176 """177 event = 'pic_photo_or_album'178@register_event('pic_weixin')179class PicWeChatEvent(BasePictureEvent):180 """181 弹出微信相册发图器的事件182 详情请参阅183 https://mp.weixin.qq.com/wiki?id=mp1421141016184 """185 event = 'pic_weixin'186@register_event('location_select')187class LocationSelectEvent(BaseEvent):188 """189 弹出地理位置选择器的事件190 详情请参阅191 https://mp.weixin.qq.com/wiki?id=mp1421141016192 """193 event = 'location_select'194 key = StringField('EventKey')195 location_info = BaseField('SendLocationInfo', {})196 @property197 def location_x(self):198 return self.location_info['Location_X']199 @property200 def location_y(self):201 return self.location_info['Location_Y']202 @property203 def location(self):204 return self.location_x, self.location_y205 @property206 def scale(self):207 return self.location_info['Scale']208 @property209 def label(self):210 return self.location_info['Label']211 @property212 def poiname(self):213 return self.location_info['Poiname']214@register_event('card_pass_check')215class CardPassCheckEvent(BaseEvent):216 event = 'card_pass_check'217 card_id = StringField('CardId')218@register_event('card_not_pass_check')219class CardNotPassCheckEvent(BaseEvent):220 event = 'card_not_pass_check'221 card_id = StringField('CardId')222@register_event('user_get_card')223class UserGetCardEvent(BaseEvent):224 """225 领取事件推送226 详情请参阅227 https://mp.weixin.qq.com/wiki?id=mp1451025274228 """229 event = 'user_get_card'230 card_id = StringField('CardId')231 is_given_by_friend = IntegerField('IsGiveByFriend')232 friend = StringField('FriendUserName')233 code = StringField('UserCardCode')234 old_code = StringField('OldUserCardCode')235 outer_id = StringField('OuterId')236@register_event('user_del_card')237class UserDeleteCardEvent(BaseEvent):238 """239 卡券删除事件推送240 详情请参阅241 https://mp.weixin.qq.com/wiki?id=mp1451025274242 """243 event = 'user_del_card'244 card_id = StringField('CardId')245 code = StringField('UserCardCode')246@register_event('user_consume_card')247class UserConsumeCardEvent(BaseEvent):248 """249 卡券核销事件推送250 详情请参阅251 https://mp.weixin.qq.com/wiki?id=mp1451025274252 """253 event = 'user_consume_card'254 card_id = StringField('CardId')255 code = StringField('UserCardCode')256 consume_source = StringField('ConsumeSource')257 location_id = StringField('LocationId')258 staff = StringField('StaffOpenId')259@register_event('merchant_order')260class MerchantOrderEvent(BaseEvent):261 event = 'merchant_order'262 order_id = StringField('OrderId')263 order_status = IntegerField('OrderStatus')264 product_id = StringField('ProductId')265 sku_info = StringField('SkuInfo')266@register_event('kf_create_session')267class KfCreateSessionEvent(BaseEvent):268 event = 'kf_create_session'269 account = StringField('KfAccount')270@register_event('kf_close_session')271class KfCloseSessionEvent(BaseEvent):272 event = 'kf_close_session'273 account = StringField('KfAccount')274@register_event('kf_switch_session')275class KfSwitchSessionEvent(BaseEvent):276 event = 'kf_switch_session'277 from_account = StringField('FromKfAccount')278 to_account = StringField('ToKfAccount')279@register_event('device_text')280class DeviceTextEvent(BaseEvent):281 event = 'device_text'282 device_type = StringField('DeviceType')283 device_id = StringField('DeviceID')284 session_id = StringField('SessionID')285 content = Base64DecodeField('Content')286 open_id = StringField('OpenID')287@register_event('device_bind')288class DeviceBindEvent(BaseEvent):289 event = 'device_bind'290 device_type = StringField('DeviceType')291 device_id = StringField('DeviceID')292 session_id = StringField('SessionID')293 content = Base64DecodeField('Content')294 open_id = StringField('OpenID')295@register_event('device_unbind')296class DeviceUnbindEvent(BaseEvent):297 event = 'device_unbind'298 device_type = StringField('DeviceType')299 device_id = StringField('DeviceID')300 session_id = StringField('SessionID')301 content = Base64DecodeField('Content')302 open_id = StringField('OpenID')303@register_event('device_subscribe_status')304class DeviceSubscribeStatusEvent(BaseEvent):305 event = 'device_subscribe_status'306 device_type = StringField('DeviceType')307 device_id = StringField('DeviceID')308 open_id = StringField('OpenID')309 op_type = IntegerField('OpType')310@register_event('device_unsubscribe_status')311class DeviceUnsubscribeStatusEvent(BaseEvent):312 event = 'device_unsubscribe_status'313 device_type = StringField('DeviceType')314 device_id = StringField('DeviceID')315 open_id = StringField('OpenID')316 op_type = IntegerField('OpType')317@register_event('shakearoundusershake')318class ShakearoundUserShakeEvent(BaseEvent):319 event = 'shakearound_user_shake'320 _chosen_beacon = BaseField('ChosenBeacon', {})321 _around_beacons = BaseField('AroundBeacons', {})322 @property323 def chosen_beacon(self):324 beacon = self._chosen_beacon325 if not beacon:326 return {}327 return {328 'uuid': beacon['Uuid'],329 'major': beacon['Major'],330 'minor': beacon['Minor'],331 'distance': float(beacon['Distance']),332 }333 @property334 def around_beacons(self):335 beacons = self._around_beacons336 if not beacons:337 return []338 ret = []339 for beacon in beacons['AroundBeacon']:340 ret.append({341 'uuid': beacon['Uuid'],342 'major': beacon['Major'],343 'minor': beacon['Minor'],344 'distance': float(beacon['Distance']),345 })346 return ret347@register_event('poi_check_notify')348class PoiCheckNotifyEvent(BaseEvent):349 event = 'poi_check_notify'350 poi_id = StringField('PoiId')351 uniq_id = StringField('UniqId')352 result = StringField('Result')353 message = StringField('Msg')354@register_event('wificonnected')355class WiFiConnectedEvent(BaseEvent):356 event = 'wificconnected'357 connect_time = IntegerField('ConnectTime')358 expire_time = IntegerField('ExpireTime')359 vendor_id = StringField('VendorId')360 shop_id = StringField('PlaceId')361 bssid = StringField('DeviceNo')362# ============================================================================363# 微信认证事件推送364# ============================================================================365@register_event('qualification_verify_success')366class QualificationVerifySuccessEvent(BaseEvent):367 """368 资质认证成功事件369 详情请参阅370 https://mp.weixin.qq.com/wiki?id=mp1455785130371 """372 event = 'qualification_verify_success'373 expired_time = DateTimeField('ExpiredTime')374@register_event('qualification_verify_fail')375class QualificationVerifyFailEvent(BaseEvent):376 """377 资质认证失败事件378 详情请参阅379 https://mp.weixin.qq.com/wiki?id=mp1455785130380 """381 event = 'qualification_verify_fail'382 fail_time = DateTimeField('FailTime')383 fail_reason = StringField('FailReason')384@register_event('naming_verify_success')385class NamingVerifySuccessEvent(BaseEvent):386 """387 名称认证成功事件388 详情请参阅389 https://mp.weixin.qq.com/wiki?id=mp1455785130390 """391 event = 'naming_verify_success'392 expired_time = DateTimeField('ExpiredTime')393@register_event('naming_verify_fail')394class NamingVerifyFailEvent(BaseEvent):395 """396 名称认证失败事件397 客户端不打勾,但仍有接口权限。详情请参阅398 https://mp.weixin.qq.com/wiki?id=mp1455785130399 """400 event = 'naming_verify_fail'401 fail_time = DateTimeField('FailTime')402 fail_reason = StringField('FailReason')403@register_event('annual_renew')404class AnnualRenewEvent(BaseEvent):405 """406 年审通知事件407 详情请参阅408 https://mp.weixin.qq.com/wiki?id=mp1455785130409 """410 event = 'annual_renew'411 expired_time = DateTimeField('ExpiredTime')412@register_event('verify_expired')413class VerifyExpiredEvent(BaseEvent):414 """415 认证过期失效通知416 详情请参阅417 https://mp.weixin.qq.com/wiki?id=mp1455785130418 """419 event = 'verify_expired'420 expired_time = DateTimeField('ExpiredTime')421@register_event('user_scan_product')422class UserScanProductEvent(BaseEvent):423 """424 打开商品主页事件425 详情请参考426 https://mp.weixin.qq.com/wiki?id=mp1455872179427 """428 event = 'user_scan_product'429 standard = StringField('KeyStandard')430 key = StringField('KeyStr')431 country = StringField('Country')432 province = StringField('Province')433 city = StringField('City')434 sex = IntegerField('Sex')435 scene = IntegerField('Scene')436@register_event('user_scan_product_enter_session')437class UserScanProductEnterSessionEvent(BaseEvent):438 """439 进入公众号事件440 详情请参考441 https://mp.weixin.qq.com/wiki?id=mp1455872179442 """443 event = 'user_scan_product_enter_session'444 standard = StringField('KeyStandard')445 key = StringField('KeyStr')446@register_event('user_scan_product_async')447class UserScanProductAsyncEvent(BaseEvent):448 """449 地理位置信息异步推送事件450 详情请参考451 https://mp.weixin.qq.com/wiki?id=mp1455872179452 """453 event = 'user_scan_product_async'454 standard = StringField('KeyStandard')455 key = StringField('KeyStr')456 region_code = StringField('RegionCode')457@register_event('user_scan_product_verify_action')458class UserScanProductVerifyActionEvent(BaseEvent):459 """460 商品审核结果事件461 详情请参考462 https://mp.weixin.qq.com/wiki?id=mp1455872179463 """464 event = 'user_scan_product_verify_action'465 standard = StringField('KeyStandard')466 key = StringField('KeyStr')467 result = StringField('Result')468 reason = StringField('ReasonMsg')469@register_event('subscribe_scan_product')470class SubscribeScanProductEvent(BaseEvent):471 """472 用户在商品主页中关注公众号事件473 详情请参考474 https://mp.weixin.qq.com/wiki?id=mp1455872179475 """476 event = 'subscribe_scan_product'477 event_key = StringField('EventKey')478 @property479 def scene(self):480 return self.event_key.split('|', 1)[0]481 @property482 def standard(self):483 return self.event_key.split('|')[1]484 @property485 def key(self):486 return self.event_key.split('|')[2]487@register_event('user_authorize_invoice')488class UserAuthorizeInvoiceEvent(BaseEvent):489 """490 用户授权发票事件491 (会包含一个订单号,不成功就失败)492 详情请参考493 https://mp.weixin.qq.com/wiki?id=mp1497082828_r1cI2494 """495 event = 'user_authorize_invoice'496 success_order_id = StringField('SuccOrderId') # 授权成功的订单号497 fail_order_id = StringField('FailOrderId') # 授权失败的订单号498 app_id = StringField('AppId') # 用于接收事件推送的公众号的AppId499 auth_source = StringField('Source') # 授权来源,web表示来自微信内H5,app标识来自app500@register_event('update_invoice_status')501class UpdateInvoiceStatusEvent(BaseEvent):502 """503 发票状态更新事件504 详情请参考505 https://mp.weixin.qq.com/wiki?id=mp1497082828_r1cI2506 """507 event = 'update_invoice_status'508 status = StringField('Status') # 发票报销状态509 card_id = StringField('CardId') # 发票 Card ID510 code = StringField('Code') # 发票 Code511@register_event('submit_invoice_title')512class SubmitInvoiceTitleEvent(BaseEvent):513 """514 用户提交发票抬头事件515 详情请参考516 https://mp.weixin.qq.com/wiki?id=mp1496554912_vfWU0517 """518 event = 'submit_invoice_title'519 title = StringField('title') # 抬头520 phone = StringField('phone') # 联系方式521 tax_no = StringField('tax_no') # 税号522 addr = StringField('addr') # 地址523 bank_type = StringField('bank_type') # 银行类型524 bank_no = StringField('bank_no') # 银行号码525 attach = StringField('attach') # 附加字段526 title_type = StringField('title_type') # 抬头类型,个人InvoiceUserTitlePersonType, 公司InvoiceUserTitleBusinessType527@register_event('user_enter_tempsession')528class UserEnterTempSessionEvent(BaseEvent):529 """530 小程序用户进入客服消息531 详情请参阅532 https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/customer-message/receive.html533 """534 event = 'user_enter_tempsession'535 session_from = StringField('SessionFrom')536@register_event('view_miniprogram')537class ViewMiniProgramEvent(BaseEvent):538 """539 从菜单进入小程序事件540 """541 event = 'view_miniprogram'542 page_path = StringField('EventKey') # 小程序路径...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Lemoncheesecake automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful