summaryrefslogtreecommitdiff
path: root/ATRI/plugins/auto_tietie.py
blob: a88760eadcf1e6d8f1317c03e6d9a05b63c12ecd (plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from random import choice

from nonebot.adapters.onebot.v11 import MessageEvent
from nonebot.adapters.onebot.v11 import MessageSegment
from nonebot.adapters.onebot.v11.helpers import Cooldown

from ATRI.service import Service
from ATRI.permission import MASTER


__TIETIE_ENABLED = True
__TIETIE_WORDS = choice(
    [
        "mua!",
        "贴贴!",
        MessageSegment.image(
            file="https://jsd.imki.moe/gh/Kyomotoi/CDN@master/project/ATRI/wife0.jpg"
        ),
        MessageSegment.image(
            file="https://jsd.imki.moe/gh/Kyomotoi/CDN@master/project/ATRI/wife1.jpg"
        ),
        MessageSegment.image(
            file="https://jsd.imki.moe/gh/Kyomotoi/CDN@master/project/ATRI/wife2.jpg"
        ),
        MessageSegment.image(
            file="https://jsd.imki.moe/gh/Kyomotoi/CDN@master/project/ATRI/wife3.jpg"
        ),
    ]
)

plugin = Service("贴贴").document("全自动贴贴机").permission(MASTER)


auto_tietie = plugin.on_message(
    "贴贴w", "只与维护者贴贴w, '不可以贴'以拒绝贴贴~, '来贴贴'以接受贴贴~", block=False, priority=11
)


@auto_tietie.handle([Cooldown(600)])
async def _(event: MessageEvent):
    if not __TIETIE_ENABLED:
        await auto_tietie.finish()

    user_id = event.get_user_id()
    at = MessageSegment.at(user_id)
    result = at + __TIETIE_WORDS  # type: ignore
    await auto_tietie.finish(result)


no_tietie = plugin.on_command("不可以贴", docs="拒绝贴贴")


@no_tietie.handle()
async def _():
    global __TIETIE_ENABLED
    __TIETIE_ENABLED = False
    await no_tietie.finish("好吧...")


yes_tietie = plugin.on_command("来贴贴", docs="继续贴贴")


@yes_tietie.handle()
async def _():
    global __TIETIE_ENABLED
    __TIETIE_ENABLED = True
    await yes_tietie.finish("好欸!")