fix for package
parent
1d6f176902
commit
c2aceb9a19
|
@ -1,2 +1,4 @@
|
|||
*/__pycache__/
|
||||
/config.toml
|
||||
**/__pycache__/
|
||||
/result
|
|
@ -15,10 +15,13 @@ dependencies = [
|
|||
"linkify_it_py"
|
||||
]
|
||||
|
||||
[project.entry-points.console_scripts]
|
||||
yobot = "yobot.cli:main"
|
||||
|
||||
[tool.setuptools.packages.find]
|
||||
include = [
|
||||
"yobot",
|
||||
"yobot.plugins",
|
||||
]
|
||||
|
||||
[tool.ruff]
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import yobot.repl
|
||||
import yobot.bot
|
||||
|
||||
import asyncio
|
||||
|
||||
def main() -> None:
|
||||
if len(sys.argv) < 2:
|
||||
print("usage: $0 repl|bot")
|
||||
sys.exit(1)
|
||||
match sys.argv[1]:
|
||||
case "repl":
|
||||
asyncio.run(yobot.repl.main())
|
||||
case "bot":
|
||||
asyncio.run(yobot.bot.main())
|
||||
case _:
|
||||
print("usage: $0 repl|bot")
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
import httpx
|
||||
|
||||
|
||||
from asyncio import timeout
|
||||
|
||||
from yobot.interface import ILine, IServer, IPlugin
|
||||
|
||||
async def req(token: str, project: int, station: int):
|
||||
async with httpx.AsyncClient() as client:
|
||||
headers = {
|
||||
"Accept": "application/json",
|
||||
"Authorization": f"Bearer {token}",
|
||||
}
|
||||
r = await client.get(f"https://api-v2.acrcloud.com/api/bm-bd-projects/{project}/channels/{station}/realtime_results", headers=headers)
|
||||
j = r.json()
|
||||
if "music" not in j["data"]["metadata"]:
|
||||
return r"snob2000 now playing: ¯\_(ツ)_/¯"
|
||||
m = j["data"]["metadata"]["music"][0]
|
||||
title = m["title"]
|
||||
artist = " & ".join([a["name"] for a in m["artists"]])
|
||||
return f"snob2000 np: {artist} - {title}"
|
||||
|
||||
class Plugin(IPlugin):
|
||||
def __init__(self, config: dict) -> None:
|
||||
super().__init__(config)
|
||||
|
||||
|
||||
async def handle(self, bot: IServer, line: ILine) -> None:
|
||||
msg = line.params[1]
|
||||
if msg == "!s2k":
|
||||
async with timeout(10):
|
||||
np = await req(**self.config)
|
||||
await bot.reply(line, np)
|
||||
|
|
@ -124,7 +124,7 @@ class Plugin(IPlugin):
|
|||
|
||||
async def twitter(self, url: str) -> str:
|
||||
url = re.sub(
|
||||
r"^https?://twitter\.com/", self.config["nitter_domain"] + "/", url
|
||||
r"^https?://twitter\.com/", self.config["nitter_domain"] + "/", url,
|
||||
)
|
||||
res = await self.generic(url)
|
||||
return re.sub(r"\| nitter$", "| twitter", res)
|
||||
|
|
|
@ -27,8 +27,8 @@ class Srv(IServer):
|
|||
s = await ainput("<user> ")
|
||||
await self.line_read(
|
||||
ILine(
|
||||
source="user", tags={}, command="PRIVMSG", params=["#test", s]
|
||||
)
|
||||
source="user", tags={}, command="PRIVMSG", params=["#test", s],
|
||||
),
|
||||
)
|
||||
except EOFError:
|
||||
pass
|
||||
|
|
Loading…
Reference in New Issue