1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

More commands done

This commit is contained in:
Steffo 2019-11-29 15:55:52 +01:00
parent 1104dc408f
commit b1fec3d5c1
12 changed files with 219 additions and 139 deletions

99
poetry.lock generated
View file

@ -44,7 +44,7 @@ description = "Python package for providing Mozilla's CA Bundle."
name = "certifi"
optional = false
python-versions = "*"
version = "2019.9.11"
version = "2019.11.28"
[[package]]
category = "main"
@ -302,6 +302,38 @@ optional = false
python-versions = "*"
version = "2019.11.1"
[[package]]
category = "main"
description = "Python HTTP for Humans."
name = "requests"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
version = "2.22.0"
[package.dependencies]
certifi = ">=2017.4.17"
chardet = ">=3.0.2,<3.1.0"
idna = ">=2.5,<2.9"
urllib3 = ">=1.21.1,<1.25.0 || >1.25.0,<1.25.1 || >1.25.1,<1.26"
[package.extras]
security = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)", "idna (>=2.0.0)"]
socks = ["PySocks (>=1.5.6,<1.5.7 || >1.5.7)", "win-inet-pton"]
[[package]]
category = "main"
description = "RiotWatcher is a thin wrapper on top of the Riot Games API for League of Legends."
name = "riotwatcher"
optional = false
python-versions = "*"
version = "2.7.1"
[package.dependencies]
requests = "*"
[package.extras]
dev = ["coverage", "pre-commit", "pytest", "pytest-cov", "tox"]
[[package]]
category = "main"
description = ""
@ -374,7 +406,7 @@ sentry = ["sentry_sdk (~0.13.2)"]
telegram = ["python_telegram_bot (^12.2.0)"]
[package.source]
reference = "c4bc1811825d7b2609f587a4890ddb5b8a618cf6"
reference = "491301b6811a41bd02192209ae75de861332aca4"
type = "git"
url = "https://github.com/Steffo99/royalnet/"
@ -520,8 +552,8 @@ category = "main"
description = "Yet another URL library"
name = "yarl"
optional = false
python-versions = ">=3.5.3"
version = "1.3.0"
python-versions = ">=3.5"
version = "1.4.1"
[package.dependencies]
idna = ">=2.0"
@ -533,10 +565,10 @@ description = "YouTube video downloader"
name = "youtube-dl"
optional = false
python-versions = "*"
version = "2019.11.22"
version = "2019.11.28"
[metadata]
content-hash = "e358039cf58db05d50f73138e8b431bcbe8476bc60181233645f2064ee496023"
content-hash = "869279b7212d24287566f5b073831fa19f68f9e099177d96b78af0897e99489b"
python-versions = "^3.8"
[metadata.files]
@ -563,8 +595,8 @@ attrs = [
{file = "attrs-19.3.0.tar.gz", hash = "sha256:f7b7ce16570fe9965acd6d30101a28f62fb4a7f9e926b3bbc9b61f8b04247e72"},
]
certifi = [
{file = "certifi-2019.9.11-py2.py3-none-any.whl", hash = "sha256:fd7c7c74727ddcf00e9acd26bba8da604ffec95bf1c2144e67aff7a8b50e6cef"},
{file = "certifi-2019.9.11.tar.gz", hash = "sha256:e4f3620cfea4f83eedc95b24abd9cd56f3c4b146dd0177e83a21b4eb49e21e50"},
{file = "certifi-2019.11.28-py2.py3-none-any.whl", hash = "sha256:017c25db2a153ce562900032d5bc68e9f191e44e9a0f762f373977de9df1fbb3"},
{file = "certifi-2019.11.28.tar.gz", hash = "sha256:25b64c7da4cd7479594d035c08c2d809eb4aab3a26e5a990ea98cc450c320f1f"},
]
cffi = [
{file = "cffi-1.13.2-cp27-cp27m-macosx_10_6_intel.whl", hash = "sha256:3c9fff570f13480b201e9ab69453108f6d98244a7f495e91b6c654a47486ba43"},
@ -778,6 +810,14 @@ regex = [
{file = "regex-2019.11.1-cp38-none-win_amd64.whl", hash = "sha256:c7393597191fc2043c744db021643549061e12abe0b3ff5c429d806de7b93b66"},
{file = "regex-2019.11.1.tar.gz", hash = "sha256:720e34a539a76a1fedcebe4397290604cc2bdf6f81eca44adb9fb2ea071c0c69"},
]
requests = [
{file = "requests-2.22.0-py2.py3-none-any.whl", hash = "sha256:9cf5292fcd0f598c671cfc1e0d7d1a7f13bb8085e9a590f48c010551dc6c4b31"},
{file = "requests-2.22.0.tar.gz", hash = "sha256:11e007a8a2aa0323f5a921e9e6a2d7e4e67d9877e85773fba9ba6419025cbeb4"},
]
riotwatcher = [
{file = "riotwatcher-2.7.1-py2.py3-none-any.whl", hash = "sha256:3fb03b20f768cea7830d54c6d301a8341c67223625ac8536d26d1c140af3dcb0"},
{file = "riotwatcher-2.7.1.tar.gz", hash = "sha256:5349271c7e00637b7619491a6070e66603705db60558ea2a690e7016f6e6d9a4"},
]
royalnet = []
sentry-sdk = [
{file = "sentry-sdk-0.13.4.tar.gz", hash = "sha256:bfc486af718c268cf49ff43d6334ed4db7333ace420240b630acdd8f8a3a8f60"},
@ -833,29 +873,46 @@ websockets = [
{file = "websockets-8.1-cp36-cp36m-macosx_10_6_intel.whl", hash = "sha256:3762791ab8b38948f0c4d281c8b2ddfa99b7e510e46bd8dfa942a5fff621068c"},
{file = "websockets-8.1-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:3db87421956f1b0779a7564915875ba774295cc86e81bc671631379371af1170"},
{file = "websockets-8.1-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:4f9f7d28ce1d8f1295717c2c25b732c2bc0645db3215cf757551c392177d7cb8"},
{file = "websockets-8.1-cp36-cp36m-manylinux2010_i686.whl", hash = "sha256:295359a2cc78736737dd88c343cd0747546b2174b5e1adc223824bcaf3e164cb"},
{file = "websockets-8.1-cp36-cp36m-manylinux2010_x86_64.whl", hash = "sha256:1d3f1bf059d04a4e0eb4985a887d49195e15ebabc42364f4eb564b1d065793f5"},
{file = "websockets-8.1-cp36-cp36m-win32.whl", hash = "sha256:2db62a9142e88535038a6bcfea70ef9447696ea77891aebb730a333a51ed559a"},
{file = "websockets-8.1-cp36-cp36m-win_amd64.whl", hash = "sha256:0e4fb4de42701340bd2353bb2eee45314651caa6ccee80dbd5f5d5978888fed5"},
{file = "websockets-8.1-cp37-cp37m-macosx_10_6_intel.whl", hash = "sha256:9b248ba3dd8a03b1a10b19efe7d4f7fa41d158fdaa95e2cf65af5a7b95a4f989"},
{file = "websockets-8.1-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:ce85b06a10fc65e6143518b96d3dca27b081a740bae261c2fb20375801a9d56d"},
{file = "websockets-8.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:965889d9f0e2a75edd81a07592d0ced54daa5b0785f57dc429c378edbcffe779"},
{file = "websockets-8.1-cp37-cp37m-manylinux2010_i686.whl", hash = "sha256:751a556205d8245ff94aeef23546a1113b1dd4f6e4d102ded66c39b99c2ce6c8"},
{file = "websockets-8.1-cp37-cp37m-manylinux2010_x86_64.whl", hash = "sha256:3ef56fcc7b1ff90de46ccd5a687bbd13a3180132268c4254fc0fa44ecf4fc422"},
{file = "websockets-8.1-cp37-cp37m-win32.whl", hash = "sha256:7ff46d441db78241f4c6c27b3868c9ae71473fe03341340d2dfdbe8d79310acc"},
{file = "websockets-8.1-cp37-cp37m-win_amd64.whl", hash = "sha256:20891f0dddade307ffddf593c733a3fdb6b83e6f9eef85908113e628fa5a8308"},
{file = "websockets-8.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:c1ec8db4fac31850286b7cd3b9c0e1b944204668b8eb721674916d4e28744092"},
{file = "websockets-8.1-cp38-cp38-manylinux1_i686.whl", hash = "sha256:5c01fd846263a75bc8a2b9542606927cfad57e7282965d96b93c387622487485"},
{file = "websockets-8.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:9bef37ee224e104a413f0780e29adb3e514a5b698aabe0d969a6ba426b8435d1"},
{file = "websockets-8.1-cp38-cp38-manylinux2010_i686.whl", hash = "sha256:d705f8aeecdf3262379644e4b55107a3b55860eb812b673b28d0fbc347a60c55"},
{file = "websockets-8.1-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:c8a116feafdb1f84607cb3b14aa1418424ae71fee131642fc568d21423b51824"},
{file = "websockets-8.1-cp38-cp38-win32.whl", hash = "sha256:e898a0863421650f0bebac8ba40840fc02258ef4714cb7e1fd76b6a6354bda36"},
{file = "websockets-8.1-cp38-cp38-win_amd64.whl", hash = "sha256:f8a7bff6e8664afc4e6c28b983845c5bc14965030e3fb98789734d416af77c4b"},
{file = "websockets-8.1.tar.gz", hash = "sha256:5c65d2da8c6bce0fca2528f69f44b2f977e06954c8512a952222cea50dad430f"},
]
yarl = [
{file = "yarl-1.3.0-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:3e2724eb9af5dc41648e5bb304fcf4891adc33258c6e14e2a7414ea32541e320"},
{file = "yarl-1.3.0-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:3890ab952d508523ef4881457c4099056546593fa05e93da84c7250516e632eb"},
{file = "yarl-1.3.0-cp35-cp35m-win32.whl", hash = "sha256:7ab825726f2940c16d92aaec7d204cfc34ac26c0040da727cf8ba87255a33829"},
{file = "yarl-1.3.0-cp35-cp35m-win_amd64.whl", hash = "sha256:b25de84a8c20540531526dfbb0e2d2b648c13fd5dd126728c496d7c3fea33310"},
{file = "yarl-1.3.0-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:2f3010703295fbe1aec51023740871e64bb9664c789cba5a6bdf404e93f7568f"},
{file = "yarl-1.3.0-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:5badb97dd0abf26623a9982cd448ff12cb39b8e4c94032ccdedf22ce01a64842"},
{file = "yarl-1.3.0-cp36-cp36m-win32.whl", hash = "sha256:c9bb7c249c4432cd47e75af3864bc02d26c9594f49c82e2a28624417f0ae63b8"},
{file = "yarl-1.3.0-cp36-cp36m-win_amd64.whl", hash = "sha256:c6e341f5a6562af74ba55205dbd56d248daf1b5748ec48a0200ba227bb9e33f4"},
{file = "yarl-1.3.0-cp37-cp37m-win32.whl", hash = "sha256:e060906c0c585565c718d1c3841747b61c5439af2211e185f6739a9412dfbde1"},
{file = "yarl-1.3.0-cp37-cp37m-win_amd64.whl", hash = "sha256:73f447d11b530d860ca1e6b582f947688286ad16ca42256413083d13f260b7a0"},
{file = "yarl-1.3.0.tar.gz", hash = "sha256:024ecdc12bc02b321bc66b41327f930d1c2c543fa9a561b39861da9388ba7aa9"},
{file = "yarl-1.4.1-cp35-cp35m-macosx_10_13_x86_64.whl", hash = "sha256:326f2dbaaa17b858ae86f261ae73a266fd820a561fc5142cee9d0fc58448fbd7"},
{file = "yarl-1.4.1-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:7ed006a220422c33ff0889288be24db56ff0a3008ffe9eaead58a690715ad09b"},
{file = "yarl-1.4.1-cp35-cp35m-win32.whl", hash = "sha256:80c9c213803b50899460cc355f47e66778c3c868f448b7b7de5b1f1858c82c2a"},
{file = "yarl-1.4.1-cp35-cp35m-win_amd64.whl", hash = "sha256:b1c178ef813940c9a5cbad42ab7b8b76ac08b594b0a6bad91063c968e0466efc"},
{file = "yarl-1.4.1-cp36-cp36m-macosx_10_13_x86_64.whl", hash = "sha256:074958fe4578ef3a3d0bdaf96bbc25e4c4db82b7ff523594776fcf3d3f16c531"},
{file = "yarl-1.4.1-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:d6eff151c3b23a56a5e4f496805619bc3bdf4f749f63a7a95ad50e8267c17475"},
{file = "yarl-1.4.1-cp36-cp36m-win32.whl", hash = "sha256:6642cbc92eaffa586180f669adc772f5c34977e9e849e93f33dc142351e98c9c"},
{file = "yarl-1.4.1-cp36-cp36m-win_amd64.whl", hash = "sha256:63be649c535d18ab6230efbc06a07f7779cd4336a687672defe70c025349a47b"},
{file = "yarl-1.4.1-cp37-cp37m-macosx_10_13_x86_64.whl", hash = "sha256:56126ef061b913c3eefecace3404ca88917265d0550b8e32bbbeab29e5c830bf"},
{file = "yarl-1.4.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:589ac1e82add13fbdedc04eb0a83400db728e5f1af2bd273392088ca90de7062"},
{file = "yarl-1.4.1-cp37-cp37m-win32.whl", hash = "sha256:32a3885f542f74d0f4f87057050c6b45529ebd79d0639f56582e741521575bfe"},
{file = "yarl-1.4.1-cp37-cp37m-win_amd64.whl", hash = "sha256:6fa05a25f2280e78a514041d4609d39962e7d51525f2439db9ad7a2ae7aac163"},
{file = "yarl-1.4.1-cp38-cp38-macosx_10_13_x86_64.whl", hash = "sha256:ab112fba996a8f48f427e26969f2066d50080df0c24007a8cc6d7ae865e19013"},
{file = "yarl-1.4.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:2db667ee21f620b446a54a793e467714fc5a446fcc82d93a47e8bde01d69afab"},
{file = "yarl-1.4.1-cp38-cp38-win32.whl", hash = "sha256:031e8f56cf085d3b3df6b6bce756369ea7052b82d35ea07b6045f209c819e0e5"},
{file = "yarl-1.4.1-cp38-cp38-win_amd64.whl", hash = "sha256:8bae18e2129850e76969b57869dacc72a66cccdbeebce1a28d7f3d439c21a7a3"},
{file = "yarl-1.4.1.tar.gz", hash = "sha256:6076bce2ecc6ebf6c92919d77762f80f4c9c6ecc9c1fbaa16567ec59ad7d6f1d"},
]
youtube-dl = [
{file = "youtube_dl-2019.11.22-py2.py3-none-any.whl", hash = "sha256:bd785113687f201415389156664b9ebd81698fb6eb44c6d9fd35898619e27bf7"},
{file = "youtube_dl-2019.11.22.tar.gz", hash = "sha256:0575efd332cb9817f5a1fffd2a1e569e5a7d3642e7c24c7a5c47cbf70f301f25"},
{file = "youtube_dl-2019.11.28-py2.py3-none-any.whl", hash = "sha256:43d6b991a34934fec2be20b93d4774ccc8642db1e5f0b8f1569f53b8d769af48"},
{file = "youtube_dl-2019.11.28.tar.gz", hash = "sha256:de2254dc38472b0e0e3ac4d1e95a9e636ec790af83e7b055e1e09f03eb61bb5c"},
]

View file

@ -20,6 +20,8 @@
[tool.poetry.dependencies]
python = "^3.8"
riotwatcher = "^2.7.1"
[tool.poetry.dependencies.royalnet]
git = "https://github.com/Steffo99/royalnet/"
# Maybe... there is a way to make these selectable?

View file

@ -3,10 +3,10 @@ from .ciaoruozi import CiaoruoziCommand
from .color import ColorCommand
from .cv import CvCommand
from .diario import DiarioCommand
# from .rage import RageCommand
# from .reminder import ReminderCommand
# from .ship import ShipCommand
# from .smecds import SmecdsCommand
from .rage import RageCommand
from .reminder import ReminderCommand
from .ship import ShipCommand
from .smecds import SmecdsCommand
# from .videochannel import VideochannelCommand
# from .trivia import TriviaCommand
# from .matchmaking import MatchmakingCommand
@ -20,7 +20,7 @@ from .diario import DiarioCommand
# from .soundcloud import SoundcloudCommand
# from .zawarudo import ZawarudoCommand
from .emojify import EmojifyCommand
# from .leagueoflegends import LeagueoflegendsCommand
from .leagueoflegends import LeagueoflegendsCommand
from .diarioquote import DiarioquoteCommand
# from .mp3 import Mp3Command
from .peertube import PeertubeCommand
@ -31,10 +31,10 @@ available_commands = [
ColorCommand,
CvCommand,
DiarioCommand,
# RageCommand,
# ReminderCommand,
# ShipCommand,
# SmecdsCommand,
RageCommand,
ReminderCommand,
ShipCommand,
SmecdsCommand,
# VideochannelCommand,
# TriviaCommand,
# MatchmakingCommand,
@ -48,7 +48,7 @@ available_commands = [
# SoundcloudCommand,
# ZawarudoCommand,
EmojifyCommand,
# LeagueoflegendsCommand,
LeagueoflegendsCommand,
DiarioquoteCommand,
# Mp3Command,
PeertubeCommand,

View file

@ -154,9 +154,23 @@ class CvCommand(Command):
name = member['name']
activity = ""
if len(member["activities"]) >= 1:
# TODO: how to render activities now?
...
for mact in member["activities"]:
# Playing
if mact["type"] == 0:
activity += f" | 🎮 {mact['name']}"
if "state" in mact and "details" in mact:
activity += f" ({mact['state']} | {mact['details']})"
elif "state" in mact:
activity += f" ({mact['state']})"
elif "details" in mact:
activity += f" ({mact['details']})"
activity += "\n"
# Custom Status
elif mact["type"] == 4:
activity += f" | ❓ {mact['state']}"
else:
# TODO: what other activity types are there?
breakpoint()
return f"{status}{voice} {name}{activity}\n"
@ -233,7 +247,7 @@ class CvCommand(Command):
draw = True
for role in member["roles"]:
if role["id"] == self.interface.cfg["Cv"]["displayed_role_id"]:
if role["id"] == self.interface.config["Cv"]["displayed_role_id"]:
break
else:
if display_only_role:

View file

@ -65,7 +65,7 @@ class DiarioCommand(Command):
if photosizes:
# Text is a caption
text = reply.caption
media_url = await to_imgur(self.interface.cfg["Imgur"]["token"],
media_url = await to_imgur(self.interface.config["Imgur"]["token"],
photosizes, text if text is not None else "")
else:
media_url = None
@ -93,7 +93,7 @@ class DiarioCommand(Command):
# Check if there's an image associated with the reply
photosizes: Optional[List[telegram.PhotoSize]] = message.photo
if photosizes:
media_url = await to_imgur(self.interface.cfg["Imgur"]["token"],
media_url = await to_imgur(self.interface.config["Imgur"]["token"],
photosizes, raw_text if raw_text is not None else "")
else:
media_url = None

View file

@ -5,6 +5,7 @@ import asyncio
import sentry_sdk
from royalnet.commands import *
from royalnet.utils import *
from royalnet.serf.telegram import *
from ..tables import LeagueOfLegends
from ..utils import LeagueLeague
@ -20,25 +21,19 @@ class LeagueoflegendsCommand(Command):
syntax = "[nomeevocatore]"
tables = {LeagueOfLegends}
_region = "euw1"
_telegram_group_id = -1001153723135
def __init__(self, interface: CommandInterface):
super().__init__(interface)
self._riotwatcher = riotwatcher.RiotWatcher(api_key=self.interface.bot.get_secret("leagueoflegends"))
self._riotwatcher = riotwatcher.RiotWatcher(api_key=self.config["Lol"]["token"])
if self.interface.name == "telegram":
self.loop.create_task(self._updater(900))
async def _send(self, message):
client = self.interface.bot.client
await self.interface.bot.safe_api_call(client.send_message,
chat_id=self._telegram_group_id,
text=telegram_escape(message),
parse_mode="HTML",
disable_webpage_preview=True)
client = self.serf.client
await self.serf.api_call(client.send_message,
chat_id=self.config["Telegram"]["main_group_id"],
text=escape(message),
parse_mode="HTML",
disable_webpage_preview=True)
async def _notify(self,
obj: LeagueOfLegends,
@ -86,7 +81,7 @@ class LeagueoflegendsCommand(Command):
async def _update(self, lol: LeagueOfLegends):
log.info(f"Updating: {lol}")
log.debug(f"Getting summoner data: {lol}")
summoner = await asyncify(self._riotwatcher.summoner.by_id, region=self._region,
summoner = await asyncify(self._riotwatcher.summoner.by_id, region=self.config["Lol"]["region"],
encrypted_summoner_id=lol.summoner_id)
await self._change(lol, "profile_icon_id", summoner["profileIconId"], self._notify)
await self._change(lol, "summoner_name", summoner["name"], self._notify)
@ -95,7 +90,7 @@ class LeagueoflegendsCommand(Command):
await self._change(lol, "summoner_id", summoner["id"], self._notify)
await self._change(lol, "account_id", summoner["accountId"], self._notify)
log.debug(f"Getting leagues data: {lol}")
leagues = await asyncify(self._riotwatcher.league.by_summoner, region=self._region,
leagues = await asyncify(self._riotwatcher.league.by_summoner, region=self.config["Lol"]["region"],
encrypted_summoner_id=lol.summoner_id)
soloq = LeagueLeague()
flexq = LeagueLeague()
@ -115,7 +110,8 @@ class LeagueoflegendsCommand(Command):
await self._change(lol, "rank_twtrq", twtrq, self._notify)
await self._change(lol, "rank_tftq", tftq, self._notify)
log.debug(f"Getting mastery data: {lol}")
mastery = await asyncify(self._riotwatcher.champion_mastery.scores_by_summoner, region=self._region,
mastery = await asyncify(self._riotwatcher.champion_mastery.scores_by_summoner,
region=self.config["Lol"]["region"],
encrypted_summoner_id=lol.summoner_id)
await self._change(lol, "mastery_score", mastery, self._notify)
@ -138,7 +134,8 @@ class LeagueoflegendsCommand(Command):
log.info(f"Sleeping for {period}s")
await asyncio.sleep(period)
def _display(self, lol: LeagueOfLegends):
@staticmethod
def _display(lol: LeagueOfLegends) -> str:
string = f" [b]{lol.summoner_name}[/b]\n" \
f"Lv. {lol.summoner_level}\n" \
f"Mastery score: {lol.mastery_score}\n" \
@ -161,7 +158,7 @@ class LeagueoflegendsCommand(Command):
if name:
# Connect a new League of Legends account to Royalnet
log.debug(f"Searching for: {name}")
summoner = self._riotwatcher.summoner.by_name(region=self._region, summoner_name=name)
summoner = self._riotwatcher.summoner.by_name(region=self.config["Lol"]["region"], summoner_name=name)
# Ensure the account isn't already connected to something else
leagueoflegends = await asyncify(
data.session.query(self.alchemy.LeagueOfLegends).filter_by(summoner_id=summoner["id"]).one_or_none)
@ -169,7 +166,8 @@ class LeagueoflegendsCommand(Command):
raise CommandError(f"L'account {leagueoflegends} è già registrato su Royalnet.")
# Get rank information
log.debug(f"Getting leagues data: {name}")
leagues = self._riotwatcher.league.by_summoner(region=self._region, encrypted_summoner_id=summoner["id"])
leagues = self._riotwatcher.league.by_summoner(region=self.config["Lol"]["region"],
encrypted_summoner_id=summoner["id"])
soloq = LeagueLeague()
flexq = LeagueLeague()
twtrq = LeagueLeague()
@ -185,11 +183,11 @@ class LeagueoflegendsCommand(Command):
tftq = LeagueLeague.from_dict(league)
# Get mastery score
log.debug(f"Getting mastery data: {name}")
mastery = self._riotwatcher.champion_mastery.scores_by_summoner(region=self._region,
mastery = self._riotwatcher.champion_mastery.scores_by_summoner(region=self.config["Lol"]["region"],
encrypted_summoner_id=summoner["id"])
# Create database row
leagueoflegends = self.alchemy.LeagueOfLegends(
region=self._region,
region=self.config["Lol"]["region"],
user=author,
profile_icon_id=summoner["profileIconId"],
summoner_name=summoner["name"],
@ -210,7 +208,7 @@ class LeagueoflegendsCommand(Command):
else:
# Update and display the League of Legends stats for the current account
if len(author.leagueoflegends) == 0:
raise CommandError("Nessun account di League of Legends trovato.")
raise UserError("Nessun account di League of Legends trovato.")
message = ""
for account in author.leagueoflegends:
try:

View file

@ -10,11 +10,11 @@ class RageCommand(Command):
description: str = "Arrabbiati per qualcosa, come una software house californiana."
MAD = ["MADDEN MADDEN MADDEN MADDEN",
_MAD = ["MADDEN MADDEN MADDEN MADDEN",
"EA bad, praise Geraldo!",
"Stai sfogando la tua ira sul bot!",
"Basta, io cambio gilda!",
"Fondiamo la RRYG!"]
async def run(self, args: CommandArgs, data: CommandData) -> None:
await data.reply(f"😠 {random.sample(self.MAD, 1)[0]}")
await data.reply(f"😠 {random.sample(self._MAD, 1)[0]}")

View file

@ -6,7 +6,9 @@ import telegram
import discord
from sqlalchemy import and_
from royalnet.commands import *
from royalnet.utils import sleep_until, asyncify, telegram_escape, discord_escape
from royalnet.utils import *
from royalnet.serf.telegram import escape as telegram_escape
from royalnet.serf.discord import escape as discord_escape
from ..tables import Reminder
@ -19,16 +21,14 @@ class ReminderCommand(Command):
syntax: str = "[ {data} ] {messaggio}"
tables = {Reminder}
def __init__(self, interface: CommandInterface):
super().__init__(interface)
session = interface.alchemy.Session()
reminders = (
session.query(interface.alchemy.Reminder)
session.query(interface.alchemy.get(Reminder))
.filter(and_(
interface.alchemy.Reminder.datetime >= datetime.datetime.now(),
interface.alchemy.Reminder.interface_name == interface.name))
interface.alchemy.get(Reminder).datetime >= datetime.datetime.now(),
interface.alchemy.get(Reminder).interface_name == interface.name))
.all()
)
for reminder in reminders:
@ -38,16 +38,16 @@ class ReminderCommand(Command):
await sleep_until(reminder.datetime)
if self.interface.name == "telegram":
chat_id: int = pickle.loads(reminder.raw_interface_data)
bot: telegram.Bot = self.interface.bot.client
await asyncify(bot.send_message,
chat_id=chat_id,
text=telegram_escape(f"❗️ {reminder.message}"),
parse_mode="HTML",
disable_web_page_preview=True)
client: telegram.Bot = self.serf.client
await self.serf.api_call(client.send_message,
chat_id=chat_id,
text=telegram_escape(f"❗️ {reminder.message}"),
parse_mode="HTML",
disable_web_page_preview=True)
elif self.interface.name == "discord":
channel_id: int = pickle.loads(reminder.raw_interface_data)
bot: discord.Client = self.interface.bot.client
channel = bot.get_channel(channel_id)
client: discord.Client = self.serf.client
channel = client.get_channel(channel_id)
await channel.send(discord_escape(f"❗️ {reminder.message}"))
async def run(self, args: CommandArgs, data: CommandData) -> None:

View file

@ -1,7 +1,5 @@
import typing
import re
from royalnet.commands import *
from royalnet.utils import safeformat
class ShipCommand(Command):
@ -34,7 +32,4 @@ class ShipCommand(Command):
part_two = match_two.group(0)
# Combine the two name parts
mixed = part_one + part_two
await data.reply(safeformat("💕 {one} + {two} = [b]{result}[/b]",
one=name_one.capitalize(),
two=name_two.capitalize(),
result=mixed.capitalize()))
await data.reply(f"💕 {part_one.capitalize()} + {part_two.capitalize()} = [b]{mixed.capitalize()}[/b]")

View file

@ -11,60 +11,59 @@ class SmecdsCommand(Command):
description: str = "Secondo me, è colpa dello stagista..."
syntax = ""
_DS_LIST = ["della secca", "del seccatore", "del secchiello", "del secchio", "del secchione", "del secondino",
"del sedano", "del sedativo", "della sedia", "del sedicente", "del sedile", "della sega", "del segale",
"della segatura", "della seggiola", "del seggiolino", "della seggiovia", "della segheria",
"del seghetto", "del segnalibro", "del segnaposto", "del segno", "del segretario", "della segreteria",
"del seguace", "del segugio", "della selce", "della sella", "della selz", "della selva",
"della selvaggina", "del semaforo", "del seme", "del semifreddo", "del seminario", "della seminarista",
"della semola", "del semolino", "del semplicione", "della senape", "del senatore", "del seno",
"del sensore", "della sentenza", "della sentinella", "del sentore", "della seppia", "del sequestratore",
"della serenata", "del sergente", "del sermone", "della serpe", "del serpente", "della serpentina",
"della serra", "del serraglio", "del serramanico", "della serranda", "della serratura", "del servitore",
"della servitù", "del servizievole", "del servo", "del set", "della seta", "della setola", "del sigaro",
"del sidecar", "del siderurgico", "del sidro", "della siepe", "del sifone", "della sigaretta",
"del sigillo", "della signora", "della signorina", "del silenziatore", "della silhouette",
"del silicio",
"del silicone", "del siluro", "della sinagoga", "della sindacalista", "del sindacato", "del sindaco",
"della sindrome", "della sinfonia", "del sipario", "del sire", "della sirena", "della siringa",
"del sismografo", "del sobborgo", "del sobillatore", "del sobrio", "del soccorritore", "del socio",
"del sociologo", "della soda", "del sofà", "della soffitta", "del software", "dello sogghignare",
"del soggiorno", "della sogliola", "del sognatore", "della soia", "del solaio", "del solco",
"del soldato", "del soldo", "del sole", "della soletta", "della solista", "del solitario",
"del sollazzare", "del sollazzo", "del sollecito", "del solleone", "del solletico", "del sollevare",
"del sollievo", "del solstizio", "del solubile", "del solvente", "della soluzione", "del somaro",
"del sombrero", "del sommergibile", "del sommo", "della sommossa", "del sommozzatore", "del sonar",
"della sonda", "del sondaggio", "del sondare", "del sonnacchioso", "del sonnambulo", "del sonnellino",
"del sonnifero", "del sonno", "della sonnolenza", "del sontuoso", "del soppalco", "del soprabito",
"del sopracciglio", "del sopraffare", "del sopraffino", "del sopraluogo", "del sopramobile",
"del soprannome", "del soprano", "del soprappensiero", "del soprassalto", "del soprassedere",
"del sopravvento", "del sopravvivere", "del soqquadro", "del sorbetto", "del sordido", "della sordina",
"del sordo", "della sorella", "della sorgente", "del sornione", "del sorpasso", "della sorpresa",
"del sorreggere", "del sorridere", "della sorsata", "del sorteggio", "del sortilegio",
"del sorvegliante", "del sorvolare", "del sosia", "del sospettoso", "del sospirare", "della sosta",
"della sostanza", "del sostegno", "del sostenitore", "del sostituto", "del sottaceto", "della sottana",
"del sotterfugio", "del sotterraneo", "del sottile", "del sottilizzare", "del sottintendere",
"del sottobanco", "del sottobosco", "del sottomarino", "del sottopassaggio", "del sottoposto",
"del sottoscala", "della sottoscrizione", "del sottostare", "del sottosuolo", "del sottotetto",
"del sottotitolo", "del sottovalutare", "del sottovaso", "della sottoveste", "del sottovuoto",
"del sottufficiale", "della soubrette", "del souvenir", "del soverchiare", "del sovrano",
"del sovrapprezzo", "della sovvenzione", "del sovversivo", "del sozzo", "dello suadente", "del sub",
"del subalterno", "del subbuglio", "del subdolo", "del sublime", "del suburbano", "del successore",
"del succo", "della succube", "del succulento", "della succursale", "del sudario", "della sudditanza",
"del suddito", "del sudicio", "del suffisso", "del suffragio", "del suffumigio", "del suggeritore",
"del sughero", "del sugo", "del suino", "della suite", "del sulfureo", "del sultano", "di Steffo",
"di Spaggia", "di Sabrina", "del sas", "del ses", "del sis", "del sos", "del sus", "della supremazia",
"del Santissimo", "della scatola", "del supercalifragilistichespiralidoso", "del sale", "del salame",
"di (Town of) Salem", "di Stronghold", "di SOMA", "dei Saints", "di S.T.A.L.K.E.R.", "di Sanctum",
"dei Sims", "di Sid", "delle Skullgirls", "di Sonic", "di Spiral (Knights)", "di Spore", "di Starbound",
"di SimCity", "di Sensei", "di Ssssssssssssss... Boom! E' esploso il dizionario", "della scala",
"di Sakura", "di Suzie", "di Shinji", "del senpai", "del support", "di Superman", "di Sekiro",
"dello Slime God", "del salassato", "della salsa", "di Senjougahara", "di Sugar", "della Stampa",
"della Stampante"]
DS_LIST = ["della secca", "del seccatore", "del secchiello", "del secchio", "del secchione", "del secondino",
"del sedano", "del sedativo", "della sedia", "del sedicente", "del sedile", "della sega", "del segale",
"della segatura", "della seggiola", "del seggiolino", "della seggiovia", "della segheria",
"del seghetto", "del segnalibro", "del segnaposto", "del segno", "del segretario", "della segreteria",
"del seguace", "del segugio", "della selce", "della sella", "della selz", "della selva",
"della selvaggina", "del semaforo", "del seme", "del semifreddo", "del seminario", "della seminarista",
"della semola", "del semolino", "del semplicione", "della senape", "del senatore", "del seno",
"del sensore", "della sentenza", "della sentinella", "del sentore", "della seppia", "del sequestratore",
"della serenata", "del sergente", "del sermone", "della serpe", "del serpente", "della serpentina",
"della serra", "del serraglio", "del serramanico", "della serranda", "della serratura", "del servitore",
"della servitù", "del servizievole", "del servo", "del set", "della seta", "della setola", "del sigaro",
"del sidecar", "del siderurgico", "del sidro", "della siepe", "del sifone", "della sigaretta",
"del sigillo", "della signora", "della signorina", "del silenziatore", "della silhouette", "del silicio",
"del silicone", "del siluro", "della sinagoga", "della sindacalista", "del sindacato", "del sindaco",
"della sindrome", "della sinfonia", "del sipario", "del sire", "della sirena", "della siringa",
"del sismografo", "del sobborgo", "del sobillatore", "del sobrio", "del soccorritore", "del socio",
"del sociologo", "della soda", "del sofà", "della soffitta", "del software", "dello sogghignare",
"del soggiorno", "della sogliola", "del sognatore", "della soia", "del solaio", "del solco",
"del soldato", "del soldo", "del sole", "della soletta", "della solista", "del solitario",
"del sollazzare", "del sollazzo", "del sollecito", "del solleone", "del solletico", "del sollevare",
"del sollievo", "del solstizio", "del solubile", "del solvente", "della soluzione", "del somaro",
"del sombrero", "del sommergibile", "del sommo", "della sommossa", "del sommozzatore", "del sonar",
"della sonda", "del sondaggio", "del sondare", "del sonnacchioso", "del sonnambulo", "del sonnellino",
"del sonnifero", "del sonno", "della sonnolenza", "del sontuoso", "del soppalco", "del soprabito",
"del sopracciglio", "del sopraffare", "del sopraffino", "del sopraluogo", "del sopramobile",
"del soprannome", "del soprano", "del soprappensiero", "del soprassalto", "del soprassedere",
"del sopravvento", "del sopravvivere", "del soqquadro", "del sorbetto", "del sordido", "della sordina",
"del sordo", "della sorella", "della sorgente", "del sornione", "del sorpasso", "della sorpresa",
"del sorreggere", "del sorridere", "della sorsata", "del sorteggio", "del sortilegio",
"del sorvegliante", "del sorvolare", "del sosia", "del sospettoso", "del sospirare", "della sosta",
"della sostanza", "del sostegno", "del sostenitore", "del sostituto", "del sottaceto", "della sottana",
"del sotterfugio", "del sotterraneo", "del sottile", "del sottilizzare", "del sottintendere",
"del sottobanco", "del sottobosco", "del sottomarino", "del sottopassaggio", "del sottoposto",
"del sottoscala", "della sottoscrizione", "del sottostare", "del sottosuolo", "del sottotetto",
"del sottotitolo", "del sottovalutare", "del sottovaso", "della sottoveste", "del sottovuoto",
"del sottufficiale", "della soubrette", "del souvenir", "del soverchiare", "del sovrano",
"del sovrapprezzo", "della sovvenzione", "del sovversivo", "del sozzo", "dello suadente", "del sub",
"del subalterno", "del subbuglio", "del subdolo", "del sublime", "del suburbano", "del successore",
"del succo", "della succube", "del succulento", "della succursale", "del sudario", "della sudditanza",
"del suddito", "del sudicio", "del suffisso", "del suffragio", "del suffumigio", "del suggeritore",
"del sughero", "del sugo", "del suino", "della suite", "del sulfureo", "del sultano", "di Steffo",
"di Spaggia", "di Sabrina", "del sas", "del ses", "del sis", "del sos", "del sus", "della supremazia",
"del Santissimo", "della scatola", "del supercalifragilistichespiralidoso", "del sale", "del salame",
"di (Town of) Salem", "di Stronghold", "di SOMA", "dei Saints", "di S.T.A.L.K.E.R.", "di Sanctum",
"dei Sims", "di Sid", "delle Skullgirls", "di Sonic", "di Spiral (Knights)", "di Spore", "di Starbound",
"di SimCity", "di Sensei", "di Ssssssssssssss... Boom! E' esploso il dizionario", "della scala",
"di Sakura", "di Suzie", "di Shinji", "del senpai", "del support", "di Superman", "di Sekiro",
"dello Slime God", "del salassato", "della salsa", "di Senjougahara", "di Sugar", "della Stampa",
"della Stampante"]
SMECDS = "🤔 Secondo me, è colpa {ds}."
_SMECDS = "🤔 Secondo me, è colpa {ds}."
async def run(self, args: CommandArgs, data: CommandData) -> None:
ds = random.sample(self.DS_LIST, 1)[0]
await data.reply(safeformat(self.SMECDS, ds=ds))
ds = random.sample(self._DS_LIST, 1)[0]
await data.reply(safeformat(self._SMECDS, ds=ds))

View file

@ -70,7 +70,7 @@ class DiscordCvEvent(Event):
"mobile": member.mobile_status.value,
"web": member.web_status.value,
},
"activities": [],
"activities": [activity.to_dict() for activity in member.activities if activity is not None],
"roles": [{
"id": role.id,
"name": role.name,
@ -81,9 +81,6 @@ class DiscordCvEvent(Event):
} for role in member.roles]
}
for activity in member.activities:
...
results.append(data)
return {

View file

@ -70,6 +70,10 @@ class LeagueLeague:
return True
if not isinstance(other, LeagueLeague):
raise TypeError(f"Can't compare {self.__class__.__qualname__} with {other.__class__.__qualname__}")
if self.empty:
return False
elif other.empty:
return True
if not (bool(self) and bool(other)):
raise ValueError("Can't compare partial LeagueLeagues.")
if self.tier != other.tier:
@ -100,6 +104,20 @@ class LeagueLeague:
result &= self.tier is not None
return result
@property
def empty(self):
result = True
result &= self.veteran is None
result &= self.fresh_blood is None
result &= self.hot_streak is None
result &= self.inactive is None
result &= self.losses is None
result &= self.wins is None
result &= self.points is None
result &= self.rank is None
result &= self.tier is None
return result
def __composite_values__(self):
return self.tier, \
self.rank, \