XZZ/route.py

30 lines
749 B
Python
Raw Normal View History

2020-02-27 21:47:36 +08:00
from worker import emmm
2020-08-03 23:20:13 +08:00
2020-06-18 19:25:32 +08:00
2020-02-27 21:47:36 +08:00
def ZZRouter(data):
2020-08-03 12:04:06 +08:00
if data['post_type'] != 'message' or data['message_type'] != 'group' or data['message'][0] != '/':
2020-08-02 23:13:31 +08:00
return
2020-08-03 12:04:06 +08:00
2020-02-27 21:47:36 +08:00
uid = data['user_id']
gid = data['group_id']
role = data['sender']['role']
parms = str.split(data['message'][1:])
2020-06-18 19:25:32 +08:00
print(uid, gid, role, parms)
2020-03-16 17:18:32 +08:00
if parms == []:
2020-03-02 14:17:30 +08:00
parms[0] = 'help'
2020-02-27 21:47:36 +08:00
worker = parms[0]
try:
2020-06-18 19:25:32 +08:00
package = __import__(name='worker.' + worker, fromlist=worker)
Ans_ = getattr(package, 'Ans')
2020-02-27 21:47:36 +08:00
except:
Ans_ = emmm.Ans
2020-06-18 19:25:32 +08:00
Ans = Ans_(parms, uid, gid, role, data)
2020-02-27 21:47:36 +08:00
Message = Ans.CheckPermission()
if Message == 0:
Message = Ans.GETMSG()
2020-06-18 19:25:32 +08:00
elif Message == -1:
2020-06-18 19:35:09 +08:00
return
Ans.sendmsg(Message)