jerrita 7 ay önce
ebeveyn
işleme
4508dfe339
1 değiştirilmiş dosya ile 99 ekleme ve 26 silme
  1. 99 26
      plugins/anon/muri.py

+ 99 - 26
plugins/anon/muri.py

@@ -1,42 +1,115 @@
-from anon.plugin import PluginManager
-from anon.event.message import GroupMessage
+from anon.plugin import PluginManager, Plugin
+from anon.event.message import GroupMessage, MessageEvent
+from anon.storage import Storage
+from anon.logger import logger
 
 import random
 import datetime
 
-db = {
+DB = {
     '随机当归': '你的当归在摆烂/你的当归在摸鱼/你的当归在认真画画/你随到了在第五人格被追的吱哇乱叫的当归/你的当归压好一刀斩了/你的当归觉得你好闲,所以告诉你该写作业了/你随到了凹深渊的当归/你的当归说你出门时会下雨/你的当归新建了一个画布/你的当归新建了一个图层/你的当归一边看直播一边听歌一边新建图层/你打死这个当归她今天都不会再动一笔了!/你随到了女装当归/你的当归正在直播/你的当归口嗨说自己画完啦/你的当归在须弥迷路啦!/当归和弁天婚礼进行时…/当归正在煮牡蛎,不给你吃/当归提醒喝水小助手,多喝热水/当归被45℃的太阳烤干惹/当归啪给你一拳',
     '我想吃牡蛎': '你吃了一个蒜蓉粉丝蒸牡蛎/你吃了一个蒜香牡蛎/你吃了一个原味生蚝/你来了一碗牡蛎豆腐汤/你吃了一个捞汁儿小牡蛎/你吃了一个椒盐海牡蛎/你的牡蛎卧沙啦!/你吃了一个清蒸生蚝/你来了一碗牡蛎口蘑汤/你把牡蛎放进了麻辣烫加麻加辣/你的牡蛎哭了,哭的好大声/你的牡蛎被暴雨冲走了/你的牡蛎被当归吃了,你没得吃',
     '欺负一下牡蛎': '牡蛎被禁言1分钟/牡蛎被禁言3分钟/牡蛎被禁言5分钟/牡蛎被禁言10分钟/牡蛎被禁言30分钟/牡蛎被禁言1小时/牡蛎被禁言8小时/牡蛎被禁言10小时/牡蛎被禁言29天23小时59分/牡蛎的管理又不见啦!/牡蛎排队食堂两天没饭吃了,呜呜/牡蛎出门没带伞突然下暴雨/牡蛎抽卡大保底/牡蛎睡醒才想起昨晚作业ddl忘了交/牡蛎被六点喊起来做核酸',
     '中午吃啥': '你的外卖送丢了/你的外卖被人偷走啦!/清汤麻辣烫/番茄麻辣烫/麻辣烫加麻加辣/麻辣烫不麻不辣/麻辣烫,但是莴笋+1+1+1+1+1/牛肉麻辣香锅/鸡肉麻辣香锅/火锅冒菜/乡村基儿童套餐/肯德基疯狂星期四/麦当劳/汉堡王/干锅鱼豆腐/干锅千页豆腐/什锦炒饭/扬州炒饭/蛋包饭/咖喱鸡肉饭/照烧鸡肉饭/茭白肉丝盖饭/罐罐米线/土豆肉丝盖饭/青椒炒蛋盖饭/白粥/莎 县 小 吃/出门撸串吧/串串火锅!/过桥米线/渔粉/饵丝/别吃饭了吃当归吧/火锅!鸳鸯锅/火锅!番茄锅/火锅!九宫格/榴莲芝士披萨/焗饭/意大利面/酸辣粉/冰粉/凉糕/香菜新地/石锅拌饭/重庆鸡公煲/重庆小面/豌杂小面/牛肉小面/肥肠小面/牡蛎炖大鹅/螺蛳粉/抄手面/鲜虾净云吞/小笼包/华莱士/正新鸡排/手抓饼豪华版/手抓饼加鸡蛋/肉夹馍/老麻抄手/烤冷面/炸鸡可乐/炒冰淇淋/水果拼盘/蔬菜沙拉/铁板鱿鱼/冷面/凉面/凉皮/口水鸡/大盘鸡拌面/地三鲜/红烧茄子/宫保鸡丁/鱼香肉丝',
 }
 
-gTarget = 591764560
+USAGE = """Usage: muri group/db <params>
+Group operators:
+muri group list
+muri group add <group_num>
+muri group del <group_num>
 
-first_greet = True
-greet_date = 0
+DB operators:
+muri db list
+muri db list <name>
+muri db set <name> <content>
+"""
 
-@PluginManager().register_event([GroupMessage])
-async def muri(event: GroupMessage):
-    global first_greet
-    global greet_date
 
-    if event.gid == gTarget:
-        msg = event.raw
+class MuriPlugin(Plugin):
+    first_greet = True
+    great_date = 0
+    keywords = ['muri']
+    brif = '牡蛎管理器'
+    store = Storage('muri')
+    usage = USAGE
 
-        if greet_date != datetime.datetime.now().day:
-            greet_date = datetime.datetime.now().day
-            first_greet = True
+    async def on_load(self):
+        logger.debug('muri load')
+        if not self.store['groups']:
+            self.store['groups'] = [591764560]
+        self.groups = self.store['groups']
+        if not self.store['db']:
+            self.store['db'] = DB
+        self.db = self.store['db']
+        logger.info(f'muri groups: {self.groups}')
 
-        if '早' and '爱归' in msg and first_greet:
-            first_greet = False
-            await event.reply(msg, quote=False)
+    async def on_cmd(self, event: MessageEvent, args: list):
+        argc = len(args)
+        if argc < 2:
+            return True
 
-        if msg == '随机列表':
-            ans = []
-            for i in db:
-                ans.append(i)
-            await event.reply('/'.join(ans), quote=False)
-        elif msg in db:
-            random.seed(datetime.datetime.now())
-            await event.reply(random.choice(db[msg].split('/')))
+        match args[1]:
+            case 'group':
+                if argc < 3:
+                    return True
+                match args[2]:
+                    case 'list':
+                        await event.reply(f'Muri Groups: \n- {"\n- ".join(map(str, self.groups))}')
+                    case _:
+                        if argc < 3:
+                            return True
+                        gn = args[3]
+                        if args[2] == 'add':
+                            self.groups.append(gn)
+                            await event.reply(f'Group {gn} added.')
+                        elif args[3] == 'del':
+                            try:
+                                self.groups.remove(args[3])
+                                await event.reply(f'Group {gn} deleted.')
+                            except Exception as e:
+                                await event.reply(f'Err: {e}')
+                                return True
+                        else:
+                            return True
+            case 'db':
+                if argc < 3:
+                    return True
+                match args[2]:
+                    case 'list':
+                        if argc == 3:
+                            await event.reply(f'Muri DB: \n- {"\n- ".join(self.db.keys())}')
+                        elif args[3] in self.db.keys():
+                            await event.reply(f'DB for {args[3]}:\n{self.db[args[3]]}')
+                        else:
+                            await event.reply('Error: no such db.')
+                    case 'set':
+                        if argc != 5:
+                            return True
+                        db = args[3]
+                        content = args[4]
+                        self.db[db] = content
+                        await event.reply('DB for {db} updated.')
+                    case _:
+                        return True
+            case _:
+                return True
+
+    async def on_event(self, event: MessageEvent):
+        if event.gid in self.groups:
+            msg = event.raw
+
+            if self.greet_date != datetime.datetime.now().day:
+                self.greet_date = datetime.datetime.now().day
+                self.first_greet = True
+
+            if '早' and '爱归' in msg and self.first_greet:
+                self.first_greet = False
+                await event.reply(msg, quote=False)
+
+            if msg in db:
+                random.seed(datetime.datetime.now())
+                await event.reply(random.choice(self.db[msg].split('/')))
+
+
+PluginManager().register_plugin(MuriPlugin([MessageEvent]))