Skip to content

Commit

Permalink
Replace twitter links with vxtwitter
Browse files Browse the repository at this point in the history
  • Loading branch information
nfaltermeier committed Dec 1, 2022
1 parent 0580dae commit 2928754
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import minecraft
import excuse
import markov
import twitter
import autogen_buildtime

logging.basicConfig(level=logging.INFO)
Expand Down Expand Up @@ -51,6 +52,7 @@ async def on_message(message: discord.Message):
await excuse.on_message(message)
await markov.on_message(message)
await faces.on_message(message, client, config)
await twitter.on_message(message, config)
if await roll.on_message(message):
return

Expand Down
2 changes: 2 additions & 0 deletions src/config.py.example
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ face_dims = [

# Max total pixels for a face image to have, set to -1 to disable
face_max_pixels = 2_000_000

enforce_vxtwitter = True
16 changes: 16 additions & 0 deletions src/twitter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import discord

async def on_message(message: discord.Message, conf):
if conf.enforce_vxtwitter:
base_len = 19
i = message.content.find('https://twitter.com')
if i == -1:
base_len = 18
i = message.content.find('http://twitter.com')
if i != -1:
space = message.content.find(" ", i)
if space == -1:
space = len(message.content)
url = f'https://vxtwitter.com{message.content[i + base_len: space]}'
await message.edit(suppress=True)
await message.reply(url)

0 comments on commit 2928754

Please sign in to comment.