Exemple #1
0
    def from_cli(cls, *plugins):
        """
        Creates a new instance of the bot using the utilities inside of the
        :mod:`disco.cli` module. Allows passing in a set of uninitialized
        plugin classes to load.

        Parameters
        ---------
        plugins : Optional[list(:class:`disco.bot.plugin.Plugin`)]
            Any plugins to load after creating the new bot instance

        """
        from disco.cli import disco_main
        inst = cls(disco_main())

        for plugin in plugins:
            inst.add_plugin(plugin)

        return inst
Exemple #2
0
import sys
from os import environ
# import logging
# import io

# from utils.log_relay import relayer

from disco.cli import disco_main
# from gevent import spawn

sys.argv.append("--token")
sys.argv.append(environ['TOKEN'])

# log_stream = io.StringIO()
# stream_handler = logging.FileHandler(log_stream)
# logging.basicConfig(stream=stream_handler)
#
client = disco_main()
#
# spawn(relayer, client, log_stream)

client.run_forever()
Exemple #3
0
from gevent.hub import Hub
from disco import cli
from raven import Client

IGNORE_ERROR = Hub.SYSTEM_ERROR + Hub.NOT_ERROR


def register_sentry_error_handler(sentry):
    Hub._origin_handle_error = Hub.handle_error

    def custom_handle_error(self, context, type, value, tb):
        if not issubclass(type, IGNORE_ERROR):
            sentry.captureException()
        self._origin_handle_error(context, type, value, tb)

    Hub.handle_error = custom_handle_error


if __name__ == '__main__':
    disco = cli.disco_main()
    sentry = Client(disco.client.config.sentry_dsn)
    sentry.environment = disco.client.config.sentry_environment
    register_sentry_error_handler(sentry)
    try:
        disco.run_forever()
    except:
        sentry.captureException()