A Python wrapper for the IW4M-Admin API
Project description
IW4M-Admin API Wrapper 🚀
A Python wrapper designed for the IW4M-Admin server administration tool 🛠️
This wrapper provides an easy way to interact with IW4M-Admin servers, enabling server commands, retrieving player information, and managing penalties through Python scripts. It supports both synchronous and asynchronous usage
Features 🌟
- Command Execution: Perform in-game commands like kick, ban, change map, and more
- Player Management: Fetch player stats, connection history, and chat history
- Penalty Management: Issue and track penalties (warnings, bans, etc)
- Real-time Interaction: Send messages to players and retrieve chat logs
- Async Support: Full asynchronous support
Getting Started
Installation 📦
To install the IW4M-Admin API Wrapper you can use pip:
Windows
pip install iw4m
Linux/Mac
pip3 install iw4m
Initialization ⚙️
Create an instance of the IW4MWrapper class by providing your server details and authentication cookie
from iw4m import IW4MWrapper
iw4m = IW4MWrapper(
base_url="http://your.iw4m.com", # Replace with your server address
server_id=1234567890, # Replace with your server ID
cookie=".AspNetCore.Cookies=CfB_u..." # Replace with your .AspNetCore cookie
)
Commands 📜
Use the Commands class to interact with the server
# Create an instance of Commands
commands = iw4m.Commands(iw4m)
# Example usage
response = commands.kick("<player>", "<reason>")
print(response)
response = commands.ban("<player>", "<reason>")
print(response)
response = commands.tempban("<player>", "<duration>", "<reason>")
print(response)
All available commands can be found at your server's help page, and the function names in the Commands class match the command names listed there.
Initialization (Async) 🌐
Create an instance of the AsyncIW4MWrapper class by providing your cookie, server address, and server ID
from iw4m import AsyncIW4MWrapper
import asyncio
iw4m = AsyncIW4MWrapper(
base_url="http://your.iw4m.com", # Replace with your server address
server_id=1234567890, # Replace with your server ID
cookie=".AspNetCore.Cookies=CfB_u..." # Replace with your .AspNetCore cookie
)
Commands (Async) ⚡
Use the Commands class to interact with the server, all methods are asynchronous and should be awaited
# Create an instance of Commands
commands = iw4m.Commands(iw4m)
async def main():
# Example usage
response = await commands.kick("<player>", "<reason>")
print(response)
response = await commands.ban("<player>", "<reason>")
print(response)
response = await commands.tempban("<player>", "<duration>", "<reason>")
print(response)
asyncio.run(main())
All available commands can be found at your server's help page, and the function names in the Commands class match the command names listed there.
Server Class 🎮
The Server class provides utility functions for interacting with the IW4M-Admin server
Methods
get_server_ids()
Retrieves a list of available servers and their corresponding IDs.
Returns:
(list): A list of dictionaries, each containing:
- server (str): The name of the server
- id (str): The unique identifier for the server
send_command(command: str)
executes an iw4m-admin console command and returns the response
Parameters:
command (str): The command to execute
Returns:
(str): Response from the server
Raises:
Exception if the request fails
color_handler(color: str)
Converts a color name to its corresponding color code used by the T6 server
Parameters:
color (str): The color name (e.g., "red", "green")
Returns:
(str): The color code for the specified color, or an empty string if the color is unknown
read_chat()
Retrieves chat messages from the server
Returns:
(list): A list of tuples, each containing the sender's name and their message
recent_clients(offset: int = 0)
Retrieves a list of recent clients.
Parameters:
offset (int, optional): The offset for pagination (default is 0)
Returns:
(list): A list of dictionaries containing details about recent clients.
find_player(name: str = "", xuid: str = "", count: int = 1, offset: int = 0, direction: int = 0)
Finds players on the server by name or XUID
Parameters:
name (str, optional): The player's name
xuid (str, optional): The player's XUID
count (int, optional): Number of players to return (default is 1)
offset (int, optional): Offset for pagination (default is 0)
direction (int, optional): Search direction (default is 0)
Returns:
(str): The response from the server containing player information
get_players()
Retrieves a list of players currently connected to the server
Returns:
(list): A list of tuples, each containing a player's name and their link
get_roles()
Retrieves a list of available roles on the server
Returns: A list of roles available
get_admins(role: str = "all", count: int = None)
Retrieves a list of administrators based on their role
Parameters:
role (str): The role to filter by (default is "all")
count (int, optional): The number of admins to return (default is unlimited)
Returns: A list of dictionaries containing details about the administrators
Player Class 👾
The Player class provides methods for retrieving and managing player information
Methods
stats(client_id: str)
Fetches the statistics for a specific player
Parameters:
client_id (str): The client ID of the player
Returns:
(str): The response from the server containing player statistics
info(client_id: str)
Retrieves detailed information about a player
Parameters:
client_id (str): The client ID of the player
Returns:
(dict): A dictionary containing the player's name, GUID, IP address, and statistics
chat_history(client_id: str, count: int)
Fetches the chat history for a specified client id
Parameters:
client_id (str): The player's client_id
count (int): The number of messages to retrieve
Returns:
(list): A list of chat messages sent by the player
advanced_stats(client_id: str)
Retrieves advanced statistics for a specified player.
Parameters:
client_id (str): The client ID of the player
Returns:
(dict): A dictionary containing advanced statistics, including player stats, hit locations, and weapon usage.
recent_clients(offset: int = 0)
Retrieves a list of recent clients.
Parameters:
offset (int, optional): The offset for pagination (default is 0)
Returns:
(list): A list of dictionaries containing details about recent clients.
name_changes(client_id: str)
Retrieves the name changes for a specified client id
Parameters:
client_id (str): The player's client_id
Returns:
(list): A list of tuples containing the old username, IP address, and date of change
administered_penalties(client_id: int, count: int = 30)
Retrieves penalties administered to players
Parameters:
client_id (int): The client ID of the player
count (int, optional): The number of penalties to return (default is 30)
Returns:
(list): A list of dictionaries containing details about the administered penalties
received_penalties(client_id: int, count: int = 30)
Retrieves penalties received by the player
Parameters:
client_id (int): The client ID of the player
count (int, optional): The number of penalties to return (default is 30)
Returns:
(list): A list of dictionaries containing details about the received penalties
connection_history(client_id: int, count: int = 30)
Fetches the connection history for a specified player
Parameters:
client_id (int): The client ID of the player
count (int, optional): The number of connection entries to return (default is 30)
Returns:
(list): A list of dictionaries containing connection history details
permissions(client_id: int, count: int = 30)
Retrieves the permission levels for a specified player
Parameters:
client_id (int): The client ID of the player
count (int, optional): The number of permission entries to return (default is 30)
Returns:
(list): A list of dictionaries containing permission change details
Come Play on Brownies SND 🍰
Why Brownies? 🤔
- Stability: Brownies delivers a consistent, lag-free experience, making it the perfect choice for players who demand uninterrupted action
- Community: The players at Brownies are known for being helpful, competitive, and fun—something Orion can only dream of
- Events & Features: Brownies is constantly running unique events and offers more server-side customization options than Orion, ensuring every game feels fresh
Brownies Discord | Brownies IW4M | Made With ❤️ By Budiworld
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file iw4m-0.3.1.tar.gz.
File metadata
- Download URL: iw4m-0.3.1.tar.gz
- Upload date:
- Size: 18.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef313243cd6724477e2bc664da0b63ab37a15a4484a7de731bc818ca5b9b93c7
|
|
| MD5 |
122832b601bbb0507946d09e215c6b92
|
|
| BLAKE2b-256 |
6b136213203384e470bbc601e4cb673948952598e53879249c62b76af1d41f40
|
File details
Details for the file iw4m-0.3.1-py3-none-any.whl.
File metadata
- Download URL: iw4m-0.3.1-py3-none-any.whl
- Upload date:
- Size: 16.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98fe8817a99cbcef267e2d37e0a0a960ac3b8b4549d09a5df679580e8970ef8f
|
|
| MD5 |
1a2272635be630d8de658e12fbd4ac11
|
|
| BLAKE2b-256 |
ad23b41f4d4964d88c744d2b4491a0bcd1ebca40cae001c8d7ff00d4794fb557
|