Skip to content

Commit

Permalink
Merge pull request #12 from georgeamccarthy/main
Browse files Browse the repository at this point in the history
Keep server alive with repeated ping requests & replit config.
  • Loading branch information
SaurabhAgarwala authored Jun 11, 2021
2 parents 9513de2 + c6a99ec commit 497b6e9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@

ok.json

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
1 change: 1 addition & 0 deletions .replit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
run = "python3 mentalHealthBot.py"
15 changes: 15 additions & 0 deletions keepalive.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from flask import Flask
from threading import Thread

app = Flask('')

@app.route('/')
def home():
return "Hello. I am alive!"

def run():
app.run(host='0.0.0.0',port=8080)

def keepalive():
t = Thread(target=run)
t.start()
6 changes: 4 additions & 2 deletions mentalHealthBot.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
import requests
from discord.ext import commands
import random
from keepalive import keepalive

# enter token for the server
from dotenv import load_dotenv
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
# enter application id

Expand Down Expand Up @@ -247,5 +246,8 @@ async def on_message(message):
response = get_qoute()
await message.channel.send(response)

# REPEATEDLY PING SERVER TO KEEP ALIVE
#keepalive()

# ---------------------INITIALIZING THE BOT
bot.run(TOKEN)

0 comments on commit 497b6e9

Please sign in to comment.