0
I’m creating a Chatbot in Telegram that can answer questions from group users. The bot needs a keyword to start chatting. That word would be his name, "Joker". Thus, only when the word Joker is mentioned in a sentence would it begin to interact with the users of the group or when a response is forwarded to it. Using Python 3.7.4.
Example:
- User: I think the Joker knows more about this
 - Bot: What subject?
 - User: About the seal killing in the backlands of Ceará, Joker.
 - Bot: What are you talking about?
 
But I have no idea how to implement this action.
def respond(self, message):
    """
   Receive message from user and returns corresponding answer.
   """
    if len(message) > 50 and self.watson_usage:
        top_answer = get_analysis(message)
        return f"Hmm, você está falando sobre {top_answer}"
    elif re.search("Joker", message) or len(message) > 0:
        return self.comm.get_response(self.clean(message))
    else:
        return "Algo de errado não está certo"\
               " Digite /info para saber mais."
						
You need to have a list of predefined commands. If you’re looking to do something like the Google Assistant (which answers countless questions formulated in the most different ways as well as being error-tolerant), have a million dollar budget first.
– Seu Madruga
I already own a. yml file with numerous predefined questions and answers. It doesn’t need to be error-tolerant. It’s not something so "astronomical" Google Assistant style. Chatbot itself works smoothly, answering questions or giving a standard answer when you don’t have an answer in your database. But, the intention is for him to respond in the group, only when his name was mentioned in a sentence and not, to answer any message that is sent in the group, as is what happens.
– Jacob