async def validate_input(data: dict[str, Any]) -> None: """Validate the user input allows us to connect.""" fivem = FiveM(data[CONF_HOST], data[CONF_PORT]) info = await fivem.get_info_raw() game_name = info.get("vars")["gamename"] if game_name is None or game_name != "gta5": raise InvalidGameNameError
def __init__( self, hass: HomeAssistant, config_data: Mapping[str, Any], unique_id: str ) -> None: """Initialize server instance.""" self.unique_id = unique_id self.server = None self.version = None self.game_name: str | None = None self.host = config_data[CONF_HOST] self._fivem = FiveM(self.host, config_data[CONF_PORT]) update_interval = timedelta(seconds=SCAN_INTERVAL) super().__init__(hass, _LOGGER, name=DOMAIN, update_interval=update_interval)
from forms import sending_forms load_dotenv(find_dotenv()) intents = discord.Intents.default() intents.members = True key = os.getenv('CLIENT_SECRET') client = commands.Bot(command_prefix = 'rp!', intents = intents) cluster = MongoClient(os.getenv('MONGO_URI')) site_db = cluster['Letsrp-db'] wlforms = site_db.wlforms info = ''; try: server = FiveM(ip = 'wyspa.letsrp.pl', port = 30120) except: server = None print('Cannot connect to FiveM') print('Connected to DB') @client.event async def on_ready(): if server is not None: info = await server.get_server_info() activity = discord.Game(f'{info.clients}/{info.max_clients}') await client.change_presence(activity = activity) players_on_server.start() sending_forms.start(site_db, client) print('Bot is active!')