Events
Using Tweety you can also listen to the events and respond to them.
Listen for new Message
- class NewMessageUpdate
- Reference:
tweety.events.newmessage.NewMessageUpdate
You can listen to new messages using this method. Check the example below for reference
from tweety import TwitterAsync from tweety import events cookies = cookies_value client = Twitter(cookies=cookies) @client.on(events.NewMessageUpdate) async def newMessage(event): await 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