{"id":17347881,"url":"https://github.com/tuokri/rs2wapy","last_synced_at":"2025-04-14T21:02:54.892Z","repository":{"id":57462964,"uuid":"218355577","full_name":"tuokri/rs2wapy","owner":"tuokri","description":"Rising Storm 2: Vietnam WebAdmin Python Interface","archived":false,"fork":false,"pushed_at":"2022-04-06T05:10:37.000Z","size":188,"stargazers_count":3,"open_issues_count":5,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-22T23:51:13.600Z","etag":null,"topics":["rcon","remote-control","rising-storm-2-vietnam","rs2","udk","unreal-engine-3","webadmin"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tuokri.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-10-29T18:26:49.000Z","updated_at":"2022-04-06T05:10:40.000Z","dependencies_parsed_at":"2022-09-12T14:22:20.720Z","dependency_job_id":null,"html_url":"https://github.com/tuokri/rs2wapy","commit_stats":null,"previous_names":[],"tags_count":37,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuokri%2Frs2wapy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuokri%2Frs2wapy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuokri%2Frs2wapy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuokri%2Frs2wapy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tuokri","download_url":"https://codeload.github.com/tuokri/rs2wapy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240780667,"owners_count":19856402,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["rcon","remote-control","rising-storm-2-vietnam","rs2","udk","unreal-engine-3","webadmin"],"created_at":"2024-10-15T16:50:26.225Z","updated_at":"2025-02-26T02:31:23.665Z","avatar_url":"https://github.com/tuokri.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rs2wapy\n[![Travis](https://travis-ci.com/tuokri/rs2wapy.svg?branch=master)](https://travis-ci.com/github/tuokri/rs2wapy)\n[![Maintainability](https://api.codeclimate.com/v1/badges/9d561a84b14c8c3486f6/maintainability)](https://codeclimate.com/github/tuokri/rs2wapy/maintainability)\n\n### Rising Storm 2: Vietnam WebAdmin Python Interface\nProvides a Python interface for performing RS2 WebAdmin\ntasks programmatically.\n\nThe library uses PycURL internally to communicate with RS2 WebAdmin.\n\n**Work in progress; interface will change!**\n\n\n### Brief Usage Examples\nThis section contains some brief usage examples.\nFor more comprehensive tutorials check out the\n[examples repository](https://github.com/tuokri/rs2wapy-examples).\n\n##### Installation\n```bash\n# Requires Python=\u003e3.7\npip install rs2wapy\n```\n\n##### Steam Web API key (optional)\nSetting your Steam Web API key as an environment variable\nallows `rs2wapy` to offer some extra functionality.\n\nUnix:\n```bash\nexport STEAM_WEB_API_KEY=\"TOPSECRETKEY\"\n```\n\nWindows:\n```Batchfile\nset STEAM_WEB_API_KEY=\"TOPSECRETKEY\"\n```\n\n##### Quickstart\nIt is recommended to create a new WebAdmin account for\n`rs2wapy`.\n```python\nfrom rs2wapy import RS2WebAdmin\n\nwa = RS2WebAdmin(\n    username=\"AutoModerator\",\n    password=\"topsecret123\",\n    webadmin_url=\"http://localhost:8080/\",\n)\n```\n\n##### Poll server ranked status and switch map automatically\n```python\nwhile True:\n    if not wa.get_current_game().ranked:\n        wa.post_chat_message(\"Unranked bug happened! Changing map in 5 seconds!\")\n        time.sleep(5)\n        wa.change_map(\"VNTE-Resort\")\n    time.sleep(1)\n```\n\n##### Forward in-game chat to a Discord webhook with discord.py.\n```python\nimport time\n\nfrom discord import RequestsWebhookAdapter\nfrom discord import Webhook\nfrom discord.utils import escape_markdown\nfrom discord.utils import escape_mentions\n\nfrom rs2wapy import RS2WebAdmin\nfrom rs2wapy.models import AllTeam\nfrom rs2wapy.models import BlueTeam\nfrom rs2wapy.models import RedTeam\n\n# Discord webhook info.\nwebhook = Webhook.partial(\n    id=123456,\n    token=\"abcdefg\",\n    adapter=RequestsWebhookAdapter()\n)\n\n# Webadmin credentials.\nUSERNAME = \"Admin\"\nPASSWORD = \"adminpassword\"\nURL = \"http://127.0.0.1:8080/ServerAdmin\"\n\nTEAM_TO_EMOJI = {\n    BlueTeam: \":blue_square:\",\n    RedTeam: \":red_square:\",\n    AllTeam: \":white_square_button:\",\n}\n\nTEAM_TO_TEAMNAME = {\n    BlueTeam: \"SOUTH\",\n    RedTeam: \"NORTH\",\n    AllTeam: \"ALL\",\n}\n\n\ndef get_team_emoji(team):\n    try:\n        return TEAM_TO_EMOJI[team]\n    except KeyError:\n        return \"?\"\n\n\ndef get_team_name(team):\n    try:\n        return TEAM_TO_TEAMNAME[team]\n    except KeyError:\n        return \"?\"\n\n\ndef main():\n    webadmin = RS2WebAdmin(USERNAME, PASSWORD, URL)\n    messages = []\n\n    while True:\n        try:\n            messages.extend(webadmin.get_chat_messages())\n        except Exception as e:\n            print(f\"error getting messages: {e}\")\n            print(\"attempting to reconnect...\")\n            webadmin = RS2WebAdmin(USERNAME, PASSWORD, URL)\n\n        if messages:\n            for message in messages:\n                text = message.text\n                sender = message.sender\n                team = message.team\n\n                team_name = get_team_name(team)\n                team_emoji = get_team_emoji(team)\n\n                # Prevent pinging @everyone from in-game chat\n                # and other \"funny\" stuff.\n                text = escape_markdown(text)\n                text = escape_mentions(text)\n                sender = escape_markdown(sender)\n                sender = escape_mentions(sender)\n\n                try:\n                    webhook.send(f\"**{sender}** [{team_name}] {team_emoji}: {text}\")\n                except Exception as e:\n                    print(f\"error sending message: {e}\")\n\n        messages = []\n        time.sleep(3)\n```\n\nThe above are just simple examples of how to use the library. In the future,\nthe library will be able to automate all tasks which RS2 WebAdmin offers.\nYou can check the status of currently implemented WebAdmin features here:\nhttps://github.com/tuokri/rs2wapy/issues/9.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftuokri%2Frs2wapy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftuokri%2Frs2wapy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftuokri%2Frs2wapy/lists"}