aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.dockerignore1
-rw-r--r--Aptfile0
-rw-r--r--Dockerfile12
-rw-r--r--Procfile1
-rw-r--r--bot.py11
-rw-r--r--requirements.txt1
-rw-r--r--runtime.txt1
7 files changed, 17 insertions, 10 deletions
diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..5ceb386
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1 @@
+venv
diff --git a/Aptfile b/Aptfile
deleted file mode 100644
index e69de29..0000000
--- a/Aptfile
+++ /dev/null
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..7717584
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,12 @@
+FROM python:3.7-alpine
+
+RUN apk add --no-cache gcc libc-dev libffi-dev zlib-dev openssl-dev jpeg-dev ffmpeg freetype-dev
+
+WORKDIR /usr/src/app
+
+COPY requirements.txt ./
+RUN pip install --no-cache-dir -r requirements.txt
+
+COPY . .
+
+CMD [ "gunicorn", "-w", "1", "bot:app", "--log-file", "-" ]
diff --git a/Procfile b/Procfile
deleted file mode 100644
index 4bbb0c4..0000000
--- a/Procfile
+++ /dev/null
@@ -1 +0,0 @@
-web: gunicorn -w 1 bot:app --log-file -
diff --git a/bot.py b/bot.py
index ee7d055..3a66ce4 100644
--- a/bot.py
+++ b/bot.py
@@ -13,14 +13,11 @@ from typing import Optional
import telegram
from telegram.ext import Dispatcher, MessageHandler, CommandHandler, InlineQueryHandler, Filters, CallbackContext
-from dotenv import load_dotenv, find_dotenv
from PIL import Image, ImageDraw, ImageFont
import libhoney
from flask import Flask, render_template, request
app = Flask(__name__)
-load_dotenv(find_dotenv())
-
libhoney.init(writekey=os.environ.get('HONEYCOMB_KEY'), dataset="crabravebot", debug=True)
font = ImageFont.truetype("assets/fonts/NotoSans-Regular.ttf", 48)
@@ -149,11 +146,11 @@ def start(update: telegram.Update, context: CallbackContext):
To shitpost, type @{me} and type the text you want to overlay over crab rave.
This was originally made by @boringcactus in one afternoon when ze was bored.
This bot isn't super reliable but the source is at https://github.com/boringcactus/crabravebot,
-and you can use this bot from the Web at https://{name}.herokuapp.com/"""
+and you can use this bot from the Web at https://{domain}/"""
you = update.effective_user.first_name
if you is None or len(you) == 0:
you = update.effective_user.username
- text = template.format(you=you, me=context.bot.username, name=os.environ.get('HEROKU_APP_NAME', 'crabravebot'))
+ text = template.format(you=you, me=context.bot.username, domain=os.environ.get('VIRTUAL_HOST', 'crabrave.boringcactus.com'))
context.bot.send_message(chat_id=update.effective_chat.id, text=text)
@@ -164,7 +161,7 @@ def inline_query(update: telegram.Update, context: CallbackContext):
logger.info('Got query %s', text)
def make_result(style: Style):
- base = "https://" + os.environ.get('HEROKU_APP_NAME', 'crabravebot') + ".herokuapp.com/render?v=1&style=" + style.id + "&text=" + url_quote(text, safe='')
+ base = "https://" + os.environ.get('VIRTUAL_HOST', 'crabrave.boringcactus.com') + "/render?v=1&style=" + style.id + "&text=" + url_quote(text, safe='')
return telegram.InlineQueryResultVideo(
id=style.id,
video_url=base + '&ext=mp4',
@@ -219,7 +216,7 @@ def webhook():
bot = telegram.Bot(token=TOKEN)
-bot.set_webhook('https://' + os.environ.get('HEROKU_APP_NAME', 'crabravebot') + '.herokuapp.com' + WEBHOOK)
+bot.set_webhook('https://' + os.environ.get('VIRTUAL_HOST', 'crabrave.boringcactus.com') + WEBHOOK)
update_queue = Queue()
dp = Dispatcher(bot, update_queue, use_context=True)
# Add handlers
diff --git a/requirements.txt b/requirements.txt
index 4865ed5..5e7f342 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,5 +1,4 @@
python-telegram-bot
-python-dotenv
Pillow
libhoney
Flask
diff --git a/runtime.txt b/runtime.txt
deleted file mode 100644
index 03a934b..0000000
--- a/runtime.txt
+++ /dev/null
@@ -1 +0,0 @@
-python-3.7.7