mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2025-06-17 03:45:25 +02:00
Remove global header when the bot is not connected to the database
This commit is contained in:
@ -7,7 +7,6 @@ from sqlalchemy.ext.declarative import declarative_base
|
||||
|
||||
import json
|
||||
import discord
|
||||
import time
|
||||
|
||||
Base = declarative_base()
|
||||
|
||||
@ -16,7 +15,6 @@ from titanembeds.database.messages import Messages
|
||||
from titanembeds.database.guild_members import GuildMembers
|
||||
from titanembeds.database.unauthenticated_users import UnauthenticatedUsers
|
||||
from titanembeds.database.unauthenticated_bans import UnauthenticatedBans
|
||||
from titanembeds.database.keyvalue_properties import KeyValueProperties
|
||||
|
||||
from titanembeds.utils import get_message_author, get_message_mentions, get_webhooks_list, get_emojis_list, get_roles_list, get_channels_list, list_role_ids
|
||||
|
||||
@ -289,15 +287,3 @@ class DatabaseInterface(object):
|
||||
dbuser.revoked = True
|
||||
session.commit()
|
||||
return "Successfully kicked **{}#{}**!".format(dbuser.username, dbuser.discriminator)
|
||||
|
||||
async def send_webserver_heartbeat(self):
|
||||
async with threadpool():
|
||||
with self.get_session() as session:
|
||||
key = "bot_heartbeat"
|
||||
q = session.query(KeyValueProperties).filter(KeyValueProperties.key == key)
|
||||
if q.count() == 0:
|
||||
session.add(KeyValueProperties(key=key, value=time.time()))
|
||||
else:
|
||||
firstobj = q.first()
|
||||
firstobj.value = time.time()
|
||||
session.commit()
|
||||
|
@ -1,17 +0,0 @@
|
||||
from titanembeds.database import db, Base
|
||||
import datetime
|
||||
|
||||
class KeyValueProperties(Base):
|
||||
__tablename__ = "keyvalue_properties"
|
||||
id = db.Column(db.Integer, primary_key=True) # Auto incremented id
|
||||
key = db.Column(db.String(255), nullable=False) # Property Key
|
||||
value = db.Column(db.Text()) # Property value
|
||||
expiration = db.Column(db.TIMESTAMP) # Suggested Expiration for value (None = no expire) in secs
|
||||
|
||||
def __init__(self, key, value, expiration=None):
|
||||
self.key = key
|
||||
self.value = value
|
||||
if expiration:
|
||||
self.expiration = datetime.now() + timedelta(seconds = expiration)
|
||||
else:
|
||||
self.expiration = None
|
Reference in New Issue
Block a user