|
1 | 1 |
|
2 | 2 |
|
| 3 | +import requests |
3 | 4 | import tweepy |
4 | 5 | from asgiref.sync import async_to_sync |
5 | 6 | from channels.layers import get_channel_layer |
@@ -54,18 +55,19 @@ def handle_collection(cls, status): |
54 | 55 |
|
55 | 56 | thread_tweets_ids = Grabber.grab_thread_tweets_ids(id) |
56 | 57 | if len(thread_tweets_ids) > 0: |
57 | | - content = ['<div class="tw-block">'+thread.full_text+'</div>'] |
| 58 | + content = [ |
| 59 | + '<div class="tw-block">'+thread.full_text+'</div>'] |
58 | 60 | for tweet_id in thread_tweets_ids: |
59 | 61 | tweet = cls.tweepy_client.get_status( |
60 | 62 | tweet_id, tweet_mode='extended') |
61 | 63 | if tweet.user.id != thread.user.id: |
62 | 64 | break |
63 | 65 | Cleaner.clean_tweet(tweet) |
64 | 66 | content.append( |
65 | | - '<div class="tw-block">' + tweet.full_text+'</div>') |
| 67 | + '<div class="tw-block">' + tweet.full_text + |
| 68 | + '</div>') |
66 | 69 | content = ''.join(content) |
67 | 70 |
|
68 | | - |
69 | 71 | post = Post.objects.create( |
70 | 72 | id=id, content=content, author_name=author_name, |
71 | 73 | author_screen_name=author_screen_name, |
@@ -103,12 +105,14 @@ def __add_post_to_user(cls, post, user_id): |
103 | 105 | def __reply_to_status(cls, status, old=False): |
104 | 106 | if settings.APP_ENV == "dev": |
105 | 107 | if old: |
106 | | - reply = f''' @{status.user.screen_name} 🧵 already saved locally ''' |
| 108 | + reply = f''' @{status.user.screen_name} 🧵 already saved locally 🧵''' |
107 | 109 | else: |
108 | | - reply = f''' @{status.user.screen_name} 🧵 saved locally ''' |
| 110 | + reply = f''' @{status.user.screen_name} 🧵 saved locally 🧵''' |
109 | 111 | else: |
110 | 112 | path = reverse('post', args=(status.in_reply_to_status_id,)) |
111 | | - reply = f''' @{status.user.screen_name} here your requested 🧵 {settings.APP_URL}{path} ''' |
| 113 | + r = requests.get( |
| 114 | + f'https://tinyurl.com/api-create.php?source=create&url={settings.APP_URL}{path}') |
| 115 | + reply = f''' @{status.user.screen_name} 🧵 {r.text} 🧵 ''' |
112 | 116 |
|
113 | 117 | cls.tweepy_client.update_status( |
114 | 118 | status=reply, in_reply_to_status_id=status.id) |
0 commit comments