Skip to content

Commit c7805f6

Browse files
committed
Fully stop posting to X (Twitter)
We previously switched from posting new questions to X to instead post an encouragement to follow us on Bluesky/Mastodon. Our X integration has now stopped working. Let's just kill this code instead of spending time trying to fix it. Fixes #425
1 parent 544c064 commit c7805f6

5 files changed

Lines changed: 4 additions & 31 deletions

File tree

quiz/management/commands/auto_publish.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
import datetime
66
from pathlib import Path
77

8-
import tweepy
9-
from django.core.mail import mail_admins
108
from django.core.management.base import BaseCommand
119
from django.utils import timezone
1210

@@ -37,7 +35,6 @@ def handle(self, *args, **options):
3735

3836
def post_to_socials(self, content):
3937
platforms = [
40-
("X", self.post_to_x),
4138
("Bluesky", lambda: self.post_to_bluesky(content)),
4239
("Mastodon", lambda: self.post_to_mastodon(content)),
4340
]
@@ -51,20 +48,6 @@ def post_to_socials(self, content):
5148
traceback.print_exc()
5249
return had_failure
5350

54-
def post_to_x(self):
55-
content = "We just published a new question! Follow us on Bluesky @cppquiz.bsky.social or Mastodon @cppquiz@mastodon.online for updates. For obvious reasons, no longer post to Elon Musk's X."
56-
print(f"Posting to X: '{content}'")
57-
secrets = self.read_secrets()
58-
59-
client = tweepy.Client(
60-
consumer_key=secrets["consumer_key"], consumer_secret=secrets["consumer_secret"],
61-
access_token=secrets["access_token"], access_token_secret=secrets["access_token_secret"],
62-
)
63-
response = client.create_tweet(
64-
text=content
65-
)
66-
post_url = f"https://x.com/user/status/{response.data['id']}"
67-
6851
def post_to_bluesky(self, content):
6952
print(f"Posting to Bluesky: '{content}'")
7053
secrets = self.read_secrets()

quiz/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def clean(self):
7676
if self.state in ('PUB', 'SCH') and self.reserved:
7777
raise ValidationError(f'Cannot {verbs[self.state]} a reserved question')
7878
if self.socials_text and not re.search("https?://", self.socials_text):
79-
raise ValidationError('Tweets must contain a url!')
79+
raise ValidationError('Social media messages must contain a url!')
8080

8181
def save(self, *args, **kwargs):
8282
self.full_clean()

quiz/tests/unit/test_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def test_requires_url_in_socials_text(self):
5454
q = Question(state="SCH", hint='hint', socials_text="hi", difficulty=1)
5555
with self.assertRaises(ValidationError) as cm:
5656
q.save()
57-
self.assertIn('Tweets must contain a url!', str(cm.exception))
57+
self.assertIn('Social media messages must contain a url!', str(cm.exception))
5858
Question(state="SCH", hint='hint', socials_text="See http://example.com", difficulty=1).save()
5959
Question(state="SCH", hint='hint', socials_text="See https://example.com", difficulty=1).save()
6060

requirements.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
Django>=5,<6
22
Markdown
3+
requests
34
pymdown-extensions
45
mock
56
parameterized
6-
tweepy
77
autopep8
88
pip-tools
99
pytest

requirements.txt

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ markdown==3.10.2
3939
# pymdown-extensions
4040
mock==5.2.0
4141
# via -r requirements.in
42-
oauthlib==3.3.1
43-
# via
44-
# requests-oauthlib
45-
# tweepy
4642
packaging==26.2
4743
# via
4844
# build
@@ -73,17 +69,11 @@ pytest-django==4.12.0
7369
pyyaml==6.0.3
7470
# via pymdown-extensions
7571
requests==2.34.2
76-
# via
77-
# requests-oauthlib
78-
# tweepy
79-
requests-oauthlib==2.0.0
80-
# via tweepy
72+
# via -r requirements.in
8173
splinter[django]==0.21.0
8274
# via -r requirements.in
8375
sqlparse==0.5.5
8476
# via django
85-
tweepy==4.16.0
86-
# via -r requirements.in
8777
urllib3==2.7.0
8878
# via
8979
# requests

0 commit comments

Comments
 (0)