def get_formatted_message(self, message): edit_ts = message.edited_at if not edit_ts: edit_ts = None else: edit_ts = self.format_datetime(edit_ts) msg = { "id": str(message.id), "channel_id": str(message.channel.id), "content": message.content, "author": get_message_author(message), "timestamp": self.format_datetime(message.created_at), "edited_timestamp": edit_ts, } if hasattr(message, "mentions"): msg["mentions"] = get_message_mentions(message.mentions) if hasattr(message, "attachments"): msg["attachments"] = get_attachments_list(message.attachments) if hasattr(message, "embeds"): msg["embeds"] = get_embeds_list(message.embeds) if hasattr(message, "author"): nickname = None if hasattr(message.author, 'nick') and message.author.nick: nickname = message.author.nick msg["author"]["nickname"] = nickname if hasattr(message, "mentions"): for mention in msg["mentions"]: mention["nickname"] = None member = message.guild.get_member(mention["id"]) if member: mention["nickname"] = member.nick return msg
def get_formatted_message(self, message): edit_ts = message.edited_timestamp if not edit_ts: edit_ts = None else: edit_ts = self.format_datetime(edit_ts) msg = { "id": message.id, "channel_id": message.channel.id, "content": message.content, "author": get_message_author(message), "timestamp": self.format_datetime(message.timestamp), "edited_timestamp": edit_ts, "mentions": get_message_mentions(message.mentions), "attachments": message.attachments, "embeds": message.embeds, } nickname = None if hasattr(message.author, 'nick') and message.author.nick: nickname = message.author.nick msg["author"]["nickname"] = nickname for mention in msg["mentions"]: mention["nickname"] = None member = message.server.get_member(mention["id"]) if member: mention["nickname"] = member.nick return msg
async def update_message(self, message): if message.guild: await Messages.update.values( content=message.content, timestamp=message.created_at, edited_timestamp=message.edited_at, mentions=json.dumps(get_message_mentions(message.mentions)), attachments=json.dumps( get_attachments_list(message.attachments)), embeds=json.dumps(get_embeds_list(message.embeds)), author=json.dumps(get_message_author(message))).where( Messages.message_id == int(message.id)).gino.status()
async def push_message(self, message): if message.guild: await Messages.create( message_id=int(message.id), guild_id=int(message.guild.id), channel_id=int(message.channel.id), content=message.content, author=json.dumps(get_message_author(message)), timestamp=message.created_at, edited_timestamp=message.edited_at, mentions=json.dumps(get_message_mentions(message.mentions)), attachments=json.dumps( get_attachments_list(message.attachments)), embeds=json.dumps(get_embeds_list(message.embeds)))
async def update_message(self, message): if message.server: async with threadpool(): with self.get_session() as session: msg = session.query(Messages) \ .filter(Messages.guild_id == message.server.id) \ .filter(Messages.channel_id == message.channel.id) \ .filter(Messages.message_id == message.id).first() if msg: msg.content = message.content msg.timestamp = message.timestamp msg.edited_timestamp = message.edited_timestamp msg.mentions = json.dumps( get_message_mentions(message.mentions)) msg.attachments = json.dumps(message.attachments) msg.author = json.dumps(get_message_author(message)) session.commit()
def _update_message(self, message): if message.guild: with self.get_session() as session: msg = session.query(Messages) \ .filter(Messages.guild_id == message.guild.id) \ .filter(Messages.channel_id == message.channel.id) \ .filter(Messages.message_id == message.id).first() if msg: msg.content = message.content msg.timestamp = message.created_at msg.edited_timestamp = message.edited_at msg.mentions = json.dumps( get_message_mentions(message.mentions)) msg.attachments = json.dumps( get_attachments_list(message.attachments)) msg.embeds = json.dumps(get_embeds_list(message.embeds)) msg.author = json.dumps(get_message_author(message)) session.commit()
async def push_message(self, message): if message.server: async with threadpool(): with self.get_session() as session: edit_ts = message.edited_timestamp if not edit_ts: edit_ts = None else: edit_ts = str(edit_ts) msg = Messages( message.server.id, message.channel.id, message.id, message.content, json.dumps(get_message_author(message)), str(message.timestamp), edit_ts, json.dumps(get_message_mentions(message.mentions)), json.dumps(message.attachments)) session.add(msg) session.commit()
def _push_message(self, message): if message.guild: with self.get_session() as session: edit_ts = message.edited_at if not edit_ts: edit_ts = None else: edit_ts = str(edit_ts) msg = Messages( int(message.guild.id), int(message.channel.id), int(message.id), message.content, json.dumps(get_message_author(message)), str(message.created_at), edit_ts, json.dumps(get_message_mentions(message.mentions)), json.dumps(get_attachments_list(message.attachments)), json.dumps(get_embeds_list(message.embeds))) session.add(msg) session.commit()