Skip to content

Instantly share code, notes, and snippets.

@simonsan
Last active April 23, 2021 09:20
Show Gist options
  • Save simonsan/6c439187b0d1a98f288a0a52f3be698c to your computer and use it in GitHub Desktop.
Save simonsan/6c439187b0d1a98f288a0a52f3be698c to your computer and use it in GitHub Desktop.
Readme for AoE2Bot by polskafan

aoe2bot

This repository contains a web app/API for chatbots for Age of Empires II streams. The API is developed in Python, and is designed to run on a remote server. Bots can then query pages for game and player information in response to viewer-issued commands.

API Reference

/elo

This route gets a player's rated 1v1 ranking from aoe2.net and reports it back synchronously.

!commands add !elo $(urlfetch https://twitch.polskafan.de/elo?player=$(querystring)&default=mmarss)

!commands add !elo $(urlfetch https://twitch.polskafan.de/elo?player=$(querystring)&default_id=406827)

!commands add !rank -a=!elo $(query)

Arguments

  • ?player [optional] The current Steam name of a player.
  • ?default The player to get if no player is specified. This should be the streamer's name.
  • ?default_id [optional] The profile to get if no player is specified. Use the route /profile_id to get this value for a given person. This should be the streamer's id.

/tgelo

This route gets a player's rated team game ranking from aoe2.net and reports it back synchronously.

!commands add !tgelo $(urlfetch https://twitch.polskafan.de/tgelo?player=$(querystring)&default=mmarss)

!commands add !tgelo $(urlfetch https://twitch.polskafan.de/tgelo?player=$(querystring)&default_id=406827)

!commands add !elotg -a=!tgelo $(query)

!commands add !tgrank -a=!tgelo $(query)

Arguments

  • ?player [optional] The current Steam name of a player.
  • ?default The player to get if no player is specified. This should be the streamer's name.
  • ?default_id [optional] The profile to get if no player is specified. Use the route /profile_id to get this value for a given person. This should be the streamer's id.

/balance

This route balances a list of players for team games.

!commands add !balance $(urlfetch https://twitch.polskafan.de/balance?players=$(querystring))

Arguments

  • ?players A comma-delimited list of players to balance. All players should have at least a 1v1 or team game ranking. 4, 6, or 8 players should be provided. Informative error messages are returned if these conditions are not heeded.

/judge

This route gets information about the rankings of all players in a team game.

!commands add !judge $(urlfetch https://twitch.polskafan.de/judge?players=$(querystring))

Arguments

  • ?players A comma-delimited list of players in a team game. The list should consist of an even number of players, listing first all players of team 1, then of team 2.

/lastmatch

This route looks up a player's most recent (or current) match, and returns information about the players and teams playing.

!commands add !match $(urlfetch https://twitch.polskafan.de/lastmatch?steam_id=76561199003184910)

!commands add !match $(urlfetch https://twitch.polskafan.de/lastmatch?profile_id=406827)

!commands add !match-id $(urlfetch https://twitch.polskafan.de/lastmatch?profile_id=$(querystring))

Arguments

  • ?steam_id The steam64 id to get the last match for. This should be the streamer's id. Note: A lookup via steam_id only works for players playing on the steam platform. Use the platform agnostic profile_id for other platforms (i.e. Xbox) instead.
  • ?profile_id The profile to get the last match for. This should be the streamer's id.
  • ?channel (optional) This is a random string used to link /castmatch to /lastmatch. For Nightbot, this works automatically, via Nightbot Request headers. For other bots just generate a random string and use it in both commands.

/castmatch

This route overwrites the default player in the /lastmatch route for a given channel. This is useful to temporarily change the requested player when games are casted. Once the default player starts a new match it should automatically clear any temporary overwrite. To manually clear the overwrite, use !castmatch clear.

Note: This command should be moderator only.

!commands add !castmatch $(urlfetch https://twitch.polskafan.de/castmatch?castplayer=$(querystring))

!commands add !castmatch $(urlfetch https://twitch.polskafan.de/castmatch?castplayer=$(querystring))&channel=EQ688erUmfuTw7nX

Arguments

  • ?castplayer The name of one of the players in the casted match
  • ?channel (optional) This is a random string used to link /castmatch to /lastmatch. For Nightbot, this works automatically, via Nightbot request headers. For other bots just generate a random string and use it in both commands.

/matchhistory

Similar to the /lastmatch route, but /matchhistory allows you to go back through older matches of a player. This can be used to create !match responses for games that were previously played.

!commands add !match $(urlfetch https://twitch.polskafan.de/lastmatch?steam_id=76561199003184910&start=2)

!commands add !match $(urlfetch https://twitch.polskafan.de/lastmatch?profile_id=406827&start=2)

Arguments

  • ?start The index of the match to return. For example start=2 returns the 2nd to last match of a player.
  • ?steam_id The steam64 id to get the last match for. This should be the streamer's id. Note: A lookup via steam_id only works for players playing on the steam platform. Use the platform agnostic profile_id for other platforms (i.e. Xbox) instead.
  • ?profile_id The profile to get the last match for. This should be the streamer's id.

/session

This route calculates the daily score of the provided steam or profile ID. For this it gets the latest matches and then searches through all played ladders and sums up the wins, losses and elo difference.

!commands add !autoscore $(urlfetch https://twitch.polskafan.de/session?steam_id=76561199003184910)

!commands add !autoscore $(urlfetch https://twitch.polskafan.de/session?profile_id=406827)

Arguments

  • ?steam_id The steam64 id to get the daily results for. This should be the streamer's id. Note: A lookup via steam_id only works for players playing on the steam platform. Use the platform agnostic profile_id for other platforms (i.e. Xbox) instead.
  • ?profile_id The profile to get the daily results for. This should be the streamer's id.

/analysis

This route looks up the ID of the last completed match. It then returns a link to aoe2insights.com to the analysis page of that match.

!commands add !analysis $(urlfetch https://twitch.polskafan.de/analysis?steam_id=76561199003184910)

!commands add !analysis $(urlfetch https://twitch.polskafan.de/analysis?profile_id=406827)

Arguments

  • ?steam_id The steam64 id to get the last match for. This should be the streamer's id. Note: A lookup via steam_id only works for players playing on the steam platform. Use the platform agnostic profile_id for other platforms (i.e. Xbox) instead.
  • ?profile_id The profile to get the last match for. This should be the streamer's id.

/profile_id

This route gets a player's profile id from their name.

!commands add !profile-id -ul=moderator $(urlfetch https://twitch.polskafan.de/profile_id?player=mmarss)

Arguments

  • ?player The current Steam name of a player.

/civinfo

This route returns a aoe2techree.net link to the player's current civ.

!commands add !civinfo $(urlfetch https://twitch.polskafan.de/civinfo?search=$(querystring)&steam_id=76561199003184910)

!commands add !civinfo $(urlfetch https://twitch.polskafan.de/civinfo?search=$(querystring)&profile_id=406827)

Arguments

  • ?search The player color or player name of the player the civ should be returned for. Searching for 2 would return the civ for the red player in the current game. A search string returns the player with the clostest name to the search string. No search returns the civ of the streamer (see ?steam_id and ?profile_id).
  • ?steam_id The steam64 id to get the last match for. This should be the streamer's id. Note: A lookup via steam_id only works for players playing on the steam platform. Use the platform agnostic profile_id for other platforms (i.e. Xbox) instead.
  • ?profile_id The profile to get the last match for. This should be the streamer's id.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment