Events
Using Tweety you can also listen to the events and respond to them.
Listen for new Message
Attention
Each triggered event will call the callback function in a new thread for time begin , in later versions , full async supprt will be added
- class NewMessageUpdate
- Reference:
tweety.events.newmessage.NewMessageUpdate
You can listen to new messages using this method. Check the example below for reference
from tweety.bot import Twitter cookies = cookies_value client = Twitter(cookies=cookies) @client.on(events.NewMessageUpdate) def newMessage(event): event.respond("OKAY") client.run_until_disconnected()
The user will register a new event handler
NewMessageUpdate
which will start listening for new messages. When this event triggers the functionnewMessage
will be called when one positional argumentevent
. The class of thisevent
isNewMessage