Skip to content

Commit

Permalink
add heroku support
Browse files Browse the repository at this point in the history
  • Loading branch information
jsmsj committed Aug 22, 2022
1 parent bed418d commit ecdb980
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 4 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/heroku.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Deploy

on:
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: akhileshns/heroku-deploy@v3.12.12 # This is the action
with:
heroku_api_key: ${{ secrets.HEROKU_API_KEY }}
heroku_app_name: ${{ secrets.HEROKU_APP_NAME }}
heroku_email: ${{ secrets.HEROKU_EMAIL }}
region: eu
env:
HD_bot_token: ${{ secrets.bot_token }}
HD_allowed_user_ids: ${{ secrets.allowed_user_ids }}
HD_db_url: ${{ secrets.db_url }}
HD_G_DRIVE_CLIENT_ID: ${{ secrets.G_DRIVE_CLIENT_ID }}
HD_G_DRIVE_CLIENT_SECRET : ${{ secrets.G_DRIVE_CLIENT_SECRET }}
HD_prefix : ${{ secrets.prefix }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
*__pycache__*
_config.py
temporary/
venv/
log.txt
.env
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
worker: python main.py
5 changes: 3 additions & 2 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ make tutorial
drive selector
bypasser
search for files (with sorting options)
heroku stuff
webapp for this thing


DONE:
size cmd
make help cmd
make help cmd
log command
heroku stuff
11 changes: 11 additions & 0 deletions cogs/_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from dotenv import load_dotenv
import os
load_dotenv()

bot_token = os.getenv('bot_token')
temp_allowed_uid = os.getenv('allowed_user_ids').split(',')
allowed_user_ids = list(map(int,[i for i in temp_allowed_uid if i!= '']))
db_url = os.getenv('db_url')
G_DRIVE_CLIENT_ID = os.getenv('G_DRIVE_CLIENT_ID')
G_DRIVE_CLIENT_SECRET = os.getenv('G_DRIVE_CLIENT_SECRET')
prefix = os.getenv('prefix')
2 changes: 1 addition & 1 deletion cogs/_config_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
G_DRIVE_CLIENT_SECRET = "xxxxxxxxxxxxxxxxxxxxxxxxxx"

"""
RENAME THIS FILE FROM _config_sample.py TO _config.py
RENAME THIS FILE FROM _config_sample.py TO _config.py IF DEPLOYING MANUALLY AND DELETE THE _config.py file which exists already
"""
37 changes: 37 additions & 0 deletions cogs/general.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"""Imports"""
import discord
import os
from discord.ext import commands
from cogs._helpers import is_allowed,embed
from cogs._config import prefix

class General(commands.Cog):
"""General commands"""

def __init__(self, bot):
self.bot = bot

async def cog_before_invoke(self, ctx):
"""
Triggers typing indicator on Discord before every command.
"""
await ctx.trigger_typing()
return

@commands.command(description=f'Checks the ping of the bot.\n`{prefix}ping`')
async def ping(self,ctx):
await ctx.send(f'🏓 Pong! Latency: {round(self.bot.latency*1000)}ms')

@is_allowed()
@commands.command(description=f'Sends the log file\n`{prefix}log`')
async def log(self,ctx):
if os.path.exists('log.txt'):
await ctx.send(embed=embed('📃 Log File','Here is the log file')[0],file=discord.File('log.txt'))
else:
await ctx.send(embed=embed('📃 Log File','No logfile found :(')[0])



def setup(bot):
bot.add_cog(General(bot))
print("General cog is loaded")
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pyasn1==0.4.8
pyasn1-modules==0.2.8
pymongo==4.1.1
pyparsing==3.0.9
python-dotenv==0.20.0
requests==2.28.0
requests-oauthlib==1.3.1
rsa==4.8
Expand Down

0 comments on commit ecdb980

Please sign in to comment.