コード例 #1
0
    def __init__(self):
        _intents = discord.Intents.none()
        _intents.members = True
        _intents.guilds = True
        _intents.emojis = True
        _intents.voice_states = True
        _intents.messages = True
        _intents.reactions = True

        _allowed_mentions = discord.AllowedMentions.none()
        _allowed_mentions.users = True

        super().__init__(command_prefix=get_prefix,
                         intents=_intents,
                         allowed_mentions=_allowed_mentions)
        run = self.loop.run_until_complete

        self.pool = run(create_pool(config.postgres, loop=self.loop))
        self.session = run(create_session(self.http.connector, loop=self.loop))
        self.dagpi = asyncdagpi.Client(config.dagpi,
                                       loop=self.loop,
                                       session=self.session)

        self.logger = logging.getLogger('pearl')
        self.all_extensions = []

        for root, _, items in os.walk('extensions'):
            files = filter(lambda f: f.endswith('.py'), items)

            for f in files:
                file_name, _ = os.path.splitext(f)
                path = os.path.join(root, file_name)

                self.all_extensions.append(re.sub(r'\\|\/', '.', path))
コード例 #2
0
async def do_dagpi_stuff(ctx: utils.CustomContext, user: discord.Member,
                         feature: asyncdagpi.ImageFeatures) -> discord.File:
    dagpi = asyncdagpi.Client(ctx.bot.settings["keys"]["dagpi"])
    url = str(user.avatar_url_as(static_format="png"))
    img = await dagpi.image_process(feature, url)
    img_file = discord.File(fp=img.image, filename=f"image.{img.format}")
    await dagpi.close()
    return img_file
コード例 #3
0
ファイル: extra.py プロジェクト: MrKomodoDragon/JDBot
async def headpat_converter2(self, url, ctx):
    dagpi_client = asyncdagpi.Client(os.environ["dagpi_key"],
                                     session=self.client.session)
    image = await dagpi_client.image_process(asyncdagpi.ImageFeatures.petpet(),
                                             str(url))
    file = discord.File(fp=image.image, filename=f"headpat.{image.format}")
    embed = discord.Embed(color=random.randint(0, 16777215))
    embed.set_author(name=f"Headpat gif requested by {ctx.author}",
                     icon_url=(ctx.author.avatar_url))
    embed.set_image(url=f"attachment://headpat.{image.format}")
    embed.set_footer(text="powered by dagpi")
    await ctx.send(file=file, embed=embed)
コード例 #4
0
 async def setup_hook(self) -> None:
     self.session: ClientSession = ClientSession()
     self.cache: Cache = Cache(self)
     self.pool: asyncpg.Pool = await asyncpg.create_pool(
         **self.settings["postgresql"])
     self.topgg: DBLClient = DBLClient(self,
                                       self.api["TopGG"],
                                       autopost_interval=None,
                                       session=self.session)
     self.topgg_webhook: WebhookManager = WebhookManager(self).dbl_webhook(
         "/dbl", self.api["TopGGWH"])
     self.gist: asyncgist.Client = asyncgist.Client(self.api["GitHub"],
                                                    self.session)
     self.sr: sr_api.Client = sr_api.Client()
     self.dagpi: asyncdagpi.Client = asyncdagpi.Client(self.api["DagpiAPI"],
                                                       session=self.session)
     self.myst: mystbin.Client = mystbin.Client(session=self.session)
     self.loop.create_task(self.cache.populate_cache())
     self.loop.create_task(self.load_extensions())
     self.loop.create_task(self.start_nodes())
     self.loop.create_task(self.find_restart_message())
     self.topgg_webhook.run(8025)
コード例 #5
0
ファイル: subclasses.py プロジェクト: ImVaskel/harley-bot
    def __init__(self, **options):
        super().__init__(
            get_prefix,
            intents=intent,
            allowed_mentions=discord.AllowedMentions.none(),
            activity=discord.Activity(type=ActivityType.listening,
                                      name="@Harley"),
            **options,
        )

        self._logger = logging.getLogger("Harley")

        self._BotBase__cogs = commands.core._CaseInsensitiveDict()
        self.usage = 0
        self.cache = {}
        self.blacklisted = {}
        self.start_time = datetime.utcnow()
        self.edit_mapping: Dict[Message, Message] = CappedDict(max_size=100)

        self.config = json.load(open("config.json"))
        self.custom_emojis = json.load(open("emojis.json"))

        self._session = aiohttp.ClientSession(loop=self.loop)

        self.ipc = ipc.Server(self, self.config.get("ipc_key"))
        self.load_extension("cogs.ipc")

        self.db = self.loop.run_until_complete(
            asyncpg.create_pool(**self.config["db"]))

        self._dagpi = asyncdagpi.Client(self.config["dagpi"])

        self.cache.update({"default": {"prefix": self.config["prefix"]}})

        self.load_extension("utils.utils")

        self.loop.run_until_complete(self._ainit())

        self.load_cogs()
コード例 #6
0
 def __init__(self):
     intents = discord.Intents.default()
     intents.members = True
     intents.presences = True
     super().__init__(
         command_prefix=self.get_prefix,
         case_insensitive=True,
         intents=intents,
         owner_ids={809587169520910346},
         description=
         '```py\n  ____      _       \n / ___|   _| |_ ___ \n| |  | | | | __/ _ \n| |__| |_| | ||  __/\n \____\__,_|\__\___|```'
     )
     self._BotBase__cogs = commands.core._CaseInsensitiveDict()
     self.author_id = 809587169520910346
     self.dagpi = asyncdagpi.Client(os.environ['dagpikey'])
     self.session = aiohttp.ClientSession()
     self.embed_color = 0x9c5cb4  #0x1E90FF
     self.mongo = motor.motor_asyncio.AsyncIOMotorClient(
         os.environ['MongoDB'])
     self.data = self.mongo.data
     self.default_prefix = 'c//'
     self.prefixes = {}
コード例 #7
0
ファイル: fun.py プロジェクト: pvffyn/wakeful
from utils.errors import TooLong
from utils.checks import gameRunning
import discord, io, asyncdagpi, asyncio, datetime, string, random, json, wonderwords, typing
from discord.ext import commands
from fuzzywuzzy import fuzz
from gtts import gTTS
from jishaku.functools import executor_function
from utils.get import *
from utils.functions import *
from akinator.async_aki import Akinator
from cogs.music import is_vc
from cogs.utility import cleanup, make

dagpi = asyncdagpi.Client(get_config("DAGPI"))
akin = Akinator()


@executor_function
def do_tts(message):
    array = io.BytesIO()
    tts = gTTS(text=message, lang="en")
    tts.write_to_fp(array)
    array.seek(0)
    return array


@executor_function
def vctts(message, path):
    res = gTTS(text=message, lang="en")
    res.save(f"{path.name}/file.wav")
コード例 #8
0
ファイル: subclasses.py プロジェクト: JoJoOnDuty/travis-bott
    def __init__(self, *args, **kwargs):
        super().__init__(get_prefix, *args, **kwargs)

        # Prep for embed colour stuff. (Thank you to z03h for this :))
        c = dt.utcnow()
        hours, minutes, seconds = 0, 5, 0

        self.duration = (3600 * hours + 60 * minutes + seconds)
        self.embed_start_dt = dt(c.year, c.month, c.day)
        self.colours = [
            (210, 31, 255),
            (232, 132, 255),
            (216, 192, 255),
            (149, 182, 255),
            (93, 128, 255),
            (128, 84, 255),
            (169, 74, 255),
        ]
        self.per_colour = self.duration // len(self.colours)

        # Vars needed for some functionality.
        self.settings = utils.Settings("config.toml")
        self.maintenance_mode = self.settings["misc"]["maintenance_mode"]
        self.start_time = dt.now()
        self.support_url = "https://discord.gg/tKZbxAF"
        self.invite_url = "https://kal-byte.co.uk/invite/706530005169209386/1580592374"
        self.cmd_usage = 0
        self.announcement = {"title": None, "message": None}

        # Things for cache
        self.verification_config = {}
        self.giveaway_roles = {}
        self.blacklist = {}
        self.ctx_cache = {}
        self.config = {}

        # Stuff that requires the bots loop
        self.loop = asyncio.get_event_loop()
        self.pool = self.loop.run_until_complete(
            asyncpg.create_pool(
                **self.settings["database"]["main"]
                if os.name != "nt" else self.settings["database"]["beta"]))
        self.session = aiohttp.ClientSession(loop=self.loop)

        # Checks to disable functionality for certain things.
        self.add_check(self.command_check)
        self.add_check(self.blacklist_check)

        # Webhooks
        self.error_webhook = discord.Webhook.from_url(
            self.settings["misc"]["error_webhook"],
            adapter=discord.AsyncWebhookAdapter(self.session))
        self.guild_webhook = discord.Webhook.from_url(
            self.settings["misc"]["guild_webhook"],
            adapter=discord.AsyncWebhookAdapter(self.session))

        # Some tasks that prep the bot to be used fully.
        self.loop.create_task(self.do_prep())
        self.loop.create_task(self.chunk_all_guilds())

        # API Wrappers
        self.zane = aiozaneapi.Client(self.settings["keys"]["zane_api"])
        self.dagpi = asyncdagpi.Client(self.settings["keys"]["dagpi"])