Skip to main content

Simple tools to deploy a script 24/7 on repl.it using an aiohttp server and automated uptimerobot monitors

Project description

dontuserepl

Let's face it, repl.it is one of the best places to develop, test and run code. As such, it's been popular for small discord bots for a couple of years now. Many people dislike the platform for various reasons, mainly, low resources, public code, etc, and they'll tell you to stop using it, however it remains a good place to start out and try new code easily.

The most popular way to run a discord bot on repl is to create a webserver on a different thread and configure a monitor service like uptimerobot.com to ping the server every five minutes or so.

Even though this is very simple to do, i feel bored by it, that's why i wrote this simple library.

How to use it:

Making your bot 24/7 is extremely easy with dontuserepl.

  1. Go to https://uptimerobot.com/, open an account and login.
  2. Go to "My settings" and scroll to "API Settings".
  3. Create and copy a "Main API Key"
  4. Go to your repl and add the key as a secret
  5. Add the snippet below to your main.py file.
import os
from dontuserepl import lazy_setup
key = os.getenv('uptimerobot_api_key')  # use the name of the secret from step 4
lazy_setup(key)
  1. That's it, lazy_setup runs a minimal aiohttp server on port 8080 and configures a monitor for the script.

Note: The server runs on the main loop since it's fully asynchronous.

Working example

import os
from dontuserepl import lazy_setup
from discord.ext import commands

key = os.getenv('uptimerobot_api_key')
token = os.getenv('discord_token')

bot = commands.Bot(command_prefix='!')

@bot.event
async def on_ready():
    print(f'logged in as "{bot.user.name}"')

@bot.command()
async def ping(ctx):
    await ctx.send('pong')


lazy_setup(key) # don't forget to call this *before* running the bot
bot.run(token)

todo:

  • Upload to pypi
  • Documentation
  • Better error handling

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dontuserepl-0.1.5.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

dontuserepl-0.1.5-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file dontuserepl-0.1.5.tar.gz.

File metadata

  • Download URL: dontuserepl-0.1.5.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.9.6 Windows/10

File hashes

Hashes for dontuserepl-0.1.5.tar.gz
Algorithm Hash digest
SHA256 603175f3b16ba675d096f71d7c8f1a74db1516130143a93ccbe81658e19b7752
MD5 bf5d65805afd35f117b35f4bcdac8284
BLAKE2b-256 069c916919aeeeecb7efad9c47f323cdfab602e22fbf0aff6aefafeb4dd46f47

See more details on using hashes here.

File details

Details for the file dontuserepl-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: dontuserepl-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.9.6 Windows/10

File hashes

Hashes for dontuserepl-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 717b324d6f991a557da3429d12a2e6e9306f6ce38196abd6fea9aed923838c94
MD5 a259fd43208ecbcf5eaa5de3cd6bf4f5
BLAKE2b-256 84ac5a7efe08ca1a5f932cfc4959e6dfb5577b0a6cda9f3c36c07f8e65cd9107

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page