Exemplo n.º 1
0
 def __init__(self, bot):
     self.bot = bot
     self.station_list = bot.station_list
     self.controllers = {}
     if not hasattr(bot, 'wavelink'):
         self.bot.wavelink = wavelink.Client(bot=self.bot)
     self.bot.loop.create_task(self.start_nodes())
Exemplo n.º 2
0
    def __init__(self, bot):
        self.bot = bot

        if not hasattr(self.bot, "wavelink"):
            self.bot.wavelink = wavelink.Client(bot=bot, session=bot.session)

        bot.loop.create_task(self.start_nodes())
Exemplo n.º 3
0
    def __init__(self, bot: commands.AutoShardedBot):
        self.bot = bot
        self.name = "MusicV3"
        if not hasattr(bot, 'wavelink'):
            bot.wavelink = wavelink.Client(bot=bot)

        bot.loop.create_task(self.start_nodes())
Exemplo n.º 4
0
    def __init__(self, instance_id):
        self.prefixes = environ['PREFIXES'].split(', ')
        super().__init__(command_prefix=custom_prefix,
                         owner_id=int(environ['OWNER_ID']),
                         case_insensitive=True,
                         help_command=None,
                         shard_count=1,
                         shard_ids=[0],
                         guild_subscriptions=False,
                         max_messages=101,
                         activity=Game(f'Prefix: {self.prefixes[0]}'))

        self.db = db
        self._bans = BanManager(db.bans)
        self._guilds = GuildManager(db.guilds)
        self._shards = ShardManager(db.shards)
        self.log = log
        self.emoji = emojis
        self.instance_id = instance_id
        self.color = [0xd74d1e, 0xb13105]
        self.loaded = False
        self.launched_shards = []
        self.started_at = datetime.utcnow()
        self.wavelink = wavelink.Client(self)
        self.guild_blacklist = set()
        self.user_blacklist = set()
        self.invoked_commands = 0
        self.read_messages = 0
        self.played_tracks = 0
        self._prefixes = {}
Exemplo n.º 5
0
    def __init__(self):
        super().__init__(command_prefix=custom_prefix,
                         owner_id=int(environ['OWNER_ID']),
                         case_insensitive=True,
                         help_command=None,
                         max_messages=None,
                         fetch_offline_members=platform.machine() != 'armv7l',
                         activity=Game(f'Loading...'))

        self.db = DatabaseManager(name=environ['DATABASE_NAME'],
                                  uri=environ['DATABASE_URI'],
                                  bot=self)
        self.i18n = i18n.I18N(source='pt_BR')
        self.log = log
        self.emoji = emojis
        self.color = DEFAULT_EMBED_COLORS
        self.loaded = False
        self.launched_shards = []
        self.started_at = datetime.utcnow()
        self.wavelink = wavelink.Client(self)
        self.guild_blacklist = set()
        self.user_blacklist = set()
        self.invoked_commands = 0
        self.read_messages = 0
        self.played_tracks = 0
        self.prefixes = environ['PREFIXES'].split(', ')
        self._prefixes = {}
        self._message_logs = set()
Exemplo n.º 6
0
    def __init__(self, client):
        self.client = client

        if not hasattr(client, 'wavelink'):
            self.client.wavelink = wavelink.Client(self.client)

        self.client.loop.create_task(self.start_nodes())
Exemplo n.º 7
0
    def __init__(self, bot: commands.Bot):
        self.bot = bot

        if not hasattr(bot, "wavelink"):
            bot.wavelink = wavelink.Client(bot=bot)

        bot.loop.create_task(self.start_nodes())
Exemplo n.º 8
0
    def __init__(self, bot):
        self.bot = bot

        if not hasattr(bot, 'wavelink'):
            self.bot.wavelink = wavelink.Client(bot=self.bot)

        self.bot.loop.create_task(self.start_nodes())
Exemplo n.º 9
0
    def __init__(self, bot):
        super().__init__(bot)
        self.controllers = {}
        self.bot._wavelink = wavelink.Client(bot=self.bot)
        _path = self.bot._config["lavalink_path"]
        _args = self.bot._config["lavalink_args"]
        self._lavalink = subprocess.Popen(
            split(f"java -jar ./Lavalink.jar {_args}"),
            shell=False,
            cwd=_path,
            stdout=subprocess.PIPE,
            universal_newlines=True)
        self._searchresults = {}

        self.bot.add_listener(self.listen_searchresults, "on_message")

        rc = 0
        while True:
            stdout = self._lavalink.stdout.readline()
            if stdout == "" and rc is not None:
                break
            if LAVALINK_READY.search(stdout):
                self.bot.loop.create_task(self.start_nodes())
                break
            rc = self._lavalink.poll()
Exemplo n.º 10
0
    def __init__(self, bot: Union[commands.Bot, commands.AutoShardedBot]):
        self.bot = bot

        if not hasattr(bot, 'wavelink'):
            self.bot.wavelink = wavelink.Client(bot)

        bot.loop.create_task(self.initiate_nodes())
