XZZ/zzcore.py

89 lines
2.7 KiB
Python
Raw Normal View History

2020-08-16 20:13:41 +08:00
import requests, json, redis
2020-02-27 21:47:36 +08:00
from config import APIURL, ALLWORKERS, AUTHORIZATION
from worker import emmm
2020-08-16 20:13:41 +08:00
pool = redis.ConnectionPool(host='127.0.0.1', port=6379, decode_responses=True)
r = redis.Redis(connection_pool=pool)
2020-02-27 21:47:36 +08:00
class StdAns():
AllowGroup = []
AllowUser = []
AllowRole = []
GroupNotAllow = '汝所在的群组不被允许这样命令咱呢.'
UserNotAllow = '汝不被允许呢.'
RoleNotAllow = '汝的角色不被允许哦.'
2020-08-16 19:11:44 +08:00
def __init__(self,parms,uid,gid,role,raw_msg):
2020-02-27 21:47:36 +08:00
self.parms = parms
self.uid = uid
self.gid = gid
self.role = role
self.raw_msg = raw_msg
2020-03-20 22:46:11 +08:00
def DATAGET(self):
return r.hgetall(self.parms[0])
def DATASET(self,data):
r.hmset(self.parms[0],data)
2020-02-27 21:47:36 +08:00
def CheckPermission(self):
if self.AllowGroup and self.gid not in self.AllowGroup:
return self.GroupNotAllow
if self.AllowUser and self.uid not in self.AllowUser:
return self.UserNotAllow
if self.AllowRole and self.role not in self.AllowRole:
return self.RoleNotAllow
return 0
def GETMSG(self):
return self.__module__ +'的话,咱已经知道了,但是还在学习呢!'
def sendmsg(self,msg):
url = APIURL + "send_msg"
2020-08-02 21:54:55 +08:00
2020-02-27 21:47:36 +08:00
data = {
2020-08-02 21:54:55 +08:00
'access_token' : AUTHORIZATION,
2020-02-27 21:47:36 +08:00
'message_type' : 'group',
'group_id' : self.gid,
'message': msg
}
2020-08-02 21:54:55 +08:00
return requests.get(url = url, params=data).json()['data']['message_id']
2020-03-20 22:51:35 +08:00
def delmsg(self,msgid):
url = APIURL + "delete_msg"
2020-08-02 21:54:55 +08:00
2020-03-20 22:51:35 +08:00
data = {
2020-08-02 21:54:55 +08:00
'access_token' : AUTHORIZATION,
2020-03-20 22:51:35 +08:00
'message_id' : msgid,
}
2020-08-02 21:54:55 +08:00
requests.get(url = url, params=data)
2020-07-14 17:04:09 +08:00
2020-08-02 16:42:41 +08:00
def getgroups(self):
url = APIURL + "get_group_list"
Headers = {
'content-type': 'application/json',
'Authorization':'Bearer ' + AUTHORIZATION
}
return requests.get(url = url,headers = Headers).json()['data']
2020-07-14 17:04:09 +08:00
def mysakuya(self, words):
if self.uid == 1318000868:
return True
2020-07-14 17:17:18 +08:00
if ('' in words and '' in words) or ('' in words and '' in words) or ('' in words and '' in words and '' in words) or ('1' in words and '6' in words and '' in words):
2020-07-14 17:04:09 +08:00
return False
2020-08-11 22:52:59 +08:00
for sakuya in ['口关夜','十六夜咲夜','十六夜','十六','咲夜', '夜咲', '六夜','Sakuya','sakuya','Izayoi Sakuya','Izayoi','izayoi','izayoi sakuya']:
2020-07-14 17:04:09 +08:00
if sakuya in words:
2020-07-14 17:23:11 +08:00
return False
2020-08-03 22:10:17 +08:00
return True
def DM(msgid):
url = APIURL + "delete_msg"
data = {
'access_token' : AUTHORIZATION,
'message_id' : msgid,
}
requests.get(url = url, params=data)