S1S13AF7 merged, bio_str in database no more used, will be deleted
This commit is contained in:
parent
d89b0572f4
commit
3fc2a6e03d
2 changed files with 17 additions and 22 deletions
|
@ -54,13 +54,13 @@ async def bio_backup_stealing(client, c, conn, default_directory):
|
|||
expr = v['until_infect']
|
||||
if cmd == 'me':
|
||||
my_victims_ids.append(user_id)
|
||||
c.execute("INSERT OR REPLACE INTO avocado(user_id,when_int,bio_str,bio_int,expr_int) VALUES (?, ?, ?, ?, ?)",
|
||||
(int(user_id), int(when), str(profit), int(profit), int(expr)))
|
||||
c.execute("INSERT OR REPLACE INTO avocado(user_id,when_int,bio_int,expr_int) VALUES (?, ?, ?, ?)",
|
||||
(int(user_id), int(when), int(profit), int(expr)))
|
||||
added += 1
|
||||
else:
|
||||
if not c.execute(f'SELECT user_id FROM avocado WHERE user_id == {user_id}').fetchone() and not c.execute(f'SELECT user_id FROM avocado_exclude WHERE user_id == {user_id}').fetchone():
|
||||
c.execute("INSERT INTO avocado(user_id,when_int,bio_str,bio_int,expr_int) VALUES (?, ?, ?, ?, ?)",
|
||||
(int(user_id), int(when), str(profit), int(profit), 0))
|
||||
c.execute("INSERT INTO avocado(user_id,when_int,bio_int,expr_int) VALUES (?, ?, ?, ?)",
|
||||
(int(user_id), int(when), int(profit), 0))
|
||||
added += 1
|
||||
else:
|
||||
rejected += 1
|
||||
|
|
31
ubot.py
31
ubot.py
|
@ -173,23 +173,18 @@ async def main():
|
|||
else:
|
||||
conn = sqlite3.connect(f"{my_id}.sqlite") # покласти базу рядом
|
||||
c = conn.cursor()
|
||||
c.execute('''CREATE TABLE IF NOT EXISTS zarazy (
|
||||
user_id INTEGER NOT NULL DEFAULT 0 UNIQUE,
|
||||
when_int INTEGER NOT NULL DEFAULT 0,
|
||||
bio_str VARCHAR NOT NULL DEFAULT 1,
|
||||
bio_int INTEGER NOT NULL DEFAULT 1,
|
||||
expr_int INTEGER NOT NULL DEFAULT 0,
|
||||
expr_str VARCHAR NOT NULL DEFAULT 0
|
||||
)''')
|
||||
conn.commit()
|
||||
c.execute('''CREATE TABLE IF NOT EXISTS avocado (
|
||||
user_id INTEGER NOT NULL DEFAULT 0 UNIQUE,
|
||||
when_int INTEGER NOT NULL DEFAULT 0,
|
||||
bio_str VARCHAR NOT NULL DEFAULT 1,
|
||||
bio_int INTEGER NOT NULL DEFAULT 1,
|
||||
expr_int INTEGER NOT NULL DEFAULT 0,
|
||||
expr_str VARCHAR NOT NULL DEFAULT 0
|
||||
)''')
|
||||
try:
|
||||
c.execute('ALTER TABLE avocado DROP COLUMN bio_str')
|
||||
logger.warning('bio_str in database no more used, deleted!')
|
||||
except:
|
||||
pass
|
||||
conn.commit()
|
||||
c.execute('''CREATE TABLE IF NOT EXISTS avocado_exclude (
|
||||
user_id INTEGER NOT NULL DEFAULT 0 UNIQUE,
|
||||
|
@ -385,15 +380,15 @@ async def main():
|
|||
if u1id > 0 and u2id > 0:
|
||||
if db_sqlite3 and u1id == my_id:
|
||||
try:
|
||||
c.execute("INSERT INTO avocado(user_id,when_int,bio_str,bio_int,expr_int,expr_str) VALUES (?, ?, ?, ?, ?, ?)", (int(
|
||||
u2id), int(when), str(experience), int(exp_int), int(datetime.timestamp(a)), str(a.strftime("%d.%m.%y"))))
|
||||
c.execute("INSERT INTO avocado(user_id,when_int,bio_int,expr_int,expr_str) VALUES (?, ?, ?, ?, ?)", (
|
||||
int(u2id), int(when), int(exp_int), int(datetime.timestamp(a)), str(a.strftime("%d.%m.%y"))))
|
||||
conn.commit()
|
||||
logger.debug(
|
||||
'[new] success writen my bio attack')
|
||||
except:
|
||||
try:
|
||||
c.execute("UPDATE avocado SET when_int = :wh, bio_str = :xp, bio_int = :xpi, expr_int = :end, expr_str = :do WHERE user_id = :z AND when_int <= :wh;", {
|
||||
"wh": int(when), "xp": str(experience), "xpi": int(exp_int), "end": int(datetime.timestamp(a)), "do": str(a.strftime("%d.%m.%y")), "z": int(u2id)})
|
||||
c.execute("UPDATE avocado SET when_int = :wh, bio_int = :xpi, expr_int = :end, expr_str = :do WHERE user_id = :z AND when_int <= :wh;", {
|
||||
"wh": int(when), "xpi": int(exp_int), "end": int(datetime.timestamp(a)), "do": str(a.strftime("%d.%m.%y")), "z": int(u2id)})
|
||||
conn.commit()
|
||||
logger.debug(
|
||||
'[upd] success updated my bio attack')
|
||||
|
@ -402,16 +397,16 @@ async def main():
|
|||
states.last_reply_bioeb_avocado = time.time()
|
||||
if db_sqlite3 and u1id != my_id and u2id not in bio_excludes:
|
||||
try:
|
||||
c.execute("INSERT INTO avocado(user_id,when_int,bio_str,bio_int,expr_int) VALUES (?, ?, ?, ?, ?)", (
|
||||
int(u2id), int(when), str(experience), int(exp_int), 0))
|
||||
c.execute("INSERT INTO avocado(user_id,when_int,bio_int,expr_int) VALUES (?, ?, ?, ?)", (
|
||||
int(u2id), int(when), int(exp_int), 0))
|
||||
conn.commit()
|
||||
logger.debug('[new] success writen bio attack')
|
||||
except:
|
||||
# NOTE: this maybe useful if you want sort database by bio-experience, but as S1S13AF7 said this
|
||||
# can be like: in database you have +10k today, tomorrow it changed to +1...
|
||||
# so... idk what next...
|
||||
c.execute("UPDATE avocado SET when_int = :wh, bio_str = :xp, bio_int = :xpi WHERE user_id = :z AND when_int < :wh AND expr_int < :wh", {
|
||||
"wh": int(when), "xp": str(experience), "xpi": int(exp_int), "z": int(u2id)})
|
||||
c.execute("UPDATE avocado SET when_int = :wh, bio_int = :xpi WHERE user_id = :z AND when_int < :wh AND expr_int < :wh", {
|
||||
"wh": int(when), "xpi": int(exp_int), "z": int(u2id)})
|
||||
conn.commit()
|
||||
logger.debug(
|
||||
'[upd] success updated bio attack')
|
||||
|
|
Loading…
Reference in a new issue