jerrita преди 9 месеца
родител
ревизия
e82ac29cf0
променени са 2 файла, в които са добавени 23 реда и са изтрити 3 реда
  1. 3 2
      main.py
  2. 20 1
      plugins/anon/base.py

+ 3 - 2
main.py

@@ -2,12 +2,13 @@ from anon import Bot
 from anon.logger import logger
 import logging
 
-logger.setLevel(logging.DEBUG)
+logger.setLevel(logging.INFO)
 
 if __name__ == '__main__':
     anon = Bot('192.168.5.145:5800', '114514')
     anon.register_plugins([
         'plugins.anon.base',
-        'plugins.anon.muri'
+        'plugins.anon.muri',
+        'plugins.anon.turing'
     ])
     anon.loop()

+ 20 - 1
plugins/anon/base.py

@@ -2,9 +2,12 @@ import asyncio
 import datetime
 
 from anon import Bot
-from anon.event.event import Event
 from anon.plugin import PluginManager, Plugin
 from anon.event import MessageEvent
+from anon.event.message import GroupMessage
+
+# (group, times)
+repeater = {}
 
 
 class AnonPlugin(Plugin):
@@ -15,5 +18,21 @@ class AnonPlugin(Plugin):
         if event.raw == 'anon':
             await event.reply('は?')
 
+        # repeater
+        if isinstance(event, GroupMessage):
+            group_id = event.gid
+            if group_id not in repeater:
+                repeater[group_id] = [event.raw, 1]
+            else:
+                if repeater[group_id][0] == event.raw:
+                    repeater[group_id][1] += 1
+                    if repeater[group_id][1] == 3:
+                        await event.reply(event.raw, quote=False)
+                else:
+                    repeater[group_id] = [event.raw, 1]
+
+    async def on_shutdown(self):
+        await Bot().send_private_message(782981223, f'Anon shutdown at: {datetime.datetime.now()}')
+
 
 PluginManager().register_plugin(AnonPlugin([MessageEvent]))