Skip to content

Commit

Permalink
chore: 我想睡觉,但我失眠了。
Browse files Browse the repository at this point in the history
  • Loading branch information
HsiangNianian committed Nov 17, 2023
1 parent de6afb8 commit b7f99a0
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions example/plugins/HydroRoll/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,27 @@ async def handle(self) -> None:
flag = True in [cmd.startswith(current_cmd) for cmd in command_list]
logger.info(f"Command {current_cmd} not found with flag {flag}")
if args[0] in [".root", ".roots"]:
import requests

data = requests.get("https://vercel-hitokoto.vercel.app/api/roots").json()
await self.event.reply(data["line"])
else:
if args[0] == ".core":
await self.event.reply(f"{self.state}")
try:
import aiohttp

async with aiohttp.ClientSession() as session:
async with session.get("https://api.hydroroll.team/api/roots") as response:
data = await response.json()
await self.event.reply(data["line"])
except Exception as e:
await self.event.reply(f"{e!r}")
elif args[0] == ".core":
await self.event.reply(f"{self.state}")
# if args[0].startswith(".set"):
# resolve = Set(args[1:]) # TODO: handle multiple sets
# elif args[0].startswith(".get"):
# resolve = Get(args[1:]) # TODO: handle multiple gets
elif args[0].startswith(".test"):
try:
result = eval(self.event.message.get_plain_text()[5:])
await self.event.reply(str(result))
except Exception as error:
await self.event.reply(f"{error!r}")
elif args[0].startswith(".test"):
try:
result = eval(self.event.message.get_plain_text()[5:])
await self.event.reply(str(result))
except Exception as error:
await self.event.reply(f"{error!r}")

async def rule(self) -> bool:
"""
Expand Down Expand Up @@ -128,4 +132,5 @@ def _load_models(self, model_path_list: list, model_dict: dict) -> dict:
return models

def load_models(self):
"""我想睡觉, 但我失眠了。"""
self.models = self._load_models(self.model_path_list, self.model_dict)

0 comments on commit b7f99a0

Please sign in to comment.