mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
Make more progress
This commit is contained in:
parent
1928aaa2f5
commit
3f0b412024
9 changed files with 184 additions and 59 deletions
0
royalpack/__init__.py
Normal file
0
royalpack/__init__.py
Normal file
|
@ -1,8 +1,9 @@
|
|||
from typing import *
|
||||
import logging
|
||||
import aiohttp
|
||||
import steam.webapi
|
||||
import royalnet.commands as rc
|
||||
import royalnet.utils as ru
|
||||
import requests
|
||||
from royalnet.backpack import tables as rbt
|
||||
from .abstract.linker import LinkerCommand
|
||||
|
||||
|
@ -12,6 +13,8 @@ from ..types import DotaRank
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
||||
|
||||
class TrionfirealiCommand(LinkerCommand):
|
||||
name: str = "trionfireali"
|
||||
|
||||
|
|
0
royalpack/halloween2020/__init__.py
Normal file
0
royalpack/halloween2020/__init__.py
Normal file
76
royalpack/halloween2020/check.py
Normal file
76
royalpack/halloween2020/check.py
Normal file
|
@ -0,0 +1,76 @@
|
|||
from typing import *
|
||||
import abc
|
||||
import aiohttp
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .trionfistatus import TrionfiStatus
|
||||
|
||||
|
||||
__all__ = [
|
||||
"Check",
|
||||
"CheckPlayedSteamGame",
|
||||
"CheckAchievementSteamGame",
|
||||
]
|
||||
|
||||
|
||||
class Check(metaclass=abc.ABCMeta):
|
||||
@abc.abstractmethod
|
||||
async def check(self, status: "TrionfiStatus") -> bool:
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
class CheckPlayedSteamGame(Check):
|
||||
def __init__(self, appid: int, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.appid: int = appid
|
||||
|
||||
async def check(self, status: "TrionfiStatus") -> bool:
|
||||
async with aiohttp.ClientSession() as ah_session:
|
||||
# noinspection PyProtectedMember
|
||||
async with ah_session.get("https://api.steampowered.com/IPlayerService/GetOwnedGames/v1/",
|
||||
params={
|
||||
"steamid": status._steamid,
|
||||
"include_appinfo": True,
|
||||
"include_played_free_games": True,
|
||||
"include_free_sub": True,
|
||||
"appids_filter": self.appid,
|
||||
}) as response:
|
||||
try:
|
||||
j = await response.json()
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
games = j["response"]["games"]
|
||||
for game in games:
|
||||
if game["appid"] != self.appid:
|
||||
continue
|
||||
if game["playtime_forever"] >= 1:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
class CheckAchievementSteamGame(Check):
|
||||
def __init__(self, appid: int, achievement_name: str, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.appid: int = appid
|
||||
self.achivement_name: str = achievement_name
|
||||
|
||||
async def check(self, status: "TrionfiStatus") -> bool:
|
||||
async with aiohttp.ClientSession() as ah_session:
|
||||
# noinspection PyProtectedMember
|
||||
async with ah_session.get("http://api.steampowered.com/ISteamUserStats/GetPlayerAchievements/v1/",
|
||||
params={
|
||||
"steamid": status._steamid,
|
||||
"appid": self.appid,
|
||||
}) as response:
|
||||
try:
|
||||
j = await response.json()
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
achievements = j["playerstats"]["achievements"]
|
||||
for ach in achievements:
|
||||
if ach["apiname"] != self.achivement_name:
|
||||
continue
|
||||
return ach["achieved"] == 1
|
||||
return False
|
|
@ -1,168 +1,170 @@
|
|||
from typing import *
|
||||
from .trionfoinfo import TrionfoInfo
|
||||
from .check import *
|
||||
|
||||
|
||||
class Halloween2020Tarot:
|
||||
def __init__(self,
|
||||
variable: str,
|
||||
title: str,
|
||||
roman: str,
|
||||
name: str,
|
||||
objective: str,
|
||||
puzzle: str,
|
||||
check: Optional[Callable[..., Awaitable[...]]]):
|
||||
self.variable: str = variable
|
||||
self.title: str = title
|
||||
self.roman: str = roman
|
||||
self.name: str = name
|
||||
self.objective: str = objective
|
||||
self.puzzle: str = puzzle
|
||||
self.check: Optional[Callable[..., Awaitable[...]]] = check
|
||||
|
||||
|
||||
halloween2020tarots = (
|
||||
Halloween2020Tarot(
|
||||
trionfilist = (
|
||||
TrionfoInfo(
|
||||
variable="zero",
|
||||
title="o",
|
||||
roman="0",
|
||||
name="Il Folle",
|
||||
puzzle="IL DESTINO TI ATTENDE",
|
||||
objective="Partecipa ai Trionfi Reali.",
|
||||
puzzle="Scopri nuovi indizi ottenendo dei Trionfi!",
|
||||
check=None,
|
||||
),
|
||||
Halloween2020Tarot(
|
||||
TrionfoInfo(
|
||||
variable="i",
|
||||
title="i",
|
||||
roman="I",
|
||||
name="Il Mago",
|
||||
objective="Trova una magia che possa fare almeno 250 danni.",
|
||||
puzzle="L'ultimo giorno del decimo mese...",
|
||||
puzzle="L'ULTIMO GIORNO",
|
||||
objective="Trova una /spell che possa fare almeno 250 danni.",
|
||||
check=None,
|
||||
),
|
||||
Halloween2020Tarot(
|
||||
TrionfoInfo(
|
||||
variable="ii",
|
||||
title="ii",
|
||||
roman="II",
|
||||
name="La Papessa",
|
||||
name="La Sacerdotessa",
|
||||
puzzle="DEL DECIMO MESE",
|
||||
objective="Gioca almeno un'ora a [url=https://store.steampowered.com/app/881100]Noita[/url].",
|
||||
check=CheckPlayedSteamGame(881100),
|
||||
),
|
||||
Halloween2020Tarot(
|
||||
TrionfoInfo(
|
||||
variable="iii",
|
||||
title="iii",
|
||||
roman="III",
|
||||
name="L'Imperatrice",
|
||||
puzzle="NON IMPEGNARTI",
|
||||
objective="Gioca a [url=https://store.steampowered.com/app/245170]Skullgirls[/url].",
|
||||
check=CheckPlayedSteamGame(245170),
|
||||
),
|
||||
Halloween2020Tarot(
|
||||
TrionfoInfo(
|
||||
variable="iv",
|
||||
title="iv",
|
||||
roman="IV",
|
||||
name="L'Imperatore",
|
||||
puzzle="ESEGUI GLI ORDINI",
|
||||
objective="Vinci una partita su [url=https://store.steampowered.com/app/611500]Quake Champions[/url].",
|
||||
check=CheckAchievementSteamGame(611500, "qc_victory")
|
||||
),
|
||||
Halloween2020Tarot(
|
||||
TrionfoInfo(
|
||||
variable="v",
|
||||
title="v",
|
||||
roman="V",
|
||||
name="Il Papa",
|
||||
puzzle="ALLA SEDICESIMA ORA",
|
||||
),
|
||||
Halloween2020Tarot(
|
||||
TrionfoInfo(
|
||||
variable="vi",
|
||||
title="vi",
|
||||
roman="VI",
|
||||
name="Gli Amanti",
|
||||
objective="Completa [url=https://store.steampowered.com/app/698780]Doki Doki "
|
||||
"Literature Club[/url].",
|
||||
puzzle="ANCORA DIECI MINUTI",
|
||||
objective="Finisci l'Atto 3 di [url=https://store.steampowered.com/app/698780]Doki Doki Literature Club["
|
||||
"/url].",
|
||||
check=CheckPlayedSteamGame(698780),
|
||||
),
|
||||
Halloween2020Tarot(
|
||||
TrionfoInfo(
|
||||
variable="vii",
|
||||
title="vii",
|
||||
roman="VII",
|
||||
name="Il Carro",
|
||||
puzzle="SOPRA UN CARRO",
|
||||
),
|
||||
Halloween2020Tarot(
|
||||
TrionfoInfo(
|
||||
variable="viii",
|
||||
title="viii",
|
||||
roman="VIII",
|
||||
name="La Giustizia",
|
||||
objective="Porta la giustizia dalla tua parte su [url=https://store.steampowered.com/app/1289310]Helltaker["
|
||||
"/url].",
|
||||
check=CheckAchievementSteamGame(1289310, "achiev_05"),
|
||||
),
|
||||
Halloween2020Tarot(
|
||||
TrionfoInfo(
|
||||
variable="ix",
|
||||
title="ix",
|
||||
roman="IX",
|
||||
name="L'Eremita",
|
||||
puzzle="SEGRETAMENTE",
|
||||
),
|
||||
Halloween2020Tarot(
|
||||
TrionfoInfo(
|
||||
variable="x",
|
||||
title="x",
|
||||
roman="X",
|
||||
name="La Fortuna",
|
||||
),
|
||||
Halloween2020Tarot(
|
||||
TrionfoInfo(
|
||||
variable="xi",
|
||||
title="xi",
|
||||
roman="XI",
|
||||
name="La Forza",
|
||||
objective="Gioca 3 partite Ranked 1v1 su "
|
||||
"[url=https://steamcommunity.com/id/steffo1999/stats/appid/291550/achievements]Brawlhalla[/url]."
|
||||
),
|
||||
Halloween2020Tarot(
|
||||
TrionfoInfo(
|
||||
variable="xii",
|
||||
title="xii",
|
||||
roman="XII",
|
||||
name="L'Appeso",
|
||||
),
|
||||
Halloween2020Tarot(
|
||||
TrionfoInfo(
|
||||
variable="xiii",
|
||||
title="xiii",
|
||||
roman="XIII",
|
||||
name="La Morte",
|
||||
objective="Raggiungi la Tenuta dell'Antenato su [url=https://store.steampowered.com/app/262060]Darkest Dungeon["
|
||||
"/url].",
|
||||
check=CheckAchievementSteamGame(262060, "welcome_home"),
|
||||
),
|
||||
Halloween2020Tarot(
|
||||
TrionfoInfo(
|
||||
variable="xiv",
|
||||
title="xiv",
|
||||
roman="XIV",
|
||||
name="La Temperanza",
|
||||
),
|
||||
Halloween2020Tarot(
|
||||
TrionfoInfo(
|
||||
variable="xv",
|
||||
title="xv",
|
||||
roman="XV",
|
||||
name="Il Diavolo",
|
||||
),
|
||||
Halloween2020Tarot(
|
||||
TrionfoInfo(
|
||||
variable="xvi",
|
||||
title="xvi",
|
||||
roman="XVI",
|
||||
name="La Torre",
|
||||
),
|
||||
Halloween2020Tarot(
|
||||
TrionfoInfo(
|
||||
variable="xvii",
|
||||
title="xvii",
|
||||
roman="XVII",
|
||||
name="Le Stelle",
|
||||
),
|
||||
Halloween2020Tarot(
|
||||
TrionfoInfo(
|
||||
variable="xviii",
|
||||
title="xviii",
|
||||
roman="XVIII",
|
||||
name="La Luna",
|
||||
objective="Gioca a [url=https://store.steampowered.com/app/388880]Oxenfree[/url].",
|
||||
check=CheckPlayedSteamGame(388880),
|
||||
),
|
||||
Halloween2020Tarot(
|
||||
TrionfoInfo(
|
||||
variable="xix",
|
||||
title="xix",
|
||||
roman="XIX",
|
||||
name="Il Sole",
|
||||
),
|
||||
Halloween2020Tarot(
|
||||
TrionfoInfo(
|
||||
variable="xx",
|
||||
title="xx",
|
||||
roman="XX",
|
||||
name="Il Giudizio",
|
||||
),
|
||||
Halloween2020Tarot(
|
||||
TrionfoInfo(
|
||||
variable="xxi",
|
||||
title="xxi",
|
||||
roman="XII",
|
||||
name="Il Mondo",
|
||||
objective="Risolvi il mistero dei Trionfi Reali.",
|
||||
puzzle="""44°35'45.0"N 11°02'58.9"E""",
|
||||
objective="Risolvi il mistero dei Trionfi Reali.",
|
||||
check=None,
|
||||
),
|
||||
)
|
|
@ -3,8 +3,8 @@ from sqlalchemy.orm import relationship, backref
|
|||
from sqlalchemy.ext.declarative import declared_attr
|
||||
|
||||
|
||||
class Halloween2020:
|
||||
__tablename__ = "halloween2020"
|
||||
class TrionfiStatus:
|
||||
__tablename__ = "trionfistatus"
|
||||
|
||||
@declared_attr
|
||||
def _steamid(self):
|
||||
|
@ -12,7 +12,7 @@ class Halloween2020:
|
|||
|
||||
@declared_attr
|
||||
def steam(self):
|
||||
return relationship("Steam", backref=backref("halloween2020", uselist=False))
|
||||
return relationship("Steam", backref=backref("trionfistatus", uselist=False))
|
||||
|
||||
@declared_attr
|
||||
def zero(self):
|
44
royalpack/halloween2020/trionfoinfo.py
Normal file
44
royalpack/halloween2020/trionfoinfo.py
Normal file
|
@ -0,0 +1,44 @@
|
|||
import royalnet.utils as ru
|
||||
from typing import *
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .check import Check
|
||||
|
||||
|
||||
class TrionfoInfo:
|
||||
def __init__(self,
|
||||
variable: str,
|
||||
title: str,
|
||||
roman: str,
|
||||
name: str,
|
||||
objective: str,
|
||||
puzzle: str,
|
||||
check: Optional["Check"]):
|
||||
self.variable: str = variable
|
||||
self.title: str = title
|
||||
self.roman: str = roman
|
||||
self.name: str = name
|
||||
self.objective: str = objective
|
||||
self.puzzle: str = puzzle
|
||||
self.check: Optional["Check"] = check
|
||||
|
||||
def json_anonymous(self) -> ru.JSON:
|
||||
return {
|
||||
"variable": self.variable,
|
||||
"title": self.title,
|
||||
"roman": self.roman,
|
||||
"name": self.name,
|
||||
"objective": self.objective,
|
||||
}
|
||||
|
||||
def json_user(self, obj) -> ru.JSON:
|
||||
status = obj.__getattribute__(self.variable)
|
||||
return {
|
||||
"variable": self.variable,
|
||||
"title": self.title,
|
||||
"roman": self.roman,
|
||||
"name": self.name,
|
||||
"objective": self.objective,
|
||||
"puzzle": self.puzzle if status is not None else None,
|
||||
"completed_on": status
|
||||
}
|
|
@ -19,7 +19,7 @@ from .mmresponse import MMResponse
|
|||
from .cvstats import Cvstats
|
||||
from .treasure import Treasure
|
||||
from .osu import Osu
|
||||
from .halloween2020 import Halloween2020
|
||||
from ..halloween2020.trionfistatus import Halloween2020
|
||||
|
||||
# Enter the tables of your Pack here!
|
||||
available_tables = [
|
||||
|
|
|
@ -77,7 +77,7 @@ class Steam:
|
|||
|
||||
"dota": self.dota.json() if self.dota is not None else None,
|
||||
"brawlhalla": self.brawlhalla.json() if self.brawlhalla is not None else None,
|
||||
"halloween2020": self.halloween2020.json() if self.halloween2020 is not None else None,
|
||||
"trionfistatus": self.trionfistatus.json() if self.trionfistatus is not None else None,
|
||||
}
|
||||
|
||||
def __repr__(self):
|
||||
|
|
Loading…
Reference in a new issue