Ejemplo n.º 1
0
"""Definition of the bot's Admin module.'"""
from contextlib import suppress
from util.perms import or_check_perms, echeck_perms, check_perms
from util.const import muted_perms
import util.dynaimport as di
from .cog import Cog

for mod in ['asyncio', 'random', 'discord']:
    globals()[mod] = di.load(mod)
commands = di.load('util.commands')


class Admin(Cog):
    """Commands useful for admins and/or moderators.
    Can be extremely powerful, use with caution!
    """
    @commands.command(pass_context=True,
                      aliases=['clear', 'nuke', 'prune', 'clean'],
                      no_pm=True)
    async def purge(self, ctx, *count):
        """Purge a channel of messages.
        Usage: purge"""
        if self.bot.selfbot:
            await self.bot.say(
                '**That command doesn\'t work in selfbot mode, due to a Discord restriction.**'
            )
            return
        or_check_perms(ctx,
                       ['manage_server', 'manage_channels', 'manage_messages'])
        mode = 'count'
        detected = False
Ejemplo n.º 2
0
"""Functions for handling the Data Store."""
import asyncio
import os
import sys
import random
import shutil
import util.json as json
import util.dynaimport as di
from discord.ext.commands import CommandInvokeError
from properties import storage_backend
bson = di.load('bson')


