Skip to content

Commit bc12088

Browse files
committed
'将Nonebot与CQHttp的网络相关配置移动到config.json中'
1 parent c34b58c commit bc12088

File tree

5 files changed

+83
-14
lines changed

5 files changed

+83
-14
lines changed

README.md

+13-10
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,16 @@ FG的核心是一个称为**TextRank**的算法,它源自于Google的PageRank
2020
> * textrank4zh >= 0.3
2121
> * [CQHTTP 酷Q插件](https://cqhttp.cc/docs/4.14/#/) >=4.8
2222
23-
## Configuration
24-
需要在两个地方进行配置
25-
> * config.py
26-
> * cn/acmsmu/FG/data/config.json
23+
## Install
2724

28-
### config.py
29-
30-
```python
31-
from nonebot.default_config import *
32-
API_ROOT = 'http://127.0.0.1:5700' # 这里 IP 和端口应与 CQHTTP 配置中的 `host` 和 `port` 对应
25+
进入项目根目录,然后运行
3326
```
27+
pip install -r requirement.txt
28+
```
29+
30+
## Configuration
31+
配置文件位置
32+
> * cn/acmsmu/FG/data/config.json
3433
3534
### config.json
3635

@@ -45,6 +44,10 @@ API_ROOT = 'http://127.0.0.1:5700' # 这里 IP 和端口应与 CQHTTP 配置中
4544
"keyWordLen":3,//小于此长度的词将不会被显示,默认为3
4645
"keyWordNum":50,//热词数量,默认50
4746
"fontPath":"C:/Windows/Fonts/msyh.ttc",//字体,用于生成词云
47+
"nonebotHost":"127.0.0.1",//Nonebot监听地址,具体可参考官方文档的“开始使用小节”
48+
"nonebotPort":8080,//Nonebot监听端口
49+
"cqhttpHost":"127.0.0.1",//CQHttp运行端口
50+
"cqhttpPort":5700,//CQHttp监听端口
4851
"groupInfo":[//群信息数组
4952
{
5053
"timer":"timer1",//定时器名称
@@ -90,7 +93,7 @@ API_ROOT = 'http://127.0.0.1:5700' # 这里 IP 和端口应与 CQHTTP 配置中
9093
## Run
9194
配置完成后,在根目录下运行
9295
```python
93-
python3 bot.py
96+
python bot.py
9497
```
9598

9699
## ScreenShots

bot.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44
@time: created on 2020/4/4 14:57
55
@修改记录:
66
'''
7-
from os import path
7+
import os
8+
from Utils.JsonUtils import JsonUtils
89
import nonebot
910
import config
1011

1112
if __name__ == '__main__':
13+
configuration = JsonUtils.json2Dict(os.path.join(os.getcwd(), 'cn', 'acmsmu', 'FG', 'data', 'config.json'))
1214
nonebot.init(config)
1315
nonebot.load_plugins(
14-
path.join(path.dirname(__file__), 'cn', 'acmsmu'),
16+
os.path.join(os.path.dirname(__file__), 'cn', 'acmsmu'),
1517
'cn.acmsmu'
1618
)
17-
nonebot.run(host='127.0.0.1', port=8080)
19+
nonebot.run(host=configuration['nonebotHost'], port=configuration['nonebotPort'])

cn/acmsmu/FG/data/config.json

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
"keyWordLen":3,
77
"keyWordNum":50,
88
"fontPath":"C:/Windows/Fonts/msyh.ttc",
9+
"nonebotHost":"127.0.0.1",
10+
"nonebotPort":8080,
11+
"cqhttpHost":"127.0.0.1",
12+
"cqhttpPort":5700,
913
"groupInfo":[
1014
{
1115
"timer":"timer1",

config.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
@author: Martin Huang
44
@time: created on 2020/4/4 14:57
55
@修改记录:
6+
2020/04/07 => 增加从配置文件中获取信息
67
'''
78
from nonebot.default_config import *
8-
API_ROOT = 'http://127.0.0.1:5700'
9+
from Utils.JsonUtils import JsonUtils
10+
import os
11+
configuration = JsonUtils.json2Dict(os.path.join(os.getcwd(),'cn','acmsmu','FG','data','config.json'))
12+
API_ROOT_URL = 'http://'+configuration['cqhttpHost']+':'+str(configuration['cqhttpPort'])
13+
API_ROOT = API_ROOT_URL

requirements.txt

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
aiocache==0.11.1
2+
aiocqhttp==1.2.5
3+
aiofiles==0.4.0
4+
APScheduler==3.6.3
5+
astroid==2.3.3
6+
beautifulsoup4==4.8.2
7+
blinker==1.4
8+
brainyquote==0.2
9+
certifi==2019.11.28
10+
chardet==3.0.4
11+
click==7.1.1
12+
colorama==0.4.3
13+
cycler==0.10.0
14+
decorator==4.4.2
15+
h11==0.9.0
16+
h2==3.2.0
17+
hpack==3.0.0
18+
hstspreload==2020.3.31
19+
httpx==0.12.1
20+
Hypercorn==0.9.4
21+
hyperframe==5.2.0
22+
idna==2.9
23+
isort==4.3.21
24+
itsdangerous==1.1.0
25+
jieba==0.42.1
26+
Jinja2==2.11.1
27+
kiwisolver==1.2.0
28+
lazy-object-proxy==1.4.3
29+
MarkupSafe==1.1.1
30+
matplotlib==3.2.1
31+
mccabe==0.6.1
32+
networkx==2.4
33+
nonebot==1.5.0
34+
numpy==1.18.2
35+
Pillow==7.1.1
36+
priority==1.3.0
37+
pylint==2.4.4
38+
pyparsing==2.4.6
39+
python-dateutil==2.8.1
40+
pytz==2019.3
41+
Quart==0.11.5
42+
requests==2.23.0
43+
rfc3986==1.3.2
44+
six==1.14.0
45+
sniffio==1.1.0
46+
soupsieve==2.0
47+
textrank4zh==0.3
48+
toml==0.10.0
49+
typing-extensions==3.7.4.2
50+
tzlocal==2.0.0
51+
urllib3==1.25.8
52+
Werkzeug==1.0.1
53+
wordcloud==1.6.0
54+
wrapt==1.11.2
55+
wsproto==0.15.0

0 commit comments

Comments
 (0)