Skip to content

Commit

Permalink
close #122
Browse files Browse the repository at this point in the history
以及一些注释
  • Loading branch information
yjqiang committed Apr 27, 2019
1 parent ab182dd commit 2643501
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
19 changes: 14 additions & 5 deletions conf/ctrl.sample.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
[print_control]
[print_control] # 打印
# 控制default_monitor_roomid所指认的room弹幕打印(pythonista ios可以彩打哦)
danmu = false

[task_control]


[global_task_control] # 总体的task控制
# 清理即将过期礼物,请true之后一定要把紧随其后的clean-expiring-gift2room设置为真实房间号
clean-expiring-gift = false
# 单位秒,这是控制定义过期礼物何时为“过期”的阈值
Expand All @@ -16,7 +18,7 @@ silver2coin = false

# 自动投满佩戴勋章当日亲密度
send2wearing-medal = false
# 短房间号(与投满亲密度send2wearing-medal的一起使用)
# 短房间号(与投满亲密度send2wearing-medal的一起使用)。注意⚠️如果只需要投佩戴的勋章,不用修改send2medal
send2medal = []

# 输入数字 0-5 表示主站每日自动投币
Expand All @@ -26,12 +28,19 @@ fetchrule = "bilitop"
# up主list([123]或者[123, 234, 123]等)
mid = [ 207539637,]

[dyn_raffle]
# 抽奖@的人,格式为 uid = "用户名"(例如 {332704117 = "白上吹雪Official", 339567211 = "赤井心Official"})
# 要求被@的人不能经常改名字,这样也就说明这些用户也可控,即不得随意骚扰他人
dyn_lottery_friends = {}

[other_control]


[custom_task_control] # 与global_task_control对应。针对某个具体用户的自定义(如果用户没有自定义的部分,就使用前面global那里的配置)
[custom_task_control.username] # sub-table({'custom_task_control': {'user0': {}, 'user1': {}}}),name与user.toml内的相同
givecoin = 5



[other_control] # 其他细节控制
# 默认监听房间号(用于打印弹幕功能等)
default_monitor_roomid = 23058

Expand Down
12 changes: 9 additions & 3 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,17 @@
dict_ctrl = conf_loader.read_ctrl()
printer.init_config(dict_color, dict_ctrl['print_control']['danmu'])

# user设置
users = []
task_control = dict_ctrl['task_control']
dyn_lottery_friends = [(str(uid), name) for uid, name in dict_ctrl['dyn_raffle']['dyn_lottery_friends'].items()]
global_task_control = dict_ctrl['global_task_control']
custom_task_control = dict_ctrl['custom_task_control']
for i, user_info in enumerate(dict_user['users']):
users.append(User(i, user_info, task_control, dict_bili, dyn_lottery_friends))
username = user_info['username']
if username in custom_task_control:
task_control = {**global_task_control, **custom_task_control[username]}
else:
task_control = global_task_control
users.append(User(i, user_info, task_control, dict_bili))
notifier.set_values(loop)
notifier.set_users(users)

Expand Down
3 changes: 2 additions & 1 deletion user.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


class User:
def __init__(self, id, dict_user, task_ctrl, dict_bili, dyn_lottery_friends):
def __init__(self, id, dict_user, task_ctrl, dict_bili):
self.id = id
self.name = dict_user['username']
self.password = dict_user['password']
Expand All @@ -27,6 +27,7 @@ def __init__(self, id, dict_user, task_ctrl, dict_bili, dyn_lottery_friends):
self.update_login_data(dict_user)
self.list_delay = []
self.repost_del_lock = asyncio.Lock() # 在follow与unfollow过程中必须保证安全(repost和del整个过程加锁)
dyn_lottery_friends = [(str(uid), name) for uid, name in task_ctrl['dyn_lottery_friends'].items()]
self.dyn_lottery_friends = dyn_lottery_friends # list (uid, name)
self.storm_lock = asyncio.Semaphore(1) # 用于控制同时进行的风暴数目(注意是单个用户的)

Expand Down

0 comments on commit 2643501

Please sign in to comment.