class DataStore():
    """The data store central."""
    exts = {'json': 'json', 'leveldb': 'ldb', 'pickle': 'db', 'bson': 'bson'}

    def __init__(self, backend, path=None, join_path=True, commit_interval=3):
        self.dir = os.path.dirname(
            os.path.abspath(sys.modules['__main__'].core_file))
        self.backend = backend
        self.session = None
        self.commit_interval = commit_interval
        self.path = ''
        if path:
            if join_path:
                self.path = os.path.join(self.dir, path)
            else:
                self.path = path
        else:
            self.path = os.path.join(self.dir,
Ejemplo n.º 3
0
import subprocess
import aiohttp
import discord
import os
import shutil
import async_timeout
import sys
import asyncio
from discord.ext import commands
from contextlib import suppress
from util.perms import echeck_perms, check_perms
from util.func import bdel, DiscordFuncs, _set_var, _import, _del_var, snowtime, assert_msg, check
import util.dynaimport as di
from .cog import Cog

zipfile = di.load('zipfile')


def gimport(mod_name, name=None, attr=None):
    exec(_import(mod_name, var_name=name, attr_name=attr))


setvar = lambda v, e: exec(_set_var(v, e))
delvar = lambda v: exec(_del_var(v))


class Owner(Cog):
    """Powerful, owner only commands."""
    def __init__(self, bot):
        self.last_broadcasts = {}
        self.dc_funcs = DiscordFuncs(bot)
Ejemplo n.º 4
0
"""Definition of the bot's Cosmetic module.'"""
from contextlib import suppress
from urllib.parse import urlencode
from .cog import Cog
from util.const import charsets, spinners, lvl_base
import util.dynaimport as di

for mod in ['asyncio', 'random', 'io', 'imghdr', 'aiohttp',
            'async_timeout', 'discord']:
    globals()[mod] = di.load(mod)
json = di.load('util.json')
commands = di.load('util.commands')

class Cosmetic(Cog):
    """Commands for some neat-o fun!
    Includes color changing and more.
    """

    def __init__(self, bot):
        self.al_aliases = [key for key in charsets]
        self.playing_anim = set()
        self.stop_anim = set()
        super().__init__(bot)

    @commands.command(aliases=['color', 'giveme', 'race'])
    async def role(self, role: str):
        """Set a public role on your account.
        Usage: role [role name]"""
        await self.bot.say('Role setting is not implemented yet!')

    @commands.command(pass_context=True)
Ejemplo n.º 5
0
"""Web dashboard."""
import os
import sys
import json
import aiohttp
from discord.ext import commands
import util.dynaimport as di
from .cog import Cog

japronto = di.load('japronto')
sanic = di.load('sanic')
response = di.load('sanic.response')
root_dir = os.path.dirname(os.path.abspath(sys.modules['__main__'].core_file))
web_root = os.path.join(root_dir, 'assets', 'web')


def webroot(f):
    return os.path.join(web_root, *f.split('/'))


class Web(Cog):
    """The awesome web dashboard."""
    def __init__(self, bot):
        super().__init__(bot)
        self.logger = self.logger.getChild('web')
        self.port = 8085
        self.host = '127.0.0.1'
        self.app = None
        self.server = None
        self.server_task = None
        if bot.user:
Ejemplo n.º 6
0
"""Definition of the bot's Cosmetic module.'"""
import asyncio
import random
import io
import aiohttp
import discord
import async_timeout
from discord.ext import commands
import util.json as json
from contextlib import suppress
from urllib.parse import urlencode
from .cog import Cog
from util.const import charsets, spinners, lvl_base
import util.dynaimport as di

imghdr = di.load('imghdr')


class Cosmetic(Cog):
    """Commands for some neat-o fun!
    Includes color changing and more.
    """
    def __init__(self, bot):
        self.playing_anim = set()
        self.stop_anim = set()
        self.al_aliases = charsets.keys()
        super().__init__(bot)

    @commands.command()
    @commands.check(commands.guild_only())
    async def emotes(self, ctx):
Ejemplo n.º 7
0
import asyncio
import io
import copy
import sys
import re
import textwrap
import random
from datetime import datetime
import aiohttp
import async_timeout
import discord
from util.commands.bot import ProContext, StringView
import util.commands as commands
from util.perms import echeck_perms
import util.dynaimport as di
pyscreenshot = di.load('pyscreenshot')
scr = di.load('util.screen')
have_pil = True
try:
    from PIL import ImageGrab
except ImportError:
    have_pil = False
from .cog import Cog


class SelfbotGoodies(Cog):
    """Some nice things for selfbot goodies."""
    def __init__(self, bot):
        self.start_time = datetime.now()
        self.web_render = None
        self.re_cache = {}
Ejemplo n.º 8
0
from datetime import datetime
from fnmatch import filter
from subprocess import run, PIPE
from concurrent.futures import ThreadPoolExecutor
from time import time
from core import set_cog
from convert_to_old_syntax import cur_dir
from util.perms import or_check_perms
from util.const import default_cogs, essential_cogs
from default_cogs.utils.dataIO import dataIO
from default_cogs.utils import checks
from default_cogs.utils.chat_formatting import pagify, box
import util.dynaimport as di
from .cog import Cog

asyncio = di.load('asyncio')
shutil = di.load('shutil')
discord = di.load('discord')
commands = di.load('util.commands')
os = di.load('os')

NUM_THREADS = 4
REPO_NONEX = 0x1
REPO_CLONE = 0x2
REPO_SAME = 0x4


class UpdateError(Exception):
    pass

Ejemplo n.º 9
0
from collections import OrderedDict
from datetime import datetime, timedelta
from fnmatch import filter
from io import BytesIO, StringIO
from util.const import _mention_pattern, _mentions_transforms, home_broadcast, absfmt, status_map, ch_fmt, code_stats, eval_blocked, v_level_map
from util.fake import FakeContextMember, FakeMessageMember
from util.func import bdel, async_encode as b_encode, async_decode as b_decode, smartjoin
from util.asizeof import asizeof
from util.perms import check_perms, or_check_perms
import util.dynaimport as di
from .cog import Cog

for mod in ['asyncio', 'random', 're', 'sys', 'time', 'textwrap', 'unicodedata',
            'aiohttp', 'async_timeout', 'discord', 'asteval', 'os', 'elizabeth',
            'qrcode', 'warnings', 'tesserocr', 'contextlib', 'base64', 'socket']:
    globals()[mod] = di.load(mod)
json = di.load('util.json')
commands = di.load('util.commands')
mclib = di.load('util.mclib')
xkcd = di.load('util.xkcd')

have_pil = True
try:
    from PIL import Image, ImageOps
except ImportError:
    have_pil = False

class Utility(Cog):
    """Random commands that can be useful here and there.
    Settings, properties, and other stuff can be found here.
    """
Ejemplo n.º 10
0
from collections import OrderedDict
from datetime import datetime, timedelta
from fnmatch import filter
from io import BytesIO, StringIO
from util.const import _mention_pattern, _mentions_transforms, home_broadcast, absfmt, status_map, ch_fmt, eval_blocked, v_level_map
from util.fake import FakeContextMember, FakeMessageMember
from util.func import bdel, encode as b_encode, decode as b_decode, smartjoin
from util.asizeof import asizeof
from util.perms import check_perms, or_check_perms
import util.dynaimport as di
from .cog import Cog

for mod in [
        'unicodedata', 'elizabeth', 'qrcode', 'warnings', 'tesserocr', 'base64'
]:
    globals()[mod] = di.load(mod)
mclib = di.load('util.mclib')
xkcd = di.load('util.xkcd')

have_pil = True
try:
    from PIL import Image, ImageOps
except ImportError:
    have_pil = False


class Utility(Cog):
    """Random commands that can be useful here and there.
    Settings, properties, and other stuff can be found here.
    """
    def __init__(self, bot):
Ejemplo n.º 11
0
"""The bot's Cozmo module. Only works with Cozmo!"""
import asyncio
import functools
import util.commands as commands
import util.dynaimport as di
cozmo = di.load('cozmo')
from .cog import Cog

class Cozmo(Cog):
    """Some commands to interface with Cozmo robots.
    You probably don't want this in the open.
    """

    def __init__(self, bot):
        self.sdk_conn = None
        self.robot = None
        try:
            self.default_connector = cozmo.run.FirstAvailableConnector()
        except ImportError:
            self.default_connector = None
        super().__init__(bot)

    async def check_conn(self, ctx=None):
        """Check the connection to Cozmo."""
        if not self.robot:
#            raise commands.ReturnError('{0.message.author.mention} **Not connected to Cozmo!**', ctx)
            await self.bot.say('Not connected to Cozmo!')
            raise commands.PassException()

    @commands.command()
    async def cspeak(self, *, text: str):