XZZ/route.py

28 lines
642 B
Python
Raw Normal View History

2020-02-27 21:47:36 +08:00
from worker import emmm
2020-06-18 19:25:32 +08:00
2020-02-27 21:47:36 +08:00
def ZZRouter(data):
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:
pass
else:
Ans.sendmsg(Message)