Skip to content
This repository was archived by the owner on Oct 5, 2024. It is now read-only.

How to create a Plugin for RTB

DeadBread76 edited this page Sep 28, 2019 · 3 revisions

How to create a Plugin for RTB

To create a plugin for RTB, you will need basic knowledge of the subprocess module.

RTB has a module you can import called plugins.helper which you can use to access the Attack manager Dictionary, config.json file, etc. Example use:

import plugins.helper

currentattacks = plugins.helper.attack_dict
theme = plugins.helper.skin
token_list = plugins.helper.token_list

RTB starts a function called plugin_launch. This is the function that will run when it starts your plugin. An example would be:

import PySimpleGUI as sg
import plugins.helper

def plugin_launch():
    sg.Popup("This is an example plugin")

It is recommend that you use subprocess to ensure RTB continues running, an example would be starting a python script called ghostpingmenu.py in the folder plugins/Additional, while writing to the Attack manager dictionary. Example:

import datetime
import subprocess
import plugins.helper

def plugin_launch():
    p = subprocess.Popen([sys.executable, 'plugins/Additional/ghostpingmenu.py', str(attacks_theme)], stdout=open("errors.log", "a+"), stderr=subprocess.STDOUT) # open("errors.log", "a+") logs to the error log, passing the attacks_theme as an argument lets the plugin use the theme.
    plugins.helper.attack_dict["Ghost Ping Spammer | Started at: {}".format(datetime.datetime.now().time())] = p.pid # adding the process PID to the attack manager dictionary.

To use the users theme, you will need to use importlib to import it. Example:

import importlib
import plugins.helper

def plugin_launch():
    mdl = importlib.import_module("themes.{}".format(plugins.helper.skin))
    if "__all__" in mdl.__dict__:
        names = mdl.__dict__["__all__"]
    else:
        names = [x for x in mdl.__dict__ if not x.startswith("_")]
    globals().update({k: getattr(mdl, k) for k in names})

This is only to create a basic loader for your plugin, and it can basically be used to run anything.

To get Plugins.helper in the subprocess, use this:

sys.path.append(os.getcwd())
import plugins.helper

If you want to use proxies, or just set up a request, use this:

headers, proxies = plugins.helper.setup_request(token)

This is to handle proxy timeouts:

while True:
    try:
        src = s.get('https://canary.discordapp.com/api/v6/users/@me', headers=headers, proxies=proxies, timeout=10)
    except Exception:
        if plugins.helper.use_proxies == 1:
            proxies = plugins.helper.request_new_proxy()
        else:
            break
        else:
            break

If you make something, and want it in the repo, hit me up on telegram @DeadBread76