-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 482cec5
Showing
21 changed files
with
736 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
roomid= | ||
term_env=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: pip | ||
directory: "/" | ||
schedule: | ||
interval: daily | ||
open-pull-requests-limit: 20 | ||
- package-ecosystem: github-actions | ||
directory: "/" | ||
schedule: | ||
interval: daily |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: build CI | ||
|
||
on: | ||
push: | ||
branches: master | ||
workflow_dispatch: | ||
workflow_call: | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [macos-latest,ubuntu-latest,windows-latest,macos-13] | ||
runs-on: ${{matrix.os}} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.8 | ||
cache: 'pip' | ||
cache-dependency-path: '**/requirements.txt' | ||
- name: Cache apt dependencies(for linux) | ||
if: ${{runner.os == 'Linux'}} | ||
uses: awalsh128/cache-apt-pkgs-action@latest | ||
with: | ||
packages: python3-tk | ||
execute_install_scripts: true | ||
- name: Install dependencies | ||
run: pip install -r requirements.txt | ||
- name: Build | ||
run: pyinstaller -F --hidden-import=PIL._tkinter_finder --additional-hooks-dir=hooks main.py -n vcbot-bili -i .res/icon.ico | ||
- name: Copy plugins | ||
run: cp -r plugins ./dist | ||
- name: pack | ||
run: 7z a -tzip vcbots-bili-${{runner.os}}-${{runner.arch}}.zip ./dist | ||
- name: Upload | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: build-${{matrix.os}} | ||
path: ./vcbots-bili-${{runner.os}}-${{runner.arch}}.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Release | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
tags: v* | ||
|
||
jobs: | ||
build: | ||
uses: ./.github/workflows/main.yml | ||
release: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: download | ||
uses: actions/download-artifact@v4 | ||
- name: create release | ||
uses: softprops/action-gh-release@v2.0.8 | ||
with: | ||
files: ./**/**.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
__pycache__ | ||
__pypackages__ | ||
logs | ||
.env | ||
build | ||
dist | ||
*.spec | ||
*.json | ||
!example.json | ||
*.jsonc | ||
*.log |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
<div align="center"> | ||
|
||
 | ||
|
||
# VCBOT FOR BILI | ||
|
||
一个用于B站的简单机器人框架(基于python) | ||
|
||
</div> | ||
|
||
## 开发原因 | ||
|
||
<details> | ||
|
||
 | ||
