add redis db
This commit is contained in:
parent
9c3abb4c7e
commit
cff7dac933
1 changed files with 9 additions and 3 deletions
12
zzcore.py
12
zzcore.py
|
@ -1,7 +1,8 @@
|
||||||
import requests
|
import requests, json, redis
|
||||||
import json
|
|
||||||
from config import APIURL, ALLWORKERS, AUTHORIZATION
|
from config import APIURL, ALLWORKERS, AUTHORIZATION
|
||||||
from worker import emmm
|
from worker import emmm
|
||||||
|
pool = redis.ConnectionPool(host='127.0.0.1', port=6379, decode_responses=True)
|
||||||
|
r = redis.Redis(connection_pool=pool)
|
||||||
|
|
||||||
class StdAns():
|
class StdAns():
|
||||||
AllowGroup = []
|
AllowGroup = []
|
||||||
|
@ -18,6 +19,11 @@ class StdAns():
|
||||||
self.role = role
|
self.role = role
|
||||||
self.raw_msg = raw_msg
|
self.raw_msg = raw_msg
|
||||||
|
|
||||||
|
def DATAGET(self):
|
||||||
|
return r.hgetall(self.parms[0])
|
||||||
|
|
||||||
|
def DATASET(self,data):
|
||||||
|
r.hmset(self.parms[0],data)
|
||||||
|
|
||||||
def CheckPermission(self):
|
def CheckPermission(self):
|
||||||
if self.AllowGroup and self.gid not in self.AllowGroup:
|
if self.AllowGroup and self.gid not in self.AllowGroup:
|
||||||
|
@ -43,4 +49,4 @@ class StdAns():
|
||||||
'group_id' : self.gid,
|
'group_id' : self.gid,
|
||||||
'message': msg
|
'message': msg
|
||||||
}
|
}
|
||||||
requests.post(url = url, data = json.dumps(data),headers = Headers)
|
return requests.post(url = url, data = json.dumps(data),headers = Headers).json()['data']['message_id']
|
||||||
|
|
Loading…
Reference in a new issue