aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/example
diff options
context:
space:
mode:
Diffstat (limited to 'example')
-rw-r--r--example/plugins/r.py23
-rw-r--r--example/plugins/show.py2
2 files changed, 24 insertions, 1 deletions
diff --git a/example/plugins/r.py b/example/plugins/r.py
new file mode 100644
index 0000000..b2248a4
--- /dev/null
+++ b/example/plugins/r.py
@@ -0,0 +1,23 @@
+from iamai import Plugin
+from numpy.random import Generator
+from iamai.adapter.onebot11.message import CQHTTPMessage, CQHTTPMessageSegment
+from iamai.log import logger
+
+ms = CQHTTPMessageSegment
+
+
+class R(Plugin):
+ priority = 1
+
+ async def handle(self) -> None:
+ try:
+ await self.event.reply("test")
+ except Exception as e:
+ # await self.event.reply(f"ERROR!{e!r}")
+ logger.info("ERROR with message: {}".format(e))
+
+ async def rule(self) -> bool:
+ return (
+ self.event.type == "message"
+ and self.event.message.get_plain_text().startswith(".show")
+ )
diff --git a/example/plugins/show.py b/example/plugins/show.py
index a9cf446..21c6722 100644
--- a/example/plugins/show.py
+++ b/example/plugins/show.py
@@ -34,7 +34,7 @@ class Exec(Plugin):
res = await self.event.adapter.send_group_forward_msg(group_id=int(self.event.group_id), messages=content)
except Exception as e:
# await self.event.reply(f"ERROR!{e!r}")
- await self.event.reply(f"{eval(self.event.message.get_plain_text()[6:])}")
+ await self.bot.get_adapter('onebot11').send_guild_channel_msg(f"{eval(self.event.message.get_plain_text()[6:])}")
async def rule(self) -> bool:
return (