|
||
</details> | ||
|
||
## 使用 | ||
|
||
1. 从[releases](https://github.com/vcbots/vcbot-bili/releases)中获取对应操作系统平台的程序,并解压 | ||
2. 创建`.env`文件,并填写以下内容 | ||
``` | ||
roomid=[房间id] | ||
term_env=[终端扫码,启用填1即可] | ||
``` | ||
3. 创建`[房间id].json`,并填写以下内容 | ||
|
||
<details> | ||
<summary>示例</summary> | ||
|
||
``` | ||
{ | ||
"connected": "连接成功", | ||
"chat":{ | ||
"global":{ | ||
"schedule":[ | ||
{ | ||
"minute":1, | ||
"content": "主包快去喝水!" | ||
}, | ||
{ | ||
"minute":15, | ||
"content":"q群:xxx" | ||
} | ||
], | ||
"events":{ | ||
"reply_notice": " {user} 回复 {re-user} : {content} ", | ||
"welcome": "欢迎 {user} 进入直播间", | ||
"gifts": "谢谢 {user} 的 {gift} 喵~", | ||
"guard": "感谢 {user} 开通 {type} 喵~", | ||
"followed": "感谢 {user} 的关注喵~" | ||
}, | ||
"command":{ | ||
"你好":"hello world!", | ||
"status":"Is running?" | ||
} | ||
}, | ||
"xxxx": { | ||
"alias":[], | ||
"command":{ | ||
"你好":"hello!", | ||
"臭机器人": "???" | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
</details> | ||
|
||
<details> | ||
<summary>解析</summary> | ||
|
||
|
||
### 配置规则解析 | ||
|
||
|字段|备注| | ||
|-|-| | ||
|connected|连接直播间成功| | ||
|global|全局事件| | ||
|xxx|xxxx为用户uid,特定用户事件| | ||
#### global规则解析 | ||
|
||
|字段|备注| | ||
|-|-| | ||
|schedule|定时事件| | ||
|events|直播事件| | ||
|command|互动事件| | ||
|
||
#### [uid]规则解析 | ||
|
||
|字段|备注| | ||
|-|-| | ||
|alias|别称,todo| | ||
|command|互动事件| | ||
|
||
#### 替换常量 | ||
|
||
|字段|备注| | ||
|-|-| | ||
|{user}|替换成用户名| | ||
|{re-user}|替换为被@用户| | ||
|{gift}|替换为礼物名称| | ||
|{type} |替换为开通大航海类型| | ||
|
||
</details> | ||
|
||
|
||
4.启动运行,**扫码登陆**后即可 | ||
|
||
## 开发 | ||
|
||
```bash | ||
# 安装依赖 | ||
pip install -r requirements.txt | ||
|
||
# 调试 | ||
python3 main.py | ||
|
||
# 编译出应用程序 | ||
pyinstaller -F --hidden-import=PIL._tkinter_finder --additional-hooks-dir=hooks main.py -n vcbot-bili -i .res/icon.ico | ||
|
||
``` | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from PyInstaller.utils.hooks import collect_data_files | ||
|
||
datas = collect_data_files("bilibili_api") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from . import config,ignore | ||
from . import user,live | ||
from . import schedule,inital_command |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import os | ||
import json | ||
from loguru import logger | ||
from dotenv import load_dotenv | ||
|
||
default={ | ||
'connected': '连接成功!', | ||
'chat': { | ||
'global': { | ||
'schedule': [ | ||
{'minute': 30, 'content': '主包记得喝水!'}, | ||
{'minute': 15, 'content': '关注上舰送灯牌,寻找主包不迷路~'} | ||
], | ||
'events': { | ||
'reply_notice': ' {user} 回复 {re-user} : {content} ', | ||
'welcome': '欢迎 {user} 进入直播间', | ||
'gifts': '谢谢 {user} 的 {gift} 喵~', | ||
'guard': '感谢 {user} 开通 {type} 喵~', | ||
'followed': '感谢 {user} 的关注喵~' | ||
}, | ||
'command': { | ||
'骂我':'杂鱼~杂鱼~' | ||
} | ||
}, | ||
'282873551': { | ||
'command': { | ||
'debug': 'vcbot-bili with default rule' | ||
} | ||
} | ||
} | ||
} | ||
|
||
def loadroomcfg(): | ||
if not os.path.exists("./.env"): | ||
roomid=input("未检测到配置文件,请输入房间号:") | ||
term_login = "n" | ||
term_login = input("是否使用终端登录?(y/[n]):") | ||
if term_login.lower() == "y": | ||
term_env_set = 1 | ||
else: | ||
term_env_set = 0 | ||
with open("./.env",mode="w",encoding="utf-8",errors="ignore") as env: | ||
env.write(f"roomid={roomid}\nterm_env={term_env_set}") | ||
load_dotenv(dotenv_path="./.env") | ||
global room | ||
room=os.environ["roomid"] | ||
global term_env | ||
term_env = os.environ["term_env"] | ||
global roomcfg | ||
global plugins_cfg | ||
try: | ||
roomcfg = json.load(open(f"./{room}.json",encoding="utf-8",errors="ignore")) | ||
except FileNotFoundError: | ||
roomcfg = default.copy() | ||
_make_default_cfg() | ||
finally: | ||
logger.info(str(roomcfg)) | ||
return | ||
|
||
def _make_default_cfg(): | ||
with open(file=f"./{room}.json",mode="w",encoding="utf-8",errors="ignore") as cookies: | ||
cookies.write(json.dumps(default,ensure_ascii=False)) | ||
|
||
if __name__ == "__main__": | ||
#方便转换,直接运行这个py文件 | ||
roomcfg = json.load(open("example.json",encoding="utf-8",errors="ignore")) | ||
print(roomcfg) | ||
with open('dist.txt',encoding='utf-8',errors='ignore',mode='w') as dists: | ||
dists.write(str(roomcfg)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#黑名单,遇到以下uid直接忽略 | ||
global ban_uid | ||
ban_uid=['3546377875360540','3546632014531086'] |
Oops, something went wrong.