Skip to content

Commit

Permalink
Fix twitter integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilia Shlykov committed Aug 8, 2023
1 parent 374b3f7 commit 7c581ec
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 41 deletions.
16 changes: 8 additions & 8 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ verify_ssl = true
name = "pypi"

[packages]
gunicorn = "==20.1.0"
gunicorn = "==21.2.0"
Django = "==3.1.14"
django-ckeditor = "==5.9.0"
django-cors-headers = "==3.4.0"
django-environ = "==0.4.5"
django-extra-fields = "==2.0.3"
django-allauth = "==0.45.0"
django-allauth = "==0.54.0"
django-filter = "==2.4.0"
django-recaptcha = "==2.0.6"
djangorestframework = "==3.12.4"
djangorestframework = "==3.14.0"
drf-serializer-cache = "==0.3.4"
datadog = "==0.37.1"
datadog = "==0.46.0"
Pillow = "==8.3.2"
Scrapy = "==2.6.2"
beautifulsoup4 = "==4.9.3"
Scrapy = "==2.10.0"
beautifulsoup4 = "==4.12.2"
python-slugify = "==5.0.2"
herepy = "==2.1.1"
ijson = "==2.6.1"
Expand All @@ -27,8 +27,8 @@ psycopg2-binary = "==2.8.5"
pymorphy2 = "==0.9.1"
python-telegram-bot = "==13.0"
scrapy-rotating-proxies = "==0.6.2"
tqdm = "==4.44.1"
tweepy = "==3.9.0"
tqdm = "==4.65.1"
tweepy = "==4.14.0"
#omit old package, it dep for scrapy-rotating-proxies
typing = { version = "*", markers="python_version < '3.0'" }

Expand Down
62 changes: 31 additions & 31 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions application/bot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,17 @@ def send_tweet(text):
access_token_secret = env('TWITTER_CONSUMER_TOKEN_SECRET')
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
apiNew = tweepy.Client(
access_token=access_token,
access_token_secret=access_token_secret,
consumer_key=consumer_key,
consumer_secret=consumer_secret
)

filename = os.path.dirname(os.path.abspath(__file__)) + "/img.png"
api.update_with_media(filename, status=text)
media = api.simple_upload(filename)
api.create_media_metadata(media_id=media.media_id, alt_text="")
apiNew.create_tweet(text=text, media_ids=[media.media_id])


def send_telegram_post(text):
Expand All @@ -183,6 +191,6 @@ def main(message="today"):
if data:
text = generate_text(data, "today_post")
make_img(data)
#send_tweet(text)
send_tweet(text)
send_telegram_post(text)
#send_vk_post(text)

0 comments on commit 7c581ec

Please sign in to comment.