Archived
1
0
Fork 0
This repository has been archived on 2024-04-26. You can view files and clone it, but cannot push or open issues or pull requests.
akari-bot/core/bots/discord/template.py
2021-08-02 23:35:45 +08:00

20 lines
790 B
Python

import re
from .message import MessageSession
from core.elements import MsgInfo, Session
from .client import client
class Bot:
@staticmethod
def bind_template(template):
for x in template.all_func:
setattr(Bot, x, getattr(template, x))
@staticmethod
def fetch_target(targetId):
matchChannel = re.match(r'^(DC|(?:DM\||)Channel)|(.*)', targetId)
if matchChannel:
getChannel = client.get_channel(int(matchChannel.group(2)))
return MessageSession(MsgInfo(targetId=targetId, senderId=targetId, senderName='',
targetFrom=matchChannel.group(1), senderFrom=matchChannel.group(1)),
Session(message=False, target=getChannel, sender=getChannel))