def find_reaction_emoji(self): mentions = [Mention(self.author_id, length=len(self.author.first_name) + 1)] if len(self.user_params) == 0: return None elif len(self.user_params) == 1: emoji = self.user_params[0].strip().lower() try: emoji = MessageReaction(emoji) return emoji except ValueError: try: emoji = self.emoji_dict[emoji] if emoji == "run_random": emoji = choose(["❤", "😍", "😆", "😮", "😢", "😠", "👍", "👎"]) return MessageReaction(emoji) except KeyError: response_text = "@{}\nSorry, you can't react with that.".format(self.author.first_name) self.client.send( Message(text=response_text, mentions=mentions), thread_id=self.thread_id, thread_type=self.thread_type ) return "invalid" else: response_text = "@{}\nPlease input only 1 emoji.".format(self.author.first_name) self.client.send( Message(text=response_text, mentions=mentions), thread_id=self.thread_id, thread_type=self.thread_type ) return "invalid"
def find_reaction_emoji(self): msg = self.message_object.text.split() ed = react.react.emoji_dict for m in msg: if m.lower() in ed: emoji = ed[m.lower()] return MessageReaction(emoji)
def send_status(self, status: Status): if isinstance(status, MessageRemoval): uid: str = cast(str, status.message.uid) rfind = uid.rfind('.') if rfind > 0 and uid[rfind + 1:].isdecimal(): uid = uid[:rfind] return self.client.unsend(uid) elif isinstance(status, ReactToMessage): try: self.client.reactToMessage( status.msg_id, status.reaction and MessageReaction(status.reaction)) except (FBchatException, ValueError) as e: self.logger.error(f"Error occurred while sending status: {e}") raise EFBMessageReactionNotPossible(*e.args) return # Other status types go here raise EFBOperationNotSupported()