Skip to content

Commit

Permalink
准备做一个抽卡记录,先把数据库建好,有空再做
Browse files Browse the repository at this point in the history
  • Loading branch information
NekoRabi committed Jun 13, 2022
1 parent defce82 commit 617e290
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
25 changes: 18 additions & 7 deletions plugin/LeisurePlugin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from plugin.LeisurePlugin.leisure import *
from plugin.LeisurePlugin.tarot import TarotCards,TarotCard
from plugin.LeisurePlugin.tarot import TarotCards, TarotCard
import os

if not os.path.exists("./database/LeisurePlugin"):
Expand All @@ -11,16 +11,27 @@
cx = sqlite3.connect("./database/LeisurePlugin/leisure.sqlite")
cursor = cx.cursor()
cursor.execute('create table IF NOT EXISTS userinfo('
'id integer primary key,'
'userid integer UNIQUE,'
'score integer default 0,'
'lastsignin varchar(50),'
'id integer primary key,'
'userid integer UNIQUE,'
'score integer default 0,'
'lastsignin varchar(50),'
'keepsigndays integer not null default 1'
')')
')')

cursor.execute('drop table if exists tarot')

cursor.execute('create table IF NOT EXISTS tarot ('
'id integer primary key,'
'cardsid integer,'
'cardname varchar(40) not null,'
'position int not null default 1 )')
'cardexpress TEXT not null)')

cursor.execute("create table if not exists playerdrawcard("
"id integer primary key,"
"userid integer not null,"
"drawtime varchar(50) not null,"
"cardid integer not null,"
"cardposition integer not null"
")")
cx.commit()
cx.close()
4 changes: 2 additions & 2 deletions plugin/LeisurePlugin/leisure.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ def signup(userid: int) -> tuple:
if differ == 1:
singinmsg += f"{user[0][0] + 1},你已连续签到{user[0][2] + 1}\n这是你今天的塔罗牌"
cursor.execute(
f"update userinfo set lastsignin = '{today}',score = {user[0][0] + 1},keepsigndays = {user[0][2]+1} where userid = {userid}")
f"update userinfo set lastsignin = '{today}',score = score + 1,keepsigndays = keepsigndays + 1 where userid = {userid}")
else:
singinmsg += f"{user[0][0] + 1},连续签到中断惹~\n这是你今天的塔罗牌"
cursor.execute(f"update userinfo set lastsignin = '{today}',score = {user[0][0] + 1},keepsigndays = 1 where userid = {userid}")
cursor.execute(f"update userinfo set lastsignin = '{today}',score = score + 1 ,keepsigndays = 1 where userid = {userid}")
cx.commit()
else:
return False, "一天只能签到一次哦~"
Expand Down
7 changes: 7 additions & 0 deletions plugin/MajSoulInfo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@
"drawcount int,"
"lastdraw varchar(50)"
")")
cursor.execute("create table if not exists playerdrawcard("
"id integer primary key,"
"userid integer not null,"
"drawtime varchar(50) not null,"
"itemlevel int not null,"
"itemname TEXT not null"
")")
cursor.execute("create view if not exists groupwatches as "
"select groupid,"
"group_concat(playername) as watchedplayers,"
Expand Down

0 comments on commit 617e290

Please sign in to comment.