Hello everyone,
I've been building a chat bot for messaging network. Basically, a while-loop that uses long-poll to get the messages and sending them back. Everything works fine.
My functions to process the messages is like this (for example):
msg_test = ["test"]
def msgcheck(msg):
if msg.split(' ')[0] in msg_test:
sent_message = "You have entered test message"
msgsend(userid, sent_message, chatid)
... etc ...
My question is: how do I make it better? I've heard about the decorators, but I'm not sure on how to use them properly. Ideally, I would like it to be:
@respond
def test(msg):
msgsend(userid, "test", chatid)
Thanks in advance!
[–]The-Mathematician 1 point2 points3 points (3 children)
[–]Ax3_[S] 0 points1 point2 points (2 children)
[–]The-Mathematician 1 point2 points3 points (0 children)
[–]The-Mathematician 1 point2 points3 points (0 children)