async def log_event(client: ApexSigma, guild: discord.Guild, db: Database, response: discord.Embed, event: str):
    all_channels = client.get_all_channels()
    log_channel_id = await db.get_guild_settings(guild.id, f'{event}_channel')
    log_event_active = await db.get_guild_settings(guild.id, event)
    if log_channel_id and log_event_active:
        log_channel = discord.utils.find(lambda x: x.id == log_channel_id, all_channels)
        if log_channel:
            try:
                await log_channel.send(embed=response)
            except Exception:
                pass
示例#2
0
def run():
    """
    The main run call.
    Runs the entire client core.
    """
    ci_token = os.getenv('CI')
    if not ci_token:
        try:
            # if `install_requirements` was run, reimport the framework.
            if requirements_reinstalled:
                sigma = import_framework()
            else:
                sigma = ApexSigma()
            sigma.run()
        except (ImportError, ModuleNotFoundError, NameError):
            install_requirements()
            run()
        except KeyboardInterrupt:
            pass
    else:
        exit(0)
示例#3
0
def import_framework():
    """
    Attempts to import the ApexSigma class.
    This is necessary after running `install_requirements`.
    :return:
    :rtype: ApexSigma
    """
    try:
        from sigma.core.sigma import ApexSigma
        return ApexSigma()
    except (ImportError, ModuleNotFoundError) as e:
        print('Installing missing requirements did not resolve the issue, please contact Sigma\'s developers.')
        print(repr(e))
        exit(errno.EINVAL)
示例#4
0
#!/usr/bin/env python3.6
import errno
import os
import sys

from sigma.core.sigma import ApexSigma

try:
    assert sys.version_info >= (3, 6)
except AssertionError:
    print('Fatal Error: Wrong Python Version! Sigma supports Python 3.6+!')
    exit(errno.EINVAL)

if __name__ == '__main__':
    ci_token = os.getenv('CI')
    if not ci_token:
        sigma = ApexSigma()
        sigma.run()
    else:
        exit(0)