Message from Python discussions
November 2018
— What I need is this:
i have a function that takes as args only strings if there just a one word and a list for multiple words.
Now I want to run the check for each arg
class _ReplyTo(BaseFilter): def __init__(self, words, starts_with=False, ignore_markdown=False, ignore_html=False): self.words = words
self.name = 'CustomFilters.reply_to_text({})'.format(self.words)
self.starts_with = starts_with
self.ignore_markdown = ignore_markdown
self.ignore_html = ignore_htm
def filter(self, message: Message):
rep_msg = message.reply_to_message
if len(list(self.words)) > 1 and not isinstance(self.words, list):
pass
elif rep_msg and rep_msg.text:
return bool(any(words in message.reply_to_message.text for words in self.words))
— This is my code btw
— How could I do what I want without using a shitload of ifs and ands
— I need that for if starts_with
— Switch statement
— Why not hastbin?
— Because i'm lazy and I'm using a phone
— Hmm
— Too much cocaine
— Okay, it's not readable, that is why.
— Lazyness will get you a warn