Guard

SPGG Bot Docs

Give me your ID if you want to cross this world!

#Play Module

File: play.py · Lines: 158

#Overview

The play.py module provides functionality to replay pre-recorded input sequences from JSON files. These recordings contain mouse movements, clicks, key presses, and custom events with precise timing.

#Functions

#replay_events(filename, _callback) ACTIVE

Main function to replay a JSON recording file.

Parameter Type Default Description
filename str Path to JSON recording file
_callback callable None Callback for custom events

Flow:

  1. Load events from JSON file
  2. Start keyboard listener (F8 to stop)
  3. Replay events with precise timing
  4. Custom and color events block the main loop until complete

#press_key(key) ACTIVE

Press and release a keyboard key.

Parameter Type Description
key str Key name (e.g., 'Key.enter', 'Key.f', 'Key.2')

Internally resolves key names via _resolve_key().


#_resolve_key(k) INTERNAL

Convert key string to pynput Key object or character.

Input Output
'Key.enter' keyboard.Key.enter
'Key.right' keyboard.Key.right
'Key.f' 'f' (literal character)
'Key.2' '2' (literal character)
'f' 'f'

#process_event(event, _callback) ACTIVE

Process a single event from the recording.

Event Type Action
move Move mouse to (x, y) with slight randomization
click Press/release mouse button
scroll Scroll mouse wheel
keypress Press keyboard key
keyrelease Release keyboard key
custom Call _callback with event name
color Wait for pixel at (x, y) to match expected RGB (60s timeout)

#simulate_typing(text) DEPRECATED

Type text character by character with random delays (50-100ms). Not called by any bot script.


#simulate_mouse_movement(dest_x, dest_y, duration) DEPRECATED

Move mouse smoothly using pyautogui.moveTo(). Not called by any bot script.


#get_first_mouse_position(filename) DEPRECATED

Get the first mouse position from a recording file. Not called by any bot script.


#on_press(key) ACTIVE

F8 key listener — sets stop_script = True to abort replay.

#Recording File Format

[
  {
    "time": 0.0,
    "type": "move",
    "details": {"x": 500, "y": 300}
  },
  {
    "time": 0.5,
    "type": "keypress",
    "details": {"key": "'Key.enter'"}
  },
  {
    "time": 1.0,
    "type": "custom",
    "details": {"event": "custom #1"}
  },
  {
    "time": 2.0,
    "type": "color",
    "details": {"x": 100, "y": 200, "r": 255, "g": 0, "b": 0}
  }
]