Exemplo n.º 11
0
    def __init__(self,
                 ConfigObj: Config,
                 *,
                 description: str = None,
                 DeleteTime: float = 10.0,
                 beta_indicator: str = "beta",
                 **options):
        """Intialise the bot.
        
            Require a config object with info and credentials.

        Args:
            ConfigObj ([Config]):
                Object holding all info and credentials the bot requires
        """
        # FORMAT:: [f"{Entity} for {Reason}"]
        # NOTE:: [To Append credits from setup functions]
        self.credits: List[Union[Dict[str], str]] = [{
            "Entity":
            "TEEN-BOOM",
            "Reason":
            "Authoring the project"
        }, {
            "Entity":
            "Anvit",
            "Reason":
            "Testing the bot"
        }, {
            "Entity": "Vlad Carstocea",
            "Reason": "Contribution"
        }]
        self._initialized = asyncio.Event()
        self.beta_indicator: str = beta_indicator
        super().__init__(command_prefix=_prefix_callable,
                         description=description,
                         **options)
        # -- |For testing...|
        self.is_beta: bool = False

        self.DeleteTime: float = DeleteTime  # DESC:: [The time to wait before deleting message]
        self.config: Config = ConfigObj
        self.GuildInfo = {}
        self.loop.create_task(self.__ainit__(
        ))  # -- Initialize the asyncpg pool when loop is started
        self.config.DB()  # -- Initialize psycopg2 connection
        # TODO:: [Shorten code and remove unnecessary attrs]
        self.token = self.config.token
        self.dburl = self.config.dburl
        self.rid = self.config.rid
        self.wavepass = self.config.wavepass
        self.rsecret = self.config.rsecret
        self.cur = self.config.cur
        self.conn = self.config.conn

        self.wavelink: wavelink.Client = wavelink.Client(bot=self)
        self.reddit_client: praw.Reddit = praw.Reddit(
            client_id=self.rid,
            client_secret=self.rsecret,
            user_agent="Small-post-seacrcher")
Exemplo n.º 12
0
    def __init__(self, bot: Union[commands.Bot, commands.AutoShardedBot]):
        self.bot = bot
        if not hasattr(bot, 'deadvcs'):
            self.bot.deadvcs = []
        self.deadvccheck.start()

        if not hasattr(bot, 'wavelink'):
            self.bot.wavelink = wavelink.Client(bot)
Exemplo n.º 13
0
def setup(bot: commands.Bot):
    if not hasattr(bot, '_wavelink'):
        bot._wavelink = wavelink.Client(bot=bot)

    if not hasattr(bot, '_player_sessions'):
        bot._player_sessions = dict()

    bot.add_cog(Player(bot))
Exemplo n.º 14
0
    def __init__(self, bot):
        self.bot = bot
        self.queue = defaultdict(lambda: [])  # Redis is not needed because why

        if not hasattr(self.bot, "wavelink"):
            self.bot.wavelink = wavelink.Client(bot=self.bot)

        self.bot.loop.create_task(self.connect())
Exemplo n.º 15
0
    def __init__(self, bot: commands.Bot):
        self.bot = bot
        self.players = {}
        if not hasattr(bot, 'wavelink'):
            self.bot.wavelink = wavelink.Client(bot=bot)

        bot.loop.create_task(self.initiate_nodes())
        bot.loop.create_task(self.set_noafks())
Exemplo n.º 16
0
    def __init__(self, bot):
        self.bot = bot
        self.music_prefix = "mp:idle2:" if not bot.config.is_beta else "mp:idlebeta2:"

        if not hasattr(self.bot, "wavelink"):
            self.bot.wavelink = wavelink.Client(self.bot)

        self.bot.loop.create_task(self.connect())
Exemplo n.º 17
0
    def __init__(self, bot: commands.Bot):
        """Prepare cog - season it salt, pepper."""
        self.bot = bot

        if not hasattr(bot, 'wavelink'):
            bot.wavelink = wavelink.Client(bot=bot)

        bot.loop.create_task(self.start_nodes())
Exemplo n.º 18
0
    def __init__(self, bot):
        self.bot = bot
        self.voice_states = {}
        self.desc = "Revamped music player using lavalink + wavelink."

        if not hasattr(bot, 'wavelink'):
            self.bot.wavelink = wavelink.Client(bot=self.bot)

        self.bot.loop.create_task(self.start_nodes())
Exemplo n.º 19
0
    def __init__(self, bot: commands.Bot):
        self.bot = bot
        spotify_credentials = bot.consts["spotify_api"]
        self.spotify = Spotify(spotify_credentials)

        if not hasattr(bot, 'wavelink'):
            bot.wavelink = wavelink.Client(bot=bot)

        bot.loop.create_task(self.start_nodes())
