Created
August 16, 2021 19:22
-
-
Save jkazimierczak/29a65edcb2485ac550fb68af69911ab6 to your computer and use it in GitHub Desktop.
A presence status mapper for League of Legends Discord activity.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Author: Jakub Kazimierczak | |
Created: 2021/08/16 | |
License: MIT | |
This module contains an enum of Discord Presence statuses for the | |
League of Legends. There is also a mapper, that returns an adequate | |
enum member for a given activity status string. | |
Big thanks to Arjan Codes Discord members, namely @MellexPro and | |
@volitional_decisions for help with the code. | |
""" | |
from enum import Enum, auto | |
class LeaguePresenceStatusType(Enum): | |
NOT_SET = 0 | |
CHAMPION_SELECT = auto() | |
HOSTING = auto() | |
HOSTING_CUSTOM = auto() | |
IN_GAME = auto() | |
IN_QUEUE = auto() | |
OUT_OF_GAME = auto() | |
translation_map = { | |
( | |
"Ve výběru šampionů", | |
"In Championauswahl", | |
"In Champion Select", | |
"Στην Επιλογή Ήρωα", | |
"En Selección de campeones", | |
"En selección de campeón", | |
"Sélectionne un champion", | |
"Hősválasztás folyamatban", | |
"Nella selezione dei campioni", | |
"チャンピオン選択中", | |
"챔피언 선택 중", | |
"Wybiera bohatera", | |
"Na Seleção de Campeões", | |
"În ecranul de selecție a campionilor", | |
"Выбирает чемпиона", | |
"อยู่ในหน้าเลือกแชมเปี้ยน", | |
"Şampiyon Seçiminde", | |
"Đang chọn tướng", | |
"英雄选择中", | |
"选择英雄中", | |
"選擇英雄中", | |
): LeaguePresenceStatusType.CHAMPION_SELECT, | |
( | |
"V lobby", | |
"In der Lobby", | |
"In Lobby", | |
"Σε Λόμπι", | |
"En Sala", | |
"En sala", | |
"Dans un salon", | |
"Előszobában", | |
"Nella lobby", | |
"ロビー内", | |
"로비에서 대기 중", | |
"W poczekalni", | |
"No Saguão", | |
"În lobby", | |
"В лобби", | |
"อยู่ในล็อบบี้", | |
"Lobide", | |
"Đang trong sảnh chờ", | |
"房间中", | |
"在组队房间中", | |
"在組隊房間中", | |
): LeaguePresenceStatusType.HOSTING, | |
( | |
"Zakládá vlastní hru", | |
"Hostet freies Spiel", | |
"Hosting custom game", | |
"Φιλοξενεί προσαρμοσμένο παιχνίδι", | |
"Auspiciando una partida personalizada", | |
"Creando partida personalizada", | |
"Hôte d'une partie perso.", | |
"Egyéni játékot indított", | |
"Ospitando una partita personalizzata", | |
"カスタムゲームをホスト中", | |
"사용자 설정 게임 생성 중", | |
"Tworzy grę niestandardową", | |
"Sediando partida personalizada", | |
"Creează un joc personalizat", | |
"Создает свою игру", | |
"กำลังสร้างเกมแบบปรับแต่งได้", | |
"Özel Oyun Düzenliyor", | |
"Đang tạo trận tùy chọn", | |
"创建自定义对局中", | |
"创建自订对战中", | |
"創建自訂對戰中", | |
): LeaguePresenceStatusType.HOSTING_CUSTOM, | |
( | |
"Ve hře", | |
"Im Spiel", | |
"In Game", | |
"Σε παιχνίδι", | |
"En partida", | |
"En jeu", | |
"Játékban", | |
"In partita", | |
"ゲーム中", | |
"게임 중", | |
"W trakcie gry", | |
"Em partida", | |
"În joc", | |
"В игре", | |
"อยู่ในเกม", | |
"Oyunda", | |
"Đang chơi", | |
"游戏中", | |
"遊戲中", | |
): LeaguePresenceStatusType.IN_GAME, | |
( | |
"Ve frontě", | |
"In der Warteschlange", | |
"In Queue", | |
"Σε Ουρά", | |
"En cola", | |
"Dans la file", | |
"Várólistán", | |
"In coda", | |
"対戦待ち中", | |
"게임 찾는 중", | |
"W kolejce", | |
"Na fila", | |
"Pe lista de așteptare", | |
"В очереди", | |
"อยู่ในคิว", | |
"Sırada", | |
"Đang tìm trận", | |
"队列中", | |
"列队中", | |
"列隊中", | |
): LeaguePresenceStatusType.IN_QUEUE, | |
( | |
"Mimo hru", | |
"Nicht im Spiel", | |
"Out of game", | |
"Εκτός Παιχνιδιού", | |
"Fuera del juego", | |
"Fuera de partida", | |
"Hors du jeu", | |
"Játékon kívül", | |
"Fuori dalla partita", | |
"ゲームを終了中", | |
"게임 종료됨", | |
"Po grze", | |
"Fora de partida", | |
"În afara jocului", | |
"Не в игре", | |
"อยู่นอกเกม", | |
"Oyun Dışında", | |
"Trực tuyến", | |
"游戏外", | |
"离开游戏", | |
"離開遊戲", | |
): LeaguePresenceStatusType.OUT_OF_GAME, | |
} | |
def get_presence_type(activity_str: str) -> LeaguePresenceStatusType: | |
"""Determine presence status type from a status string. | |
:param activity_str: League of Legends Presence status string. | |
:return: LeaguePresenceStatusType enum member. | |
>>> get_presence_type('In Game') | |
<LeaguePresenceStatusType.IN_GAME: 4> | |
>>> get_presence_type('An Unknown State') | |
<LeaguePresenceStatusType.NOT_SET: 0> | |
""" | |
for k, v in translation_map.items(): | |
if activity_str in k: | |
return v | |
return LeaguePresenceStatusType.NOT_SET |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment