-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathmain.py
86 lines (74 loc) · 2.08 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import sys
sys.path.append("Src")
import time
import asyncio
import Console
import threading
import Danmu_Monitor
from Raffle_Handler import RaffleHandler
import platform
if platform.system() == "Windows":
from Windows_Log import Log
else:
from Unix_Log import Log
from Auth import Auth
from Capsule import Capsule
from Coin2Silver import Coin2Silver
from GiftSend import GiftSend
from Group import Group
from Heart import Heart
from Silver2Coin import Silver2Coin
from SilverBox import SilverBox
from Statistics import Statistics
from Task import Task
from Sentence import Sentence
from Timer import Timer
from config import config
# 初始化所有class
Auth = Auth()
Capsule = Capsule()
Coin2Silver = Coin2Silver()
GiftSend = GiftSend()
Group = Group()
Heart = Heart()
Silver2Coin = Silver2Coin()
SilverBox = SilverBox()
Task = Task()
rafflehandler = RaffleHandler()
if config["Other"]["INFO_MESSAGE"] != "False":
Log.info("BiliBiliHelper Python Version Beta 0.0.1")
if config["Other"]["SENTENCE"] != "False":
Log.info(Sentence().get_sentence())
loop = asyncio.get_event_loop()
timer = Timer(loop)
console = Console.Console(loop)
area_ids = [1,2,3,4,5,6,]
Statistics(len(area_ids))
danmu_tasks = [Danmu_Monitor.run_Danmu_Raffle_Handler(i) for i in area_ids]
other_tasks = [
rafflehandler.run()
]
console_thread = threading.Thread(target=console.cmdloop)
console_thread.start()
# 先登陆一次,防止速度太快导致抽奖模块出错
Auth.work()
def daily_job():
while (1):
Auth.work()
Capsule.work()
Coin2Silver.work()
GiftSend.work()
Group.work()
Heart.work()
Silver2Coin.work()
SilverBox.work()
Task.work()
# 休息0.5s,减少CPU占用
time.sleep(0.5)
daily_job_thread = threading.Thread(target=daily_job)
daily_job_thread.start()
if config["Function"]["RAFFLE_HANDLER"] != "False":
loop.run_until_complete(asyncio.wait(danmu_tasks+other_tasks))
console_thread.join()
daily_job_thread.join()
loop.close()