This repository has been archived by the owner on Jul 2, 2019. It is now read-only.
forked from Dawnnnnnn/bilibili-live-tools
-
Notifications
You must be signed in to change notification settings - Fork 23
/
bili_console.py
170 lines (137 loc) · 6.19 KB
/
bili_console.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
import sys
import utils
from statistics import Statistics
from connect import connect
import printer
from configloader import ConfigLoader
from rafflehandler import Rafflehandler
import rafflehandler
import OnlineHeart
import asyncio
from cmd import Cmd
def fetch_real_roomid(roomid):
if roomid:
real_roomid = [[roomid], utils.check_room]
else:
real_roomid = ConfigLoader().dic_user['other_control']['default_monitor_roomid']
return real_roomid
class Biliconsole(Cmd):
prompt = ''
def __init__(self, loop):
self.loop = loop
Cmd.__init__(self)
def guide_of_console(self):
print(' ___________________ ')
print('| 欢迎使用本控制台 |')
print('| 1 输出本次抽奖统计 |')
print('| 2 查看目前拥有礼物的统计 |')
print('| 3 查看持有勋章状态 |')
print('| 4 获取直播个人的基本信息 |')
print('| 5 检查今日任务的完成情况 |')
print('| 6 模拟电脑网页端发送弹幕 |')
print('| 7 直播间的长短号码的转化 |')
print('| 8 手动送礼物到指定直播间 |')
print('| 9 切换监听的直播间 |')
print('|10 控制弹幕的开关 |')
print('|11 房间号码查看主播 |')
print('|12 当前拥有的扭蛋币 |')
print('|13 开扭蛋币(一、十、百) |')
print('|16 尝试一次实物抽奖 |')
print('  ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ')
def default(self, line):
self.guide_of_console()
def emptyline(self):
self.guide_of_console()
def do_1(self, line):
Statistics.getlist()
def do_2(self, line):
self.append2list_console(utils.fetch_bag_list)
def do_3(self, line):
self.append2list_console(utils.fetch_medal)
def do_4(self, line):
self.append2list_console(utils.fetch_user_info)
def do_5(self, line):
self.append2list_console(utils.check_taskinfo)
def do_6(self, line):
msg = input('请输入要发送的信息:')
roomid = input('请输入要发送的房间号:')
real_roomid = fetch_real_roomid(roomid)
self.append2list_console([[msg, real_roomid], utils.send_danmu_msg_web])
def do_7(self, line):
roomid = input('请输入要转化的房间号:')
if not roomid:
roomid = ConfigLoader().dic_user['other_control']['default_monitor_roomid']
self.append2list_console([[roomid], utils.check_room])
def do_8(self, line):
self.append2list_console([[True], utils.fetch_bag_list])
bagid = input('请输入要发送的礼物编号:')
# print('是谁', giftid)
giftnum = int(input('请输入要发送的礼物数目:'))
roomid = input('请输入要发送的房间号:')
real_roomid = fetch_real_roomid(roomid)
self.append2list_console([[real_roomid, giftnum, bagid], utils.send_gift_web])
def do_9(self, line):
roomid = input('请输入roomid')
real_roomid = fetch_real_roomid(roomid)
self.append2list_console([[real_roomid], connect.reconnect])
def do_10(self, line):
new_words = input('弹幕控制')
if new_words == 'T':
printer.control_printer(True, None)
else:
printer.control_printer(False, None)
def do_11(self, line):
roomid = input('请输入roomid')
real_roomid = fetch_real_roomid(roomid)
self.append2list_console([[real_roomid], utils.fetch_liveuser_info])
def do_12(self, line):
self.append2list_console(utils.fetch_capsule_info)
def do_13(self, line):
count = input('请输入要开的扭蛋数目(1或10或100)')
self.append2list_console([[count], utils.open_capsule])
def do_14(self, line):
if sys.platform == 'ios':
roomid = input('请输入roomid')
real_roomid = fetch_real_roomid(roomid)
self.append2list_console([[real_roomid], utils.watch_living_video])
return
print('仅支持ios')
def do_15(self, line):
self.append2list_console(utils.TitleInfo)
def do_16(self, line):
self.append2list_console(OnlineHeart.draw_lottery)
def do_17(self, line):
new_words = input('debug控制')
if new_words == 'T':
printer.control_printer(None, True)
else:
printer.control_printer(None, True)
def do_18(self, line):
video_id = input('请输入av号')
num = input('输入数目')
self.append2list_console([[int(video_id), int(num)], utils.GiveCoin2Av])
def do_19(self, line):
try:
roomid = int(input('输入roomid'))
self.append2list_console([[(roomid,), rafflehandler.handle_1_room_guard], rafflehandler.Rafflehandler.Put2Queue_wait])
except:
pass
def do_check(self, line):
Rafflehandler.getlist()
Statistics.checklist()
def append2list_console(self, request):
asyncio.run_coroutine_threadsafe(self.excute_async(request), self.loop)
# inst.loop.call_soon_threadsafe(inst.queue_console.put_nowait, request)
async def excute_async(self, i):
if isinstance(i, list):
# 对10号单独简陋处理
for j in range(len(i[0])):
if isinstance(i[0][j], list):
# print('检测')
i[0][j] = await i[0][j][1](*(i[0][j][0]))
if i[1] == 'normal':
i[2](*i[0])
else:
await i[1](*i[0])
else:
await i()