dont import discord message for type checking
This commit is contained in:
parent
dace014779
commit
ae4d610754
1 changed files with 7 additions and 3 deletions
|
@ -4,16 +4,20 @@ Templates for representing different kinds of messages on mediawiki
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
from wiki_postbot.formats.wiki import WikiPage
|
from wiki_postbot.formats.wiki import WikiPage
|
||||||
from abc import abstractmethod
|
from abc import abstractmethod
|
||||||
from discord.message import Message
|
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from wiki_postbot.clients.slack import SlackMessage
|
from wiki_postbot.clients.slack import SlackMessage
|
||||||
|
try:
|
||||||
|
from discord.message import Message
|
||||||
|
except ImportError:
|
||||||
|
Message = None
|
||||||
|
|
||||||
class WikiTemplate(WikiPage):
|
class WikiTemplate(WikiPage):
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def format_discord(self, msg:Message) -> str:
|
def format_discord(self, msg:'Message') -> str:
|
||||||
"""
|
"""
|
||||||
Format a discord message into a template string
|
Format a discord message into a template string
|
||||||
"""
|
"""
|
||||||
|
@ -21,7 +25,7 @@ class WikiTemplate(WikiPage):
|
||||||
class TemplateMessage(WikiTemplate):
|
class TemplateMessage(WikiTemplate):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def format_discord(self, msg:Message) -> str:
|
def format_discord(self, msg:'Message') -> str:
|
||||||
# try/catch the avatar URL
|
# try/catch the avatar URL
|
||||||
try:
|
try:
|
||||||
avatar = msg.author.avatar.url
|
avatar = msg.author.avatar.url
|
||||||
|
|
Loading…
Reference in a new issue