MCPcopy Create free account
hub / github.com/smallfawn/QLScriptPublic / handle_welfare_task

Method handle_welfare_task

daily/sfsy.py:783–812  ·  view source on GitHub ↗

处理领取生活特权任务

(self, task_title: str)

Source from the content-addressed store, hash-verified

781 return False
782
783 def handle_welfare_task(self, task_title: str) -> bool:
784 """处理领取生活特权任务"""
785 self.logger.info('正在获取生活特权列表...')
786
787 welfare_list = self.get_welfare_list()
788 if not welfare_list:
789 self.logger.warning('没有可领取的生活特权')
790 return False
791
792 self.logger.info(f'找到 {len(welfare_list)} 个可领取的生活特权')
793
794 # 尝试领取第一个可用的特权
795 for welfare in welfare_list:
796 goods_no = welfare.get('goodsNo')
797 goods_name = welfare.get('goodsName')
798 show_name = welfare.get('showName')
799
800 if not goods_no:
801 continue
802
803 display_name = f"{show_name} - {goods_name}" if show_name else goods_name
804
805 # 使用任务的 taskCode
806 if self.receive_welfare(goods_no, display_name, self.taskCode):
807 return True
808
809 # 如果领取失败,等待一下再尝试下一个
810 time.sleep(1)
811
812 return False
813
814 def run_all_tasks(self) -> tuple[int, int]:
815 """执行所有任务

Callers 1

run_all_tasksMethod · 0.95

Calls 6

get_welfare_listMethod · 0.95
receive_welfareMethod · 0.95
warningMethod · 0.80
sleepMethod · 0.80
infoMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected