Skip to content

Commit

Permalink
重构基本完成,等待搬运功能
Browse files Browse the repository at this point in the history
  • Loading branch information
mikezom committed Jun 13, 2022
1 parent 39b0fc5 commit f2cffa3
Show file tree
Hide file tree
Showing 20 changed files with 1,889 additions and 62 deletions.
166 changes: 165 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,165 @@
test.ipynb
test.ipynb
.vscode
config/config.json
config/group_permissions.json

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.10.5
17 changes: 17 additions & 0 deletions bigbedbot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from graia.ariadne.entry import Ariadne, Friend, MessageChain, config


app = Ariadne(
config(
verify_key="1234567890",
account=2420862130,
)
)


@app.broadcast.receiver("FriendMessage")
async def friend_message_listener(app: Ariadne, friend: Friend):
await app.send_message(friend, "Hello, World!")


Ariadne.launch_blocking()
18 changes: 14 additions & 4 deletions config/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
{
"bot_ID": 123456,
"authKey": "1234567890",
"host_port": "8088",
"enable_websocket": 1
"mirai" : {
"bot_ID": 2420862130,
"authKey": "1234567890",
"mirai_host": "http://localhost:8080",
"enable_websocket": true
},
"debug" : {
"enable": true,
"groups": [263571637, 769317237]
},
"name": "bigbedbot",
"master": 879712286,
"admins": [879712286],
"bans": []
}
16 changes: 16 additions & 0 deletions config/config_example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"mirai" : {
"bot_ID": 123456,
"authKey": "authKey",
"mirai_host": "http://localhost:8080",
"enable_websocket": true
},
"debug" : {
"enable": false,
"groups": []
},
"name": "bigbedbot",
"master": 10000,
"admins": [10000],
"bans": []
}
54 changes: 54 additions & 0 deletions config/function_name.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"测试1": {
"name": "test_function_1",
"description": "测试群友是不是配用这个功能"
},
"测试2": {
"name": "test_function_2",
"description": "群功能开关"
},
"发什么": {
"name": "fashenme",
"description": "发什么??"
},
"加发": {
"name": "fashenme_add",
"description": "往列表里加发"
},
"发什么十连": {
"name": "fashenme_x10",
"description": "发什么发什么发什么发什么发什么发什么发什么发什么发什么发什么"
},
"减发": {
"name": "fashenme_remove",
"description": "别乱加(什么是乱?)"
},
"发什么长度测试": {
"name": "fashenme_too_long",
"description": "待实现功能:察看最长发什么"
},
"基金": {
"name": "jijin",
"description": "查看一个基金的当日涨跌情况"
},
"查询流量": {
"name": "ladder_traffic_remaining",
"description": "看看我梯子还有多少流量"
},
"播放": {
"name": "play_chinese_number_notation",
"description": "播放中式(?)简谱"
},
"9播放": {
"name": "play_abc_notation",
"description": "播放简谱"
},
"复读": {
"name": "repeater",
"description": "随机复读群友说的话"
},
"二次元sample": {
"name": "nijigen_sample",
"description": "播放一些典中典"
}
}
10 changes: 10 additions & 0 deletions config/function_name_example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"测试1": {
"name": "test_function_1",
"description": "测试群友是不是配用这个功能"
},
"测试2": {
"name": "test_function_2",
"description": "群功能开关"
}
}
1 change: 1 addition & 0 deletions config/group_permissions_example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"10000": {"test_function": true}, "20000": {"test_function_01": true}}
22 changes: 22 additions & 0 deletions libs/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import json

from pydantic import AnyHttpUrl

# load config file
with open('config/config.json') as f:
config_data = json.load(f)

class BotConfig:
class Mirai:
account: int = config_data["mirai"]["bot_ID"]
verify_key: str = config_data["mirai"]["authKey"]
mirai_host: AnyHttpUrl = config_data["mirai"]["mirai_host"]

class Debug:
enable: bool = config_data["debug"]["enable"]
groups: list[int] = config_data["debug"]["groups"]

name: str = config_data["name"]
master: int = config_data["master"]
admins: list[int] = config_data["admins"]
bans: list[int] = config_data["bans"]
Loading

0 comments on commit f2cffa3

Please sign in to comment.