Giter Site home page Giter Site logo

opengsq / opengsq-python Goto Github PK

View Code? Open in Web Editor NEW
22.0 1.0 2.0 1.88 MB

Python library designed for querying game servers. It supports 24 different query protocols and has been downloaded over 34,000 times.

Home Page: https://python.opengsq.com/

License: MIT License

Python 100.00%
opengsq game-server-query game server-query ase minecraft quake source teamspeak3 asyncio

opengsq-python's Introduction

OpenGSQ Python Library

Python Package GitHub license PyPI version Python versions Downloads

The OpenGSQ Python library provides a convenient way to query servers from applications written in the Python language.

Supported Protocols

The library supports a wide range of protocols. Here are some examples:

from opengsq.protocols import (
    ASE,
    Battlefield,
    Doom3,
    EOS,
    FiveM,
    GameSpy1,
    GameSpy2,
    GameSpy3,
    GameSpy4,
    Kaillera,
    KillingFloor,
    Minecraft,
    Quake1,
    Quake2,
    Quake3,
    RakNet,
    Samp,
    Satisfactory,
    Scum,
    Source,
    TeamSpeak3,
    Unreal2,
    Vcmp,
    WON,
)

Requirements

  • Python 3.7 or higher

Installation

The recommended installation method is using pip:

pip install --upgrade opengsq

Usage

Here’s an example of how to query a server using the Source protocol:

import asyncio
from opengsq.protocols import Source

async def main():
    source = Source(host='45.147.5.5', port=27015)
    info = await source.get_info()
    print(info)

asyncio.run(main())

You can also use the Source Remote Console:

import asyncio
from opengsq.exceptions import AuthenticationException
from opengsq.rcon_protocols.source_rcon import SourceRcon

async def main():
    with SourceRcon("123.123.123.123", 27015) as source_rcon:
        try:
            await source_rcon.authenticate("serverRconPassword")
        except AuthenticationException:
            print('Failed to authenticate')

        response = await source_rcon.send_command("cvarlist")
        print(response)

asyncio.run(main())

Command-line interface

This library additionally provides an opengsq command-line utility which makes it easy to query game servers from your terminal. Run opengsq -h for usage.

# query server using source protocol
opengsq source --host 123.123.123.123 --port 27015 --function get_info

Tests and Results

You can find information about tests and results at https://python.opengsq.com/tests/protocols

Stargazers over time

Stargazers over time

opengsq-python's People

Contributors

battlefieldduck avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

opengsq-python's Issues

Mordhau module does not show players

Hi,

I'm currently working on a project to create a mordhau server monitor frontend. For this i'm trying to leverage query tools like a2s but unfortunately i'm unable to get any player stats returned.

Today i stumbled upon your project and tried it with your example; ofcourse with the proper server ip and port. But also I did not get any player stats returned. Do you happen to know what is preventing the player stats from showing and are you able to provide a fix for this in opengsq?

from opengsq import Mordhau

mordhau = Mordhau(address='123.123.123.123', query_port=27015)
server = mordhau.query()

print(server.to_json())

I am getting Player count returned, but an empty player_list array.

{"name": "Specs duelling server", "map": "The Pit", "players": 3, "max_players": 16, "bots": 0, "player_list": [], "latency": 0.20559906959533691}

kind regards,
Patrick

Timeout error for no apparent reason.

import asyncio
from dotenv import load_dotenv
import os
from opengsq.protocols import Source

load_dotenv()


async def main():
    source = Source(host=os.getenv("HOST_IP"), port=os.getenv("QUERY_PORT"))
    info = await source.get_info()
    print(info)

asyncio.run(main())

I keep getting timeout error for no reason, no matter what server. Tested on 4 machines with same results.

EOS Query Credentials

I was able to use opengsq to query ARK:SA servers, using the example provided. But I can't query other EOS-based games. I get the error " ServerNotFoundException"

Are the credentials used in the example specific to ARK:SA? If so, how would one go about obtaining credentials for other games?

Source.RemoteConsole not working with ASA

I am unable to to send commands to my ASA server and get a TimeoutError

        with Source.RemoteConsole(host, int(port) as rcon:
            await rcon.authenticate(password)
            response = await rcon.send_command(args)

Is it possible in php?

Thank you for the project. I came across this project while researching, as Squad switched to the EOS protocol. I didn't have the opportunity to test it since it's in Python, but is there a possibility of you writing this project in PHP? Despite creating and adding my client ID, client secret, and deployment keys via Epic Dev, I couldn't get it to run; it seemed quite complex.

Documented instructions do not seem to work

Hi,

Congrats on the release of 1.0.0. Unfortunately I can't get this to work with even your basic instruction from the main page.

Traceback (most recent call last):
File "opengsq.py", line 2, in
from opengsq.protocols import Source
File "/Users/pblaas/Documents/github/insAPI/opengsq.py", line 2, in
from opengsq.protocols import Source
ModuleNotFoundError: No module named 'opengsq.protocols'; 'opengsq' is not a package

import asyncio
from opengsq.protocols import Source

async def main():
    source = Source(address='45.147.5.5', query_port=27015)
    info = await source.get_info()
    print(info)

asyncio.run(main())
▶ python -V
Python 3.8.10
▶ pip3 list|grep opengsq
opengsq                            1.0.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.