Skip to content
天子方辰 edited this page May 15, 2024 · 36 revisions

Blueprint

Database: Amazon RDS mysql

credentials 账号登录信息

('ac_time_value', 'varchar'), 
('bili_jct', 'varchar'), 
('buvid3', 'varchar'), 
('sessdata', 'varchar'), 
('dedeuserid', 'BIGINT UNSIGNED'), 
('master', 'varchar')

liveTime 开播下播时间记录,用于在录播放出后发评论

('room_id', 'int'), 
('start', 'timestamp'), 
('end', 'timestamp’), 
(‘summary’, ’varchar’)

danmu 记录订阅直播间的所有弹幕

('name', 'varchar'), 
('uid', 'BIGINT UNSIGNED'), 
('text', 'varchar'), 
('type', 'int'),
(‘medal_id’, 'int'), 
(‘medal_level’, ‘int’), 
('time', 'timestamp’), 
('room_id', 'int'),
('danmu_id', 'varchar') UNIQUE

banned 记录被封禁的用户

('uid', 'BIGINT UNSIGNED'), 
('reason', 'varchar'), 
('time', 'timestamp’), 
('room_id', 'int')

ban_history 记录曾经被封禁过的用户

('uid', 'BIGINT UNSIGNED'), 
('room_id', 'int')

postProgress 记录最新发表评论的录播视频

('room_id', 'int'),
('aid', 'int')

checkin 记录用户考勤 (<master_uid> 用来记录当前头位置, slot 0-29 形成环)

('uid', 'BIGINT UNSIGNED'),       \ UNI
('room_id', 'int'),   / QUE
('name', 'varchar')
('slot_0', 'int'),
('slot_1', 'int'),
('slot_2', 'int'),
('slot_3', 'int'),
('slot_4', 'int'),
('slot_5', 'int'),
('slot_6', 'int'),
('slot_7', 'int'),
('slot_8', 'int'),
('slot_9', 'int'),
('slot_10', 'int'),
('slot_11', 'int'),
('slot_12', 'int'),
('slot_13', 'int'),
('slot_14', 'int'),
('slot_15', 'int'),
('slot_16', 'int'),
('slot_17', 'int'),
('slot_18', 'int'),
('slot_19', 'int'),
('slot_20', 'int'),
('slot_21', 'int'),
('slot_22', 'int'),
('slot_23', 'int'),
('slot_24', 'int'),
('slot_25', 'int'),
('slot_26', 'int'),
('slot_27', 'int'),
('slot_28', 'int'),
('slot_29', 'int'),
('count', 'int'), AS SUM(slot_0 ... slot_29)
('all_time', 'int')

blacklist 黑名单

('uid', 'BIGINT UNSIGNED')

guard 上舰记录

(room_id int, uid BIGINT UNSIGNED, username varchar(255), guard_name varchar(255), guard_num int)

Configs: EC2 ~/BiliLiveManager/Configs

Configs/mysql.json

Configs/masterCongid.json

Configs/config{room_id}.json

Functions: EC2 ~/BiliLiveManager/

master.py

  • @danmu.on("DANMU_MSG")
    • Ban -> send to database
    • keyword -> send to database
  • @danmu.on(“GIFT”)
    • Unban -> delete from database
  • @room.on("LIVE")
    • send start email
    • say hello
    • update credentials
  • @room.on(“PREPARING”)
    • send summary email
    • store timestamped summary in database

cron jobs

  • [hourly] if renqi: send renqi reminder every hour
  • [hourly] if new video: pull summary from database then comment then remove old records in database

deployer.py

  • 根据私信提供的信息生成config<room_id>.json编辑masterConfig.py
    • subscribe: (required field only, leave optionals to update)
    • update
  • 重启 master.py (仅添加房间需要)

Utils: EC2 ~/BiliLiveManager/

Summarizer.py

def summarize(room_id: int, roomConfig: dict) -> (str, str, datetime.datetime, datetime.datetime):

EmailSender.py

async def send_mail_async(sender:str, to:list[str], subject:str, text:str, textType='plain'):

CredentialGetter.py

def getCredential(user: str) -> Credential: