Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CJ-Maske
Bot console
提交
56e7d073
Bot console
项目概览
CJ-Maske
/
Bot console
通知
43
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Bot console
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
56e7d073
编写于
9月 30, 2022
作者:
CJ-Maske
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
上传新文件
上级
664cfcca
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
55 addition
and
0 deletion
+55
-0
dist/wx/robot.py
dist/wx/robot.py
+55
-0
未找到文件。
dist/wx/robot.py
0 → 100644
浏览文件 @
56e7d073
import
os
import
sys
from
imp
import
load_source
import
ntchat
from
ruamel
import
yaml
file
=
list
(
filter
(
lambda
n
:
n
.
endswith
(
'.yml'
),
os
.
listdir
(
'./'
)))
config
=
None
if
file
is
not
None
:
with
open
(
file
[
0
],
'r'
,
encoding
=
'utf-8'
)
as
ym
:
config
=
yaml
.
load
(
ym
,
Loader
=
yaml
.
Loader
)
MainModel
=
''
model
=
load_source
(
MainModel
,
config
[
'script'
][
'fileName'
])
script
=
getattr
(
model
,
config
[
'script'
][
'bySet'
])().
By
ntchat
.
set_wechat_exe_path
(
wechat_version
=
'3.6.0.18'
)
wechat
=
ntchat
.
WeChat
()
wechat
.
open
(
smart
=
True
)
else
:
raise
KeyboardInterrupt
(
'Missing configuration file'
)
@
wechat
.
msg_register
(
ntchat
.
MT_RECV_TEXT_MSG
)
def
on_recv_text_msg
(
wechat_instance
:
ntchat
.
WeChat
,
message
):
data
=
message
[
"data"
]
from_wxid
=
data
[
"from_wxid"
]
room_wxid
=
config
[
'listenRoomList'
]
or
[
data
[
"room_wxid"
]]
self_wxid
=
wechat_instance
.
get_login_info
()[
"wxid"
]
sender
=
wechat_instance
.
get_contact_detail
(
from_wxid
)[
'nickname'
]
remark
=
wechat_instance
.
get_contact_detail
(
from_wxid
)[
'remark'
]
if
data
[
'msg'
].
startswith
(
'/'
)
and
data
[
'room_wxid'
]
in
room_wxid
and
from_wxid
!=
self_wxid
:
methods_name
=
data
[
'msg'
].
strip
(
'/'
).
split
(
'-'
)[
0
]
params
=
data
[
'msg'
].
strip
(
'/'
).
split
(
'-'
)[
1
:]
try
:
if
methods_name
in
[
'早报'
]:
imag
=
script
[
methods_name
]()
wechat_instance
.
send_image
(
data
[
'room_wxid'
],
imag
)
else
:
msg
=
script
[
methods_name
](
params
)
wechat_instance
.
send_room_at_msg
(
data
[
'room_wxid'
],
f
'@
{
sender
}
\n
{
msg
}
'
,
[
from_wxid
])
except
KeyError
:
msg
=
script
[
'other'
](
methods_name
)
wechat_instance
.
send_room_at_msg
(
data
[
'room_wxid'
],
f
'@
{
sender
}
\n
{
msg
}
'
,
[
from_wxid
])
try
:
while
True
:
pass
except
KeyboardInterrupt
:
ntchat
.
exit_
()
sys
.
exit
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录