77import utils
88from printer import Printer
99
10+
1011class Tasks ():
1112
1213 def __init__ (self ):
1314 fileDir = os .path .dirname (os .path .realpath ('__file__' ))
1415 file_user = fileDir + "/conf/user.conf"
1516 self .dic_user = configloader .load_user (file_user )
16-
17+
1718 # 获取每日包裹奖励
1819 async def Daily_bag (self ):
1920 response = await bilibili ().get_dailybag ()
2021 json_response = await response .json ()
21- for i in range (0 ,len (json_response ['data' ]['bag_list' ])):
22- Printer ().printlist_append ([ 'join_lottery' , '' , 'user' , "获得-" + json_response [ 'data' ][ 'bag_list' ][ i ][ 'bag_name' ] + "-成功" ], True )
23-
22+ for i in range (0 , len (json_response ['data' ]['bag_list' ])):
23+ Printer ().printlist_append (
24+ [ 'join_lottery' , '' , 'user' , "获得-" + json_response [ 'data' ][ 'bag_list' ][ i ][ 'bag_name' ] + "-成功" ], True )
2425
2526 def CurrentTime (self ):
2627 currenttime = str (int (time .mktime (datetime .datetime .now ().timetuple ())))
@@ -30,44 +31,45 @@ def CurrentTime(self):
3031 async def DoSign (self ):
3132 response = await bilibili ().get_dosign ()
3233 temp = await response .json (content_type = None )
33- Printer ().printlist_append (['join_lottery' , '' , 'user' , "签到状态:" ,temp ['msg' ]],True )
34+ Printer ().printlist_append (['join_lottery' , '' , 'user' , "签到状态:" , temp ['msg' ]], True )
3435
3536 # 领取每日任务奖励
3637 async def Daily_Task (self ):
3738 response2 = await bilibili ().get_dailytask ()
3839 json_response2 = await response2 .json ()
39- Printer ().printlist_append (['join_lottery' , '' , 'user' , "双端观看直播:" , json_response2 ["msg" ]],True )
40+ Printer ().printlist_append (['join_lottery' , '' , 'user' , "双端观看直播:" , json_response2 ["msg" ]], True )
4041
4142 # 应援团签到
4243 async def link_sign (self ):
4344 response = bilibili ().get_grouplist ()
4445 check = len (response .json ()['data' ]['list' ])
4546 group_id_list = []
4647 owner_uid_list = []
47- for i in range (0 ,check ):
48+ for i in range (0 , check ):
4849 group_id = response .json ()['data' ]['list' ][i ]['group_id' ]
4950 owner_uid = response .json ()['data' ]['list' ][i ]['owner_uid' ]
5051 group_id_list .append (group_id )
5152 owner_uid_list .append (owner_uid )
52- for (i1 ,i2 ) in zip (group_id_list ,owner_uid_list ):
53+ for (i1 , i2 ) in zip (group_id_list , owner_uid_list ):
5354 response = bilibili ().assign_group (i1 , i2 )
5455 if response .json ()['code' ] == 0 :
5556 if (response .json ()['data' ]['status' ]) == 1 :
56- Printer ().printlist_append (['join_lottery' , '' , 'user' , "# 应援团 %s 已应援过" % (i1 ) ])
57+ Printer ().printlist_append (['join_lottery' , '' , 'user' , "# 应援团 %s 已应援过" % (i1 )])
5758 if (response .json ()['data' ]['status' ]) == 0 :
58- Printer ().printlist_append (['join_lottery' , '' , 'user' , "# 应援团 %s 应援成功,获得 %s 点亲密度" % (i1 , response .json ()['data' ]['add_num' ])])
59+ Printer ().printlist_append (['join_lottery' , '' , 'user' ,
60+ "# 应援团 %s 应援成功,获得 %s 点亲密度" % (i1 , response .json ()['data' ]['add_num' ])])
5961 else :
60- Printer ().printlist_append (['join_lottery' , '' , 'user' ,"# 应援团 %s 应援失败" % (i1 )])
62+ Printer ().printlist_append (['join_lottery' , '' , 'user' , "# 应援团 %s 应援失败" % (i1 )])
6163
6264 async def send_gift (self ):
6365 if self .dic_user ['gift' ]['on/off' ] == '1' :
64- argvs ,x = await utils .fetch_bag_list (printer = False )
65- for i in range (0 ,len (argvs )):
66+ argvs , x = await utils .fetch_bag_list (printer = False )
67+ for i in range (0 , len (argvs )):
6668 giftID = argvs [i ][0 ]
6769 giftNum = argvs [i ][1 ]
6870 bagID = argvs [i ][2 ]
6971 roomID = self .dic_user ['gift' ]['send_to_room' ]
70- await utils .send_gift_web (roomID ,giftID ,giftNum ,bagID )
72+ await utils .send_gift_web (roomID , giftID , giftNum , bagID )
7173 if not argvs :
7274 Printer ().printlist_append (['join_lottery' , '' , 'user' , "没有将要过期的礼物~" ])
7375
@@ -87,7 +89,7 @@ async def auto_send_gift(self):
8789 day_limit = a [2 ]
8890 left_num = int (day_limit ) - int (today_feed )
8991 calculate = 0
90- for i in range (0 ,len (temp )):
92+ for i in range (0 , len (temp )):
9193 gift_id = int (temp [i ][0 ])
9294 gift_num = int (temp [i ][1 ])
9395 bag_id = int (temp [i ][2 ])
@@ -96,16 +98,16 @@ async def auto_send_gift(self):
9698 if (gift_num * (temp_dic [gift_id ] / 100 ) < left_num ):
9799 calculate = calculate + temp_dic [gift_id ] / 100 * gift_num
98100 tmp2 = temp_dic [gift_id ] / 100 * gift_num
99- await utils .send_gift_web (roomid ,gift_id ,gift_num ,bag_id )
100- left_num = left_num - tmp2
101+ await utils .send_gift_web (roomid , gift_id , gift_num , bag_id )
102+ left_num = left_num - tmp2
101103 elif left_num - temp_dic [gift_id ] / 100 >= 0 :
102104 tmp = (left_num ) / (temp_dic [gift_id ] / 100 )
103105 tmp1 = (temp_dic [gift_id ] / 100 ) * int (tmp )
104106 calculate = calculate + tmp1
105107 await utils .send_gift_web (roomid , gift_id , tmp , bag_id )
106108 left_num = left_num - tmp1
107109 Printer ().printlist_append (['join_lottery' , '' , 'user' , "自动送礼共送出亲密度为%s的礼物" % int (calculate )])
108-
110+
109111 async def doublegain_coin2silver (self ):
110112 if self .dic_user ['doublegain_coin2silver' ]['on/off' ] == "1" :
111113 response0 = await bilibili ().request_doublegain_coin2silver ()
@@ -121,7 +123,7 @@ async def sliver2coin(self):
121123 json_response1 = await response1 .json ()
122124 json_response = await response .json ()
123125
124- Printer ().printlist_append (['join_lottery' , '' , 'user' ,"" , json_response ['msg' ]])
126+ Printer ().printlist_append (['join_lottery' , '' , 'user' , "" , json_response ['msg' ]])
125127 Printer ().printlist_append (['join_lottery' , '' , 'user' , "" , json_response1 ['msg' ]])
126128
127129 async def run (self ):
0 commit comments