Exemplo n.º 20
0
    def __init__(self, bot: Photon):
        self.bot = bot
        self._controllers = {}
        self.node_online = False

        if not hasattr(bot, "wavelink"):
            self.bot.wavelink = wavelink.Client(bot=self.bot)

        self.bot.loop.create_task(self.start_nodes())
Exemplo n.º 21
0
    def __init__(self, bot):
        self.bot = bot

        if not hasattr(
                bot, 'wavelink'
        ):  # This ensures the client isn't overwritten during cog reloads.
            self.bot.wavelink: wavelink.Client = wavelink.Client(bot=self.bot)

        self.bot.loop.create_task(self.start_nodes())
Exemplo n.º 22
0
    def __init__(self, bot):
        self.bot = bot
        self.log = logging.getLogger(__name__)
        self.bot.loop.create_task(self.update_cache())

        # Avoids overwriting the wavelink client on cog reload
        if not hasattr(bot, "wavelink"):
            self.bot.wavelink = wavelink.Client(bot=self.bot)

        self.bot.loop.create_task(self.start_node())
Exemplo n.º 23
0
    def __init__(self, *args, **kwargs) -> None:
        super().__init__(*args, **kwargs)
        self.session = aiohttp.ClientSession()
        self.wavelink = wavelink.Client(bot=self)

        # Create tasks to setup other libraries.
        self.loop.create_task(Mangadex.setup(session=self.session))
        self.loop.create_task(Wolfram.setup(session=self.session, signing=True))
        self.loop.create_task(Jisho.setup(session=self.session))
        self.loop.create_task(Wikipedia.setup(session=self.session))
Exemplo n.º 24
0
    def __init__(self, bot):
        self.bot = bot
        self.controllers = {}

        self.votes = {}

        self.playlist_cache = {}

        if not hasattr(bot, 'wavelink'):
            self.bot.wavelink = wavelink.Client(bot=self.bot)

        self.bot.loop.create_task(self.start_nodes())
Exemplo n.º 25
0
 def __init__(self, bot):
     self.bot = bot
     self.wavelink = wavelink.Client(bot=bot)
     self.bot.loop.create_task(self.start_nodes())
     self.initial_connect_embed = None
     self.search_loading_embed = None
     self.current_volume = DEFAULT_VOLUME
     self.cooldown = 10
     self.cooldown_lock = False
     self.cooldown_tries = 0
     self.music_channel = self.bot.get_channel(Configs.MUSIC_CMD_CHANNEL)
     self.song_index = 0  # used to play songs directly by no. This variable should be managed manually.
Exemplo n.º 26
0
    def __init__(self, bot):
        self.bot = bot
        self.controllers = {}

        self.help_icon = '<:deafened:686251889519493250>'
        self.big_icon = ''
        self._last_command_channel = {}

        if not hasattr(bot, 'wavelink'):
            bot.wavelink = wavelink.Client(bot=self.bot)

        self.bot.loop.create_task(self.initialize_nodes())
Exemplo n.º 27
0
    def __init__(self, bot: commands.Bot):
        self.bot = bot

        if not hasattr(bot, 'wavelink'):
            bot.wavelink = wavelink.Client(bot=bot)

            bot.loop.create_task(self.start_nodes())

        if self.bot.use_web:

            @self.bot.app.route("/player")
            async def music_player():
                return "This is where the music player *would* be."
Exemplo n.º 28
0
    def __init__(self, bot: commands.Bot):
        """
        The constructor for the Track class.

        Parameters:
            bot (commands.Bot): The Discord bot.
        """

        self.bot = bot

        if not hasattr(bot, 'wavelink'):
            bot.wavelink = wavelink.Client(bot=bot)

        bot.loop.create_task(self.start_nodes())
Exemplo n.º 29
0
	def __init__(self, bot, settings):
		self.bot      = bot
		self.settings = settings
		self.queue    = {}
		self.skips    = {}
		self.vol      = {}
		self.loop     = {}
		self.data     = {}
		global Utils, DisplayName
		Utils = self.bot.get_cog("Utils")
		DisplayName = self.bot.get_cog("DisplayName")
		# Setup Wavelink
		if not hasattr(self.bot,'wavelink'): self.bot.wavelink = wavelink.Client(bot=self.bot)
		self.bot.loop.create_task(self.start_nodes())
Exemplo n.º 30
0
    def __init__(self, bot):
        self.bot = bot
        self.queue = defaultdict(lambda: [])  # Redis is not needed because why

        if (self.bot.config.music.query_endpoint is None
                or self.bot.config.music.resolve_endpoint is None):
            bot.logger.warning(
                "music endpoints not set, unloading music cog...")
            bot.unload_extension("cogs.music")

        if not hasattr(self.bot, "wavelink"):
            self.bot.wavelink = wavelink.Client(bot=self.bot)

        self.bot.loop.create_task(self.connect())