forked from Teahouse-Studios/akari-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
59 lines (45 loc) · 2.18 KB
/
bot.py
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
import asyncio
from graia.application import GraiaMiraiApplication, Session
from graia.application.event.messages import TempMessage
from graia.application.event.mirai import NewFriendRequestEvent, BotInvitedJoinGroupRequestEvent
from graia.application.friend import Friend
from graia.application.group import Group, Member
from graia.application.message.chain import MessageChain
from graia.application.message.elements.internal import Plain, At, Image, UploadMethods, Quote
from graia.broadcast import Broadcast
from os.path import abspath
from MessageGen import gen, findwikitext
loop = asyncio.get_event_loop()
bcc = Broadcast(loop=loop, debug_flag=True)
app = GraiaMiraiApplication(
broadcast=bcc,
connect_info=Session(
host="http://localhost:11919", # 填入 httpapi 服务运行的地址
authKey='1145141919810', # 填入 authKey
account=2052142661, # 你的机器人的 qq 号
websocket=True # Graia 已经可以根据所配置的消息接收的方式来保证消息接收部分的正常运作.
)
)
@bcc.receiver("GroupMessage")
async def group_message_handler(app: GraiaMiraiApplication, message: MessageChain, group: Group, member: Member):
await gen(app, message, group, member, msgtype='group')
await findwikitext(app, message, group, member, msgtype='group')
@bcc.receiver("FriendMessage")
async def friend_message_handler(app: GraiaMiraiApplication, message: MessageChain, friend: Friend):
print(message)
print('f')
await gen(app, message, friend, msgtype='friend')
await findwikitext(app, message, friend, msgtype='friend')
@bcc.receiver("TempMessage")
async def temp_message_handler(app: GraiaMiraiApplication, message: MessageChain, group: Group, member: Member):
print(group.id, member.id, message.asDisplay())
print('t')
await gen(app, message, group, member, msgtype='temp')
await findwikitext(app, message, group, member, msgtype='temp')
@bcc.receiver("NewFriendRequestEvent")
async def NFriend(event: NewFriendRequestEvent):
await event.accept()
@bcc.receiver("BotInvitedJoinGroupRequestEvent")
async def NGroup(event: BotInvitedJoinGroupRequestEvent):
await event.accept()
app.launch_blocking()