aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tests/plugins/Webhook/__init__.py
diff options
context:
space:
mode:
author简律纯 <i@jyunko.cn>2023-08-09 14:36:37 +0800
committer简律纯 <i@jyunko.cn>2023-08-09 14:36:37 +0800
commit85ec2f7dc55a672b07272a50f11eb86460f38671 (patch)
tree8517989c8cc6444df8ae7ae50802a3b81766b01f /tests/plugins/Webhook/__init__.py
parent642a278b1e2cc11fee587b933413a30c057753c1 (diff)
downloadHydroRoll-85ec2f7dc55a672b07272a50f11eb86460f38671.tar.gz
HydroRoll-85ec2f7dc55a672b07272a50f11eb86460f38671.zip
feat:all
Diffstat (limited to 'tests/plugins/Webhook/__init__.py')
-rw-r--r--tests/plugins/Webhook/__init__.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/plugins/Webhook/__init__.py b/tests/plugins/Webhook/__init__.py
new file mode 100644
index 0000000..23f4c3a
--- /dev/null
+++ b/tests/plugins/Webhook/__init__.py
@@ -0,0 +1,32 @@
+from iamai import Plugin
+from iamai.log import logger as log
+import asyncio
+import aiohttp
+
+payload = None
+
+class Webhook(Plugin):
+ async def handle(self) -> None:
+ global payload
+ if payload:
+ log.info(payload[:5])
+ await self.bot.get_adapter("cqhttp").call_api(
+ "send_group_msg",
+ group_id=126211793,
+ message=payload
+ )
+
+ async def rule(self) -> bool:
+ global payload
+ async with aiohttp.ClientSession() as session:
+ try:
+ async with session.get('http://localhost:3000') as response:
+ try:
+ payload = await response.text()
+ log.info(payload)
+ return True
+ except Exception as e:
+ log.info(f'Failed to fetch payload: {e}')
+ return False
+ except Exception as e:
+ return False \ No newline at end of file