Skip to main content

kagtcprlib · AUR Build Status

A TCPR library for King Arthur's Gold, aiming to provide a simple solution for writing interesting TCPR mods.

  • Supports async connections to multiple KAG servers.

The basic design of the library is that the user creates a Client instance:

client = Client(nickname="playercount", host="localhost", port=50301, rcon_password="ilovetrenchrun")

Then adds some handlers to it:

client.add_handler(PingHandler())

Then calls the client's connect method:

client.connect()

Whenever the client receives a line of text from KAG, all matching handlers will be run. If any handler returns some text, it will be sent back to KAG as an RCON command.

What each handler does is totally up to the user. This could involve creating entries in a database, posting to a web API, or just logging to a file.

Example

import logging
import kagtcprlib
from kagtcprlib.handlers import BaseHandler

class PingHandler(BaseHandler):
    """Respond to 'ping' from KAG with code to print 'pong' in chat.
    """
    def handle(self, client_nickname, timestamp, content):
        if content == "ping":
            logging.info("Got ping from %s, sending pong.", client_nickname)
            return "getNet().server_SendMsg('pong');"


if __name__ == "__main__":
    logging.basicConfig(level=logging.INFO)
    client = kagtcprlib.Client(nickname="playercount", host="localhost", port=50301,
                               rcon_password="ilovetrenchrun")

    client.add_handler(PingHandler())
    client.connect_forever()

For more examples see the examples/ folder.

Contributing

You are welcome to contribute to this project.

Please ensure your feature branch is based on the master branch and is named like feature-foo-bar.

You must run pylint over your code and ensure it receives at least a score of 9.

Docs

https://benjamingorman.github.io/kagtcprlib/

Release files for kagtcprlib 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kagtcprlib 0.2.1
File Size Uploaded
kagtcprlib-0.2.1.tar.gz 244.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for kagtcprlib 0.2.1
File Interpreter ABI Platform
kagtcprlib-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 492.6 kB

Release files / kagtcprlib-0.2.1.tar.gz

Download URL kagtcprlib-0.2.1.tar.gz
Size 244.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d1074fc01ac062e9932b9c3256935fbf8316f56fd3ee99c1ad3b530c67e0309e
BLAKE2b-256 checksum
How to use checksums
e663cb68ba742e2e88dbc04e7ee6cbcadd16463b12e83dff3a2360d87a620138
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

Release files / kagtcprlib-0.2.1-py3-none-any.whl

Download URL kagtcprlib-0.2.1-py3-none-any.whl
Size 248.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b1e3623640b73bb587aad9fc080e35914aa0e38de77a9460c09e0cf78d7596a9
BLAKE2b-256 checksum
How to use checksums
d9b896d1e05b1abf9203238412c21f0518395644f63f70ebf1d2efbd05fa757f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page