aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tests/plugins/_show.py
blob: d009760fb5dab9375911d9c2f36994af69573e64 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from iamai import Plugin
import json

class Exec(Plugin):
    
    priority = 1
    
    async def handle(self) -> None:
        try:
            content = [
                {
                    "type": "node",
                    "data": {
                        "name": f"{self.event.sender.nickname}",
                        "uin": f"{self.event.sender.user_id}",
                        "content": [
                            {
                                "type": "text", 
                                "data": {
                                    "text": f"{eval(self.event.message.get_plain_text()[6:])}"
                                }
                            }
                        ]
                    }
                }
            ]
            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}")
            
    async def rule(self) -> bool:
        return (
            self.event.type == "message"
            and
            self.event.message.get_plain_text().startswith(".show")
        )