pleroma-support #56
3 changed files with 15 additions and 21 deletions
|
@ -1,6 +1,6 @@
|
|||
import requests
|
||||
from fediverse_factory import get_fediverse_service
|
||||
from db_utils import get_db_connection
|
||||
import db_utils
|
||||
from config import RARITY_TO_WEIGHT
|
||||
|
||||
def add_character(name: str, rarity: int, weight: float, image_url: str) -> tuple[int, str]:
|
||||
|
@ -47,20 +47,14 @@ def add_character(name: str, rarity: int, weight: float, image_url: str) -> tupl
|
|||
except RuntimeError as e:
|
||||
raise RuntimeError(f"Failed to upload image: {e}") from e
|
||||
|
||||
# Insert into database
|
||||
conn = get_db_connection()
|
||||
cur = conn.cursor()
|
||||
cur.execute(
|
||||
# Insert into database using the global connection pattern
|
||||
db_utils.CURSOR.execute(
|
||||
'INSERT INTO characters (name, rarity, weight, file_id) VALUES (?, ?, ?, ?)',
|
||||
(stripped_name, rarity, float(weight), file_id)
|
||||
)
|
||||
conn.commit()
|
||||
character_id = cur.lastrowid
|
||||
character_id = db_utils.CURSOR.lastrowid
|
||||
|
||||
return character_id, file_id
|
||||
|
||||
except Exception as e:
|
||||
raise
|
||||
finally:
|
||||
if 'conn' in locals():
|
||||
conn.close()
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
import time
|
||||
import traceback
|
||||
from parsing import parse_notification
|
||||
from db_utils import get_config, set_config
|
||||
from db_utils import get_config, set_config, connect
|
||||
from fediverse_factory import get_fediverse_service
|
||||
import config
|
||||
|
||||
def stream_notifications():
|
||||
# Initialize database connection
|
||||
connect()
|
||||
|
||||
# Initialize the Fediverse service
|
||||
fediverse_service = get_fediverse_service()
|
||||
|
||||
|
|
|
@ -5,6 +5,13 @@
|
|||
DefaultAdmins = ['admin@example.tld']
|
||||
; SQLite Database location
|
||||
DatabaseLocation = ./gacha_game.db
|
||||
; Instance type - either "misskey" or "pleroma"
|
||||
InstanceType = misskey
|
||||
; Web server port (default: 5000)
|
||||
WebPort = 5000
|
||||
; Comma-separated list of trusted fediverse instances (leave empty to allow only local users)
|
||||
; Example: TrustedInstances = mastodon.social,misskey.io,pleroma.example.com
|
||||
TrustedInstances =
|
||||
|
||||
[gacha]
|
||||
; Number of seconds players have to wait between rolls
|
||||
|
@ -32,13 +39,3 @@ User = @bot@example.tld
|
|||
; API key for the bot
|
||||
; Generate one by going to Settings > API > Generate access token
|
||||
Token = abcdefghijklmnopqrstuvwxyz012345
|
||||
|
||||
; Instance type - either "misskey" or "pleroma"
|
||||
InstanceType = misskey
|
||||
|
||||
; Web server port (default: 5000)
|
||||
WebPort = 5000
|
||||
|
||||
; Comma-separated list of trusted fediverse instances (leave empty to allow only local users)
|
||||
; Example: TrustedInstances = mastodon.social,misskey.io,pleroma.example.com
|
||||
TrustedInstances =
|
||||
|
|
Loading…
Add table
Reference in a new issue