Skip to content

Commit

Permalink
新增积分表,暂时只做了b站的签到部分功能,GUI未适配
Browse files Browse the repository at this point in the history
  • Loading branch information
Ikaros-521 committed Sep 16, 2023
1 parent 1bac23b commit 20680a9
Show file tree
Hide file tree
Showing 11 changed files with 665 additions and 240 deletions.
6 changes: 6 additions & 0 deletions bilibili.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def schedule_task(index):
content = random_copy

data = {
"platform": "哔哩哔哩",
"username": None,
"content": content
}
Expand Down Expand Up @@ -260,6 +261,7 @@ async def _(event):
logging.info(f"[{user_name}]: {content}")

data = {
"platform": "哔哩哔哩",
"username": user_name,
"content": content
}
Expand All @@ -283,6 +285,7 @@ async def _(event):
logging.info(f"用户:{user_name} 赠送 {combo_num}{gift_name},总计 {combo_total_coin}电池")

data = {
"platform": "哔哩哔哩",
"gift_name": gift_name,
"username": user_name,
"num": combo_num,
Expand Down Expand Up @@ -313,6 +316,7 @@ async def _(event):
logging.info(f"用户:{user_name} 赠送 {num}{gift_name},单价 {discount_price}电池,总计 {combo_total_coin}电池")

data = {
"platform": "哔哩哔哩",
"gift_name": gift_name,
"username": user_name,
"num": num,
Expand Down Expand Up @@ -344,6 +348,7 @@ async def _(event):
logging.info(f"用户:{uname} 发送 {price}元 SC:{message}")

data = {
"platform": "哔哩哔哩",
"gift_name": "SC",
"username": uname,
"num": 1,
Expand Down Expand Up @@ -373,6 +378,7 @@ async def _(event):
add_username_to_last_username_list(user_name)

data = {
"platform": "哔哩哔哩",
"username": user_name,
"content": "进入直播间"
}
Expand Down
97 changes: 97 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -403,5 +403,102 @@
"web_captions_printer": {
"enable": false,
"api_ip_port": "http://127.0.0.1:5500"
},
"integral": {
"enable": false,
"entrance": {
"enable": true,
"get_integral": 1,
"copywriting": [
{
"entrance_num_interval": "0-3",
"copywriting": [
"{user_name},感谢您的观看,获得{get_integral}点积分",
"欢迎{user_name},获得{get_integral}点积分"
]
},
{
"entrance_num_interval": "4-29",
"copywriting": [
"{user_name},感谢您的观看,获得{get_integral}点积分",
"欢迎{user_name},今天是您看我的{entrance_num}天,我很开心"
]
},
{
"entrance_num_interval": "30-666666",
"copywriting": [
"{user_name},今天是您看我的{entrance_num}天,获得{get_integral}点积分",
"非常感谢{user_name}的陪伴,有您这样的粉丝,主播生涯也是没有遗憾了"
]
}
]
},
"gift": {
"enable": true,
"get_integral_proportion": 10,
"copywriting": [
{
"gift_price_interval": "0-1",
"copywriting": [
"感谢{user_name}的{gift_name},获得{get_integral}点积分",
"感谢{user_name}的{gift_name}"
]
},
{
"gift_price_interval": "1.01-10",
"copywriting": [
"感谢{user_name}的{gift_name},老板大气,获得{get_integral}点积分",
"感谢{user_name}的{gift_name},老板大气,获得{get_integral}点积分"
]
},
{
"gift_price_interval": "10.01-88888888",
"copywriting": [
"感谢{user_name}的{gift_name},获得{get_integral}点积分",
"感谢{user_name}的{gift_name},您真是在下的衣食父母啊"
]
}
]
},
"sign": {
"enable": true,
"cmd": [
"签到",
"打卡"
],
"get_integral": 1,
"copywriting": [
{
"sign_num_interval": "0-3",
"copywriting": [
"{user_name}打卡成功,获得{get_integral}点积分,您已打卡{sign_num}天",
"{user_name}打卡成功喵,获得{get_integral}点积分,感谢您{sign_num}天的陪伴"
]
},
{
"sign_num_interval": "4-30",
"copywriting": [
"{user_name}打卡成功,获得{get_integral}点积分,您已打卡{sign_num}天",
"{user_name}打卡成功喵,获得{get_integral}点积分,感谢您{sign_num}天的陪伴"
]
},
{
"sign_num_interval": "31-66666",
"copywriting": [
"非常感谢{user_name}的陪伴,有您这样的粉丝,主播生涯也是没有遗憾了",
"{user_name}打卡成功喵,获得{get_integral}点积分,感谢您{sign_num}天的陪伴"
]
}
]
},
"crud": {
"query": {
"enable": true,
"cmd": [
"我的积分",
"查询积分"
]
}
}
}
}
97 changes: 97 additions & 0 deletions config.json.bak
Original file line number Diff line number Diff line change
Expand Up @@ -403,5 +403,102 @@
"web_captions_printer": {
"enable": false,
"api_ip_port": "http://127.0.0.1:5500"
},
"integral": {
"enable": false,
"entrance": {
"enable": true,
"get_integral": 1,
"copywriting": [
{
"entrance_num_interval": "0-3",
"copywriting": [
"{user_name},感谢您的观看,获得{get_integral}点积分",
"欢迎{user_name},获得{get_integral}点积分"
]
},
{
"entrance_num_interval": "4-29",
"copywriting": [
"{user_name},感谢您的观看,获得{get_integral}点积分",
"欢迎{user_name},今天是您看我的{entrance_num}天,我很开心"
]
},
{
"entrance_num_interval": "30-666666",
"copywriting": [
"{user_name},今天是您看我的{entrance_num}天,获得{get_integral}点积分",
"非常感谢{user_name}的陪伴,有您这样的粉丝,主播生涯也是没有遗憾了"
]
}
]
},
"gift": {
"enable": true,
"get_integral_proportion": 10,
"copywriting": [
{
"gift_price_interval": "0-1",
"copywriting": [
"感谢{user_name}的{gift_name},获得{get_integral}点积分",
"感谢{user_name}的{gift_name}"
]
},
{
"gift_price_interval": "1.01-10",
"copywriting": [
"感谢{user_name}的{gift_name},老板大气,获得{get_integral}点积分",
"感谢{user_name}的{gift_name},老板大气,获得{get_integral}点积分"
]
},
{
"gift_price_interval": "10.01-88888888",
"copywriting": [
"感谢{user_name}的{gift_name},获得{get_integral}点积分",
"感谢{user_name}的{gift_name},您真是在下的衣食父母啊"
]
}
]
},
"sign": {
"enable": true,
"cmd": [
"签到",
"打卡"
],
"get_integral": 1,
"copywriting": [
{
"sign_num_interval": "0-3",
"copywriting": [
"{user_name}打卡成功,获得{get_integral}点积分,您已打卡{sign_num}天",
"{user_name}打卡成功喵,获得{get_integral}点积分,感谢您{sign_num}天的陪伴"
]
},
{
"sign_num_interval": "4-30",
"copywriting": [
"{user_name}打卡成功,获得{get_integral}点积分,您已打卡{sign_num}天",
"{user_name}打卡成功喵,获得{get_integral}点积分,感谢您{sign_num}天的陪伴"
]
},
{
"sign_num_interval": "31-66666",
"copywriting": [
"非常感谢{user_name}的陪伴,有您这样的粉丝,主播生涯也是没有遗憾了",
"{user_name}打卡成功喵,获得{get_integral}点积分,感谢您{sign_num}天的陪伴"
]
}
]
},
"crud": {
"query": {
"enable": true,
"cmd": [
"我的积分",
"查询积分"
]
}
}
}
}
3 changes: 0 additions & 3 deletions data/badwords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3012,7 +3012,6 @@
处女
聖母
欠干
新大陆
江蛤蟆
押小
公子冲
Expand Down Expand Up @@ -4322,7 +4321,6 @@
林果
陈润儿
寂寞女
导航
學生妹
吃雞巴
监职
Expand Down Expand Up @@ -5232,7 +5230,6 @@
巨商
伊斯蘭
比样
铃声
淩辱
網捷信
罂粟
Expand Down
2 changes: 2 additions & 0 deletions douyu.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def schedule_task(index):
content = random_copy

data = {
"platform": "斗鱼",
"username": None,
"content": content
}
Expand Down Expand Up @@ -211,6 +212,7 @@ async def on_message(websocket, path):
logging.info(f'[📧直播间弹幕消息] [{user_name}]:{content}')

data = {
"platform": "斗鱼",
"username": user_name,
"content": content
}
Expand Down
5 changes: 5 additions & 0 deletions dy.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def schedule_task(index):
content = random_copy

data = {
"platform": "抖音",
"username": None,
"content": content
}
Expand Down Expand Up @@ -206,6 +207,7 @@ def on_message(ws, message):
logging.info(f'[📧直播间弹幕消息] [{user_name}]:{content}')

data = {
"platform": "抖音",
"username": user_name,
"content": content
}
Expand All @@ -226,6 +228,7 @@ def on_message(ws, message):
logging.info(f'[🚹🚺直播间成员加入消息] 欢迎 {user_name} 进入直播间')

data = {
"platform": "抖音",
"username": user_name,
"content": "进入直播间"
}
Expand All @@ -241,6 +244,7 @@ def on_message(ws, message):
logging.info(f'[➕直播间关注消息] 感谢 {data_json["User"]["Nickname"]} 的关注')

data = {
"platform": "抖音",
"username": user_name
}

Expand Down Expand Up @@ -282,6 +286,7 @@ def on_message(ws, message):
logging.info(f'[🎁直播间礼物消息] 用户:{user_name} 赠送 {num}{gift_name},单价 {discount_price}抖币,总计 {combo_total_coin}抖币')

data = {
"platform": "抖音",
"gift_name": gift_name,
"username": user_name,
"num": num,
Expand Down
2 changes: 2 additions & 0 deletions ks.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ def handler(self, websocket):
logging.info(f"[📧直播间弹幕消息] [{username}]:{content}")

data = {
"platform": "快手",
"username": username,
"content": content
}
Expand Down Expand Up @@ -275,6 +276,7 @@ def schedule_task(index):
content = random_copy

data = {
"platform": "快手",
"username": None,
"content": content
}
Expand Down
2 changes: 2 additions & 0 deletions talk.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ def do_listen_and_comment(status=True):
user_name = config.get("talk", "username")

data = {
"platform": "本地聊天",
"username": user_name,
"content": content
}
Expand Down Expand Up @@ -211,6 +212,7 @@ def do_listen_and_comment(status=True):
user_name = config.get("talk", "username")

data = {
"platform": "本地聊天",
"username": user_name,
"content": content
}
Expand Down
26 changes: 26 additions & 0 deletions utils/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,3 +655,29 @@ def parse_cookie_data(self, data_str, field_name):

# 如果未找到指定字段,返回空字符串
return ""


# 动态变量替换
def dynamic_variable_replacement(self, template, data_json):
"""动态变量替换
Args:
template (str): 待替换变量的字符串
data_json (dict): 用于替换的变量json数据
Returns:
str: 替换完成后的字符串
"""
pattern = r"{(\w+)}"
var_names = re.findall(pattern, template)

for var_name in var_names:
if var_name in data_json:
template = template.replace("{"+var_name+"}", str(data_json[var_name]))
else:
# 变量不存在,保留原样
pass

logging.debug(f"template={template}")

return template
Loading

0 comments on commit 20680a9

Please sign in to comment.