summaryrefslogtreecommitdiff
path: root/ATRI/plugins/GetChatMSG.py
diff options
context:
space:
mode:
Diffstat (limited to 'ATRI/plugins/GetChatMSG.py')
-rw-r--r--ATRI/plugins/GetChatMSG.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/ATRI/plugins/GetChatMSG.py b/ATRI/plugins/GetChatMSG.py
new file mode 100644
index 0000000..05d47b8
--- /dev/null
+++ b/ATRI/plugins/GetChatMSG.py
@@ -0,0 +1,30 @@
+import os
+import json
+import nonebot
+from pathlib import Path
+
+
+bot = nonebot.get_bot()
+
+
[email protected]_message('group')
+async def _(ctx):
+ group = ctx['group_id']
+ user = ctx['user_id']
+ msgID = ctx['message_id']
+ RAWmsg = ctx['message']
+
+ try:
+ with open(Path('.') / 'ATRI' / 'data' / 'groupData' / f'{group}' / 'msgData.json', 'r') as f:
+ data = json.load(f)
+ except:
+ data = {}
+
+ data[f'{msgID}'] = {"msg": f"{RAWmsg}", "user_id": f"{user}"}
+
+ try:
+ with open(Path('.') / 'ATRI' / 'data' / 'groupData' / f'{group}' / 'msgData.json', 'w') as f:
+ f.write(json.dumps(data))
+ f.close()
+ except:
+ os.mkdir(Path('.') / 'ATRI' / 'data' / 'groupData' / f'{group}') \ No newline at end of file