Keepalive - Discord Bot to keep threads from expiring

Overview

keepalive

Discord Bot to keep threads from expiring

Installation

Create a new Discord Bot in the Discord developer console. Remember to select "Bot" and "applications.commands" in OAuth2->URL Generator else your Bot will not work.

Usage

The bot exports three (slash) commands:

  • /addthread |all to either keep the given thread ID alive or all threads alive.
  • /rmthread to stop keeping the given thread ID alive
  • /lsthread to list all thread IDs being kept alive

The way any given thread is kept alive is by sending a message to it and then deleting it.

Configuration

Create a .env file in the bot directory with two variables: KEEPALIVE_BOT_SECRET="your bot token" KEEPALIVE_CRONTAB="your bot crontab for keeping threads alive"

One good schedule to keep threads alive, IMHO is

KEEPALIVE_CRONTAB="0 1 * * *"

Meaning send a keep-alive message to all monitored threads every day at 1 AM.

You might also like...
Satoshi is a discord bot template in python using discord.py that allow you to track some live crypto prices with your own discord bot.

Satoshi ~ DiscordCryptoBot Satoshi is a simple python discord bot using discord.py that allow you to track your favorites cryptos prices with your own

Satoshi is a discord bot template in python using discord.py that allow you to track some live crypto prices with your own discord bot.

Satoshi ~ DiscordCryptoBot Satoshi is a simple python discord bot using discord.py that allow you to track your favorites cryptos prices with your own

This python module can analyse cryptocurrency news for any number of coins given and return a sentiment. Can be easily integrated with a Trading bot to keep an eye on the news.

Python script that analyses news headline or body sentiment and returns the overall media sentiment of any given coin. It can take multiple coins an

ToDo - A simple bot to keep track of things you need to do

ToDo A simple bot to keep track of things you need to do. Installation You will

It's a Discord bot to control your PC using your Discord Channel or using Reco: Discord PC Remote Controller App.
It's a Discord bot to control your PC using your Discord Channel or using Reco: Discord PC Remote Controller App.

Reco PC Server Reco PC Server is a cross platform PC Controller Discord Bot which is a modified and improved version of Chimera for Reco-Discord PC Re

Discord-Protect is a simple discord bot allowing you to have some security on your discord server by ordering a captcha to the user who joins your server.
Discord-Protect is a simple discord bot allowing you to have some security on your discord server by ordering a captcha to the user who joins your server.

Discord-Protect Discord-Protect is a simple discord bot allowing you to have some security on your discord server by ordering a captcha to the user wh

A small and fun Discord Bot that is written in Python and discord-interactions (with discord.py)
A small and fun Discord Bot that is written in Python and discord-interactions (with discord.py)

Articuno (discord-interactions) A small and fun Discord Bot that is written in Python and discord-interactions (with discord.py) Get started If you wa

Discord bot script for sending multiple media files to a discord channel according to discord limitations.

Discord Bulk Image Sending Bot Send bulk images to Discord channel. This is a bot script that will allow you to send multiple images to Discord channe

An Open-Source Discord bot created to provide basic functionality which should be in every discord guild. We use this same bot with additional configurations for our guilds.

A Discord bot completely written to be taken from the source and built according to your own custom needs. This bot supports some core features and is

Discord ToolBox is a discord bot developed by DJD320 created for the purpose of having some convenient tools in the form of a single bot.

Discord ToolBox Discord ToolBox is a discord bot developed by DJD320 created for the purpose of having some convenient tools in the form of a single b

Linky bot, A open-source discord bot that allows you to add links to ur website, youtube url, etc for the people all around discord to see!

LinkyBot Linky bot, An open-source discord bot that allows you to add links to ur website, youtube url, etc for the people all around discord to see!

Image-Bot-Discord - This Is a discord bot that shows the specific image you search from Google
Image-Bot-Discord - This Is a discord bot that shows the specific image you search from Google

Advanced Discord.py Image Bot CREDITS Made by RLX and Mathiscool README by Milrato Installation Guide in .env Adjust the TOKEN python main.py to start

Discord.py-Bot-Template - Discord Bot Template with Python 3.x

Discord Bot Template with Python 3.x This is a template for creating a custom Di

Flask-Discord-Bot-Dashboard - A simple discord Bot dashboard created in Flask Python
Flask-Discord-Bot-Dashboard - A simple discord Bot dashboard created in Flask Python

Flask-Discord-Bot-Dashboard A simple discord Bot dashboard created in Flask Pyth

Example-bot-discord - Example bot discord xD

example-python-bot-discord Clone this repository Grab a token on Discord's devel

YouTube-Discord-Bot - Discord Bot to Search YouTube
YouTube-Discord-Bot - Discord Bot to Search YouTube

YouTube Bot Info YouTube Bot is a discord bot where you can search for anything

SongLink Discord Bot - Discord bot to share music links easily

SongLink_Discord_Bot Discord bot to share music links easily. Take a link from y

Anime-Discord-Bot - Lightweight anime searching Discord bot supported by the AnilistPython library (anilist.co APIv2 wrapper)) Discord bot-CTFD-Thread-Parser - Discord bot CTFD-Thread-Parser
Discord bot-CTFD-Thread-Parser - Discord bot CTFD-Thread-Parser

Discord bot CTFD-Thread-Parser Description: This tools is used to create automat

Comments
  • Not working if some features are enabled on server

    Not working if some features are enabled on server

    Hi,

    First of all, great job 👍

    But we had some problems with your bot because the server used some features that aren't detected as valid by pincer. Some where already added in newer commits but not released yet. And one was added by myself here: https://github.com/Pincer-org/Pincer/pull/431

    Maybe you should think about using the main branch of pincer or at least use a newer commit in the meantime?

    opened by Dr-Electron 1
  • exception=AttributeError(

    exception=AttributeError("'str' object has no attribute 'get'")

    Hello here!

    we are using the bot and getting this error:

    ERROR:asyncio:Task exception was never retrieved                                                                                                                                                                   
    future: <Task finished name='Task-471' coro=<Client.event_handler() done, defined at /opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/client.py:743> exception=AttributeError("'str' object has no 
    attribute 'get'")>                                                                                                                                                                                                 
    Traceback (most recent call last):                                                                                                                                                                                 
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/client.py", line 755, in event_handler                                                                                                    
        await self.process_event(payload.event_name.lower(), payload, gateway)                                                                                                                                         
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/client.py", line 741, in process_event                                                                                                    
        await self.execute_error(e, gateway)                                                                                                                                                                           
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/client.py", line 714, in execute_error                                                                                                    
        raise error                                                                                                                                                                                                    
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/client.py", line 734, in process_event                                                                                                    
        key, args = await self.handle_middleware(payload, name, gateway)                                                                                                                                               
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/client.py", line 667, in handle_middleware                                                                                                
        extractable = await ware(self, gateway, payload, *args, **kwargs)                                                                                                                                              
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/client.py", line 154, in wrapper                                                                                                          
        return await func(cls, gateway, payload)                                                                                                                                                                       
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/middleware/presence_update.py", line 38, in presence_update_middleware                                                                    
        return ("on_presence_update", PresenceUpdateEvent.from_dict(payload.data))                                                                                                                                     
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/utils/api_object.py", line 276, in from_dict                                                                                              
        return cls(                                                                                                                                                                                                    
      File "<string>", line 8, in __init__                                                                                                                                                                             
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/utils/api_object.py", line 222, in __post_init__                                                                                          
        attr_value = [                                                                                                                                                                                                 
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/utils/api_object.py", line 223, in <listcomp>                                                                                             
        self.__attr_convert(attr_item, classes[0])                                                                                                                                                                     
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/utils/api_object.py", line 181, in __attr_convert                                                                                         
        return factory(attr_value)                                                                                                                                                                                     
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/utils/api_object.py", line 239, in __factory__                                                                                            
        return cls.from_dict(*args, **kwargs)                                                                                                                                                                          
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/utils/api_object.py", line 276, in from_dict                                                                                              
        return cls(                                                                                                                                                                                                    
      File "<string>", line 18, in __init__                                                                                                                                                                            
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/utils/api_object.py", line 222, in __post_init__                                                                                          
        attr_value = [                                                                                                                                                                                                 
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/utils/api_object.py", line 223, in <listcomp>                                                                                             
        self.__attr_convert(attr_item, classes[0])                                                                                                                                                                     
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/utils/api_object.py", line 183, in __attr_convert                                                                                         
        return factory(attr_value)                                                                                                                                                                                     
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/utils/api_object.py", line 239, in __factory__                                                                                            
        return cls.from_dict(*args, **kwargs)                                                                                                                                                                          
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/utils/api_object.py", line 277, in from_dict                                                                                              
        **dict(                                                                                                                                                                                                        
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/utils/api_object.py", line 286, in <lambda>                                                                                               
        lambda object_argument: data.get(object_argument)                                                               
        AttributeError: 'str' object has no attribute 'get'                                                                                                                                                       [26/1806]
    Keeping thread 932528191325736992 alive
    ERROR:pincer.core:An http exception occurred while trying to send a request to channels/932528191325736992/messages. (400, Bad Request)
    ERROR:asyncio:Exception in callback Cron.set_result(<_GatheringFu...ad Request')]>)
    handle: <Handle Cron.set_result(<_GatheringFu...ad Request')]>)>
    Traceback (most recent call last):
      File "/usr/lib/python3.9/asyncio/events.py", line 80, in _run
        self._context.run(self._callback, *self._args)
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/aiocron/__init__.py", line 112, in set_result
        raise result
      File "/opt/antonio/keepalive/bot.py", line 108, in keep_alive
        await bot.keep_them_all_alive()
      File "/opt/antonio/keepalive/bot.py", line 92, in keep_them_all_alive
        await self.keep_alive(thread_id)
      File "/opt/antonio/keepalive/bot.py", line 98, in keep_alive
        msg = await channel.send('ping')
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/objects/guild/channel.py", line 517, in send
        resp = await self._http.post(
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/core/http.py", line 446, in post
        return await self.__send(
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/core/http.py", line 186, in __send
        return await self.__handle_response(
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/core/http.py", line 272, in __handle_response
        raise exception
    pincer.exceptions.BadRequestError: Bad Request
    ERROR:asyncio:Task exception was never retrieved
    future: <Task finished name='Task-1550' coro=<Client.event_handler() done, defined at /opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/client.py:743> exception=AttributeError("'str' object has no
     attribute 'get'")>
    Traceback (most recent call last):
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/client.py", line 755, in event_handler
        await self.process_event(payload.event_name.lower(), payload, gateway)
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/client.py", line 741, in process_event
        await self.execute_error(e, gateway)
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/client.py", line 714, in execute_error
        raise error
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/client.py", line 734, in process_event
        key, args = await self.handle_middleware(payload, name, gateway)
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/client.py", line 667, in handle_middleware
        extractable = await ware(self, gateway, payload, *args, **kwargs)
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/client.py", line 154, in wrapper
        return await func(cls, gateway, payload)
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/middleware/presence_update.py", line 38, in presence_update_middleware
        return ("on_presence_update", PresenceUpdateEvent.from_dict(payload.data))
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/utils/api_object.py", line 276, in from_dict
        return cls(
      File "<string>", line 8, in __init__
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/utils/api_object.py", line 222, in __post_init__
        attr_value = [
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/utils/api_object.py", line 223, in <listcomp>
        self.__attr_convert(attr_item, classes[0])
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/utils/api_object.py", line 181, in __attr_convert
        return factory(attr_value)
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/utils/api_object.py", line 239, in __factory__
        return cls.from_dict(*args, **kwargs)
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/utils/api_object.py", line 276, in from_dict
        return cls(
      File "<string>", line 18, in __init__
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/utils/api_object.py", line 222, in __post_init__
        attr_value = [
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/utils/api_object.py", line 223, in <listcomp>
        self.__attr_convert(attr_item, classes[0])
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/utils/api_object.py", line 183, in __attr_convert
        return factory(attr_value)
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/utils/api_object.py", line 239, in __factory__
        return cls.from_dict(*args, **kwargs)
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/utils/api_object.py", line 277, in from_dict
        **dict(
      File "/opt/antonio/keepalive/kavenv/lib/python3.9/site-packages/pincer/utils/api_object.py", line 286, in <lambda>
        lambda object_argument: data.get(object_argument)
    AttributeError: 'str' object has no attribute 'get'
    

    Is there anything we can look at or help debug?

    Thanks

    opened by antonionardella 4
Owner
Francesco Pierfederici
Francesco Pierfederici
A mass creator for Discord's new channel threads.

discord-thread-flooder A mass creator for Discord's new channel threads. (obv created by https://github.com/imvast) Warning: this may lag ur pc if u h

Vast 6 Nov 4, 2022
A bot framework for Reddit to manage threads, wiki pages, widgets, menus and more.

Sub Manager Sub Manager is a bot framework for Reddit to automate a variety of tasks on one or more subreddits, and can be configured and run without

r/SpaceX 3 Aug 26, 2022
Cytotron - A unique discord bot like never before. Add it to your server to keep it active, motiviated, and amazing!!

Cytotron - Take your server to the next level Most of the details are in the website. Go to https://cytotron-bot.gq for more information. If that link

LeviathanProgramming 6 Jun 13, 2021
Download images from forum threads

Forum Image Scraper Downloads images from forum threads Only works with forums which doesn't require a login to view and have an incremental paginatio

null 9 Nov 16, 2022
The producer-consumer problem implemented with threads in Python

This was developed using a Python virtual environment, I would strongly recommend to do the same if you want to clone this repository. How to run this

Omar Beltran 1 Oct 30, 2021
Automatically re-open threads when they get archived, no matter your boost level!

ThreadPersist Automatically re-open threads when they get archived, no matter your boost level! Installation You will need to install poetry to run th

null 7 Sep 18, 2022
A python tool for synchronizing the messages from different threads, processes, or hosts.

Sync-stream This project is designed for providing the synchoronization of the stdout / stderr among different threads, processes, devices or hosts.

Yuchen Jin 0 Aug 11, 2021
Pearpy - a Python package for writing multithreaded code and parallelizing tasks across CPU threads.

Pearpy The Python package for (pear)allelizing your tasks across multiple CPU threads. Installation The latest version of Pearpy can be installed with

MLH Fellowship 5 Nov 1, 2021
City-seeds - A random generator of cultural characteristics intended to spark ideas and help draw threads

City Seeds This is a random generator of cultural characteristics intended to sp

Aydin O'Leary 2 Mar 12, 2022
Python directory buster, multiple threads, gobuster-like CLI, web server brute-forcer, URL replace pattern feature.

pybuster v1.1 pybuster is a tool that is used to brute-force URLs of web servers. Features Directory busting (URI) URL replace patterns (put PYBUSTER

Glaukio 1 Jan 5, 2022