def __init__(self, Config: ConfigParser = ConfigParser()): self.Config: ConfigParser = Config self.version: str = self.Config.get("version", "[N/A]") self.start_time: int = time.time( ) # together with another time.time(), used to know how long phaaze is running # get the active/load class, aka, what sould get started self.Active: ActiveStore = ActiveStore(self.Config) # a class filled with permanent vars, mainly from external sources or whatever self.Vars: VarsStore = VarsStore(self.Config) # the key to everything, that will be needed to connect to everything thats not ourself self.Access: AccessStore = AccessStore(self.Config) # contains user limits for all addeble things, like custom command amount self.Limit: LimitStore = LimitStore(self.Config) # log to handler of choice self.Logger: PhaazeLogger = PhaazeLogger() # all featured "superclasses" aka, stuff that makes calls to somewhere # all of these get added by self.Mainframe when started # both the actual working part and a quick link to there running loops, to inject async funtions for them to run # most likly used for the worker, that can calculate time consuming functions or discord because send_message must be called from this loop self.Discord: PhaazebotDiscord = PhaazebotDiscord(self) self.DiscordLoop: asyncio.AbstractEventLoop = None self.Twitch = None self.TwitchLoop: asyncio.AbstractEventLoop = None self.TwitchEvents: PhaazebotTwitchEvents = PhaazebotTwitchEvents(self) self.TwitchEventsLoop: asyncio.AbstractEventLoop = None self.Osu: PhaazebotOsu = PhaazebotOsu(self) self.OsuLoop: asyncio.AbstractEventLoop = None self.Twitter = None self.TwitterLoop: asyncio.AbstractEventLoop = None self.Web: PhaazebotWeb = PhaazebotWeb(self) self.WebLoop: asyncio.AbstractEventLoop = None self.WorkerLoop: asyncio.AbstractEventLoop = None # Worker object is protected and only gives us the loop in inject # this runs everthing self.Mainframe = Mainframe(self) # this keeps track of what is running self.IsReady: IsReadyStore = IsReadyStore() # connection to phaaze brain self.PhaazeDB: DBConn = DBConn(host=self.Access.PHAAZEDB_HOST, port=self.Access.PHAAZEDB_PORT, user=self.Access.PHAAZEDB_USER, passwd=self.Access.PHAAZEDB_PASSWORD, database=self.Access.PHAAZEDB_DATABASE)
import discord from typing import List from phaazebot import Phaazebot from Platforms.Discord.main_discord import PhaazebotDiscord from Utils.Classes.dbconn import DBConn from Utils.config import ConfigParser from Utils.cli import CliArgs Conf: Optional[ConfigParser] = None for config_source_path in [(CliArgs.get("config") or ""), f"{base_dir}/Config/config.phzcf", f"{base_dir}/Config/config.json"]: if not config_source_path: continue try: Conf = ConfigParser(config_source_path) break except: pass Phaaze: Phaazebot = Phaazebot(PreConfig=Conf) DBC: DBConn = DBConn(host=Phaaze.Config.get("phaazedb_host", "localhost"), port=Phaaze.Config.get("phaazedb_port", "3306"), user=Phaaze.Config.get("phaazedb_user", "phaaze"), passwd=Phaaze.Config.get("phaazedb_password", ""), database=Phaaze.Config.get("phaazedb_database", "phaaze")) class CheckDiscordOnServer(PhaazebotDiscord): def __init__(self): super().__init__(Phaaze)
def __init__(self, PreConfig:ConfigParser=None): if PreConfig: self.Config:ConfigParser = PreConfig else: cfg_path:str = CliArgs.get("config_path", "Config/config.phzcf") cfg_type:str = CliArgs.get("config_type", "phzcf") self.Config:ConfigParser = ConfigParser(file_path=cfg_path, file_type=cfg_type) self.version:str = self.Config.get("version", "[N/A]") self.start_time:float = time.time() # together with another time.time(), used to know how long phaaze is running # log to handler of choice self.Logger:PhaazeLogger = PhaazeLogger() # get the active/load class, aka, what should get started self.Active:ActiveStore = ActiveStore(self) # a class filled with permanent vars, mainly from external sources or whatever self.Vars:VarsStore = VarsStore(self) # the key to everything, that will be needed to connect to everything that's not ourself self.Access:AccessStore = AccessStore(self) # contains user limits for all addable things, like custom command amount self.Limit:LimitStore = LimitStore(self) # all featured "superclasses" aka, stuff that makes calls to somewhere # all of these get added by self.Mainframe when started # both the actual working part and a quick link to there running loops, to inject async functions for them to run # most likely used for the worker, that can calculate time consuming functions or discord because send_message must be called from this loop self.Discord:PhaazebotDiscord = PhaazebotDiscord(self) self.DiscordLoop:Optional[asyncio.AbstractEventLoop] = None self.Twitch:PhaazebotTwitch = PhaazebotTwitch(self) self.TwitchLoop:Optional[asyncio.AbstractEventLoop] = None self.TwitchEvents:PhaazebotTwitchEvents = PhaazebotTwitchEvents(self) self.TwitchEventsLoop:Optional[asyncio.AbstractEventLoop] = None self.Osu:PhaazebotOsu = PhaazebotOsu(self) self.OsuLoop:Optional[asyncio.AbstractEventLoop] = None self.Twitter = None self.TwitterLoop:Optional[asyncio.AbstractEventLoop] = None self.Web:PhaazebotWeb = PhaazebotWeb(self) self.WebLoop:Optional[asyncio.AbstractEventLoop] = None self.WorkerLoop:Optional[asyncio.AbstractEventLoop] = None # Worker object is protected and only gives us the loop in inject # this runs everything self.Mainframe:MainframeThread = MainframeThread(self) # this keeps track of what is running self.IsReady:IsReadyStore = IsReadyStore() # connection to phaaze brain self.PhaazeDB:DBConn = DBConn( host=self.Access.phaazedb_host, port=self.Access.phaazedb_port, user=self.Access.phaazedb_user, passwd=self.Access.phaazedb_password, database=self.Access.phaazedb_database )
# discord_twitch_alert table. # # To be exact the discord_guild_id field. # Because its not really needed for the alerts, but of stat listing etc. # This protocol is suppost to try finding the GuildID based on the ChannelID # import os import sys sys.path.insert(0, f"{os.path.dirname(__file__)}/../../") import discord import asyncio from Utils.Classes.dbconn import DBConn from Utils.config import ConfigParser Configs: ConfigParser = ConfigParser() class PhaazeDiscordConnection(discord.Client): """ Discord connection for running the protocol """ def __init__(self, empty_entrys: list): super().__init__() self.empty_entrys = empty_entrys async def on_ready(self) -> None: global DBC print("Discord Connectet, running checks...") for entry in self.empty_entrys: channel_id: str = entry.get("discord_channel_id", "") if not channel_id: