-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjrrp.py
52 lines (41 loc) · 1.38 KB
/
jrrp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import date
from lib import *;
from auth import *;
from database import *;
from dictsearch import get_random_dict;
def gen_jrrp(qqid):
s = str(date.date()) + str(qqid)
ret = 1 + hash(s)%100;
#print(ret);
return ret;
def get_jrrp(qqid):
today = date.date()
n = cursor.execute('SELECT val FROM jrrp WHERE qqid = %d and date = %d' % (qqid, today))
ret = 0;
if(n == 0):
ret = gen_jrrp(qqid);
execute('INSERT INTO jrrp(qqid, date, val) VALUES(%d, %d, %d)' % (qqid, today, ret))
db.commit()
else:
ret = cursor.fetchone()[0]
print(ret);
return ret
# def jrrp(args, groupid, qqid):
# if not len(args) == 1:
# return ""
# print(get_jrrp(qqid))
# return "[CQ:at,qq=%d]的人品值是:%d" %(qqid, get_jrrp(qqid))
def jrrp(args, groupid, qqid):
rand_dict = ""
rand_dict = get_random_dict();
if(len(args) == 1):
return "[CQ:at,qq=%d]的人品值是:%d\n\n%s" %(qqid, get_jrrp(qqid), rand_dict)
elif(len(args) == 2):
aimqqid = read_qqid(args[1]);
if(get_authlevel(qqid, groupid)<5):
return "权限不足,请重试"
elif(get_authlevel(qqid, groupid)<get_authlevel(aimqqid, groupid)):
return "权限不足,请重试"
else:
n = get_jrrp(aimqqid);
return "%d的人品值是:%d\n\n%s" %(aimqqid, n, rand_dict);