Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
d60 committed May 4, 2024
1 parent f23423a commit 960c9ae
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
35 changes: 35 additions & 0 deletions examples/dm_auto_reply.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import os

from twikit import Client
from twikit.streaming import Topic

AUTH_INFO_1 = ''
AUTH_INFO_2 = ''
PASSWORD = ''

client = Client()

if os.path.exists('cookies.json'):
client.load_cookies('cookies.json')
else:
client.login(
auth_info_1=AUTH_INFO_1,
auth_info_2=AUTH_INFO_2,
password=PASSWORD
)
client.save_cookies('cookies.json')


user_id = '1752362966203469824' # User ID of the DM partner to stream.
reply_message = 'Hello'

topics = {
Topic.dm_update(f'{client.user_id()}-{user_id}')
}
streaming_session = client.get_streaming_session(topics)

for topic, payload in streaming_session:
if payload.dm_update:
if client.user_id() == payload.dm_update.user_id:
continue
client.send_dm(payload.dm_update.user_id, reply_message)
3 changes: 2 additions & 1 deletion twikit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
Twikit Twitter API Wrapper
==========================
https://github.com/d60/twikit
A Python library for interacting with the Twitter API.
"""

__version__ = '1.6.1'
__version__ = '1.6.2'

from .bookmark import BookmarkFolder
from .client import Client
Expand Down

0 comments on commit 960c9ae

Please sign in to comment.