fixed emoji call and added msg_gen
This commit is contained in:
@@ -28,16 +28,18 @@ class Kwaylon(Client):
|
|||||||
"""
|
"""
|
||||||
async def alive(channel: TextChannel):
|
async def alive(channel: TextChannel):
|
||||||
await channel.send('https://tenor.com/view/terminator-im-back-gif-19144173')
|
await channel.send('https://tenor.com/view/terminator-im-back-gif-19144173')
|
||||||
await channel.send(self.kaylon_emoji())
|
await channel.send(self.kaylon_emoji)
|
||||||
|
|
||||||
# _log.info('[bold bright_green]Starting initialize[/]')
|
# _log.info('[bold bright_green]Starting initialize[/]')
|
||||||
self.fd_guild: Guild = await self.fetch_guild(FD_GUILD_ID)
|
self.fd_guild: Guild = await self.fetch_guild(FD_GUILD_ID)
|
||||||
self.robotics_facility: TextChannel = await self.fetch_channel(ROBOTICS_FACILITY_ID)
|
self.robotics_facility: TextChannel = await self.fetch_channel(ROBOTICS_FACILITY_ID)
|
||||||
self.robotics_facility_dev: TextChannel = await self.fetch_channel(DEV_ROBOTICS_FACILITY_ID)
|
self.robotics_facility_dev: TextChannel = await self.fetch_channel(DEV_ROBOTICS_FACILITY_ID)
|
||||||
self.kaylon_emoji: Emoji = utils.get(self.emojis, name='kaylon')
|
self.kaylon_emoji: Emoji = utils.get(self.emojis, name='kaylon')
|
||||||
# await alive(self.robotics_facility_dev)
|
# await alive(self.robotics_facility)
|
||||||
_log.info('[bold bright_green]Done[/][bright_black], laying in wait...[/]')
|
_log.info('[bold bright_green]Done[/][bright_black], laying in wait...[/]')
|
||||||
|
|
||||||
|
await self.msg_gen(limit=10)
|
||||||
|
|
||||||
async def handle_message(self, message: Message):
|
async def handle_message(self, message: Message):
|
||||||
if message.author != self.user:
|
if message.author != self.user:
|
||||||
await self.respond_to_joke(message)
|
await self.respond_to_joke(message)
|
||||||
@@ -132,11 +134,23 @@ class Kwaylon(Client):
|
|||||||
channel = await guild.fetch_channel(row['channel_id'])
|
channel = await guild.fetch_channel(row['channel_id'])
|
||||||
return await channel.fetch_message(row['msg_id'])
|
return await channel.fetch_message(row['msg_id'])
|
||||||
|
|
||||||
async def scan_messages(self, **kwargs):
|
async def msg_gen(self, **kwargs):
|
||||||
async with self.lock:
|
_log.debug(f'Starting scan of {self.fd_guild.name}')
|
||||||
await self.data.scan_messages(client=self, **kwargs)
|
for channel in (await self.fd_guild.fetch_channels()):
|
||||||
|
if isinstance(channel, TextChannel):
|
||||||
|
_log.debug(f'[bold green]{channel.name}[/]')
|
||||||
|
msg: Message
|
||||||
|
async for msg in channel.history(**kwargs):
|
||||||
|
_log.debug(f'[bold blue]{msg.author.display_name}[/] {msg.content[:200]}')
|
||||||
|
|
||||||
|
|
||||||
|
def log_info():
|
||||||
|
for name, logger in logging.Logger.manager.loggerDict.items():
|
||||||
|
print(f'{name:25} {str(logger.__class__)[8:-2]}')
|
||||||
|
if not isinstance(logger, logging.PlaceHolder) and logger.hasHandlers():
|
||||||
|
for handler in logger.handlers:
|
||||||
|
print(f' - {str(handler.__class__)[8:-2]}')
|
||||||
|
|
||||||
def get_emoji_name(string: str) -> str:
|
def get_emoji_name(string: str) -> str:
|
||||||
if (m := re.search('<:(?P<name>\w+):(?P<id>\d+)>', string)):
|
if (m := re.search('<:(?P<name>\w+):(?P<id>\d+)>', string)):
|
||||||
string = m.group('name')
|
string = m.group('name')
|
||||||
|
|||||||
Reference in New Issue
Block a user