Ejemplo n.º 1
0
    async def rift_web(self, ctx: commands.Context, *rifts: Messageable):
        """
        Opens up all possible connections between this channel and the specified rifts.

        See the helptext of `[p]rift link` for more info.
        """
        if not rifts:
            raise commands.UserInputError()
        unique_rifts: List[Messageable] = deduplicate_iterables(rifts)
        source = ctx.channel if ctx.guild else ctx.author
        no_notify = await self.bot.is_owner(
            ctx.author) and not await self.config.notify()
        self.rifts.add_web(source, *unique_rifts)
        humanized = humanize_list(list(map(str, (source, *unique_rifts))))
        for rift in unique_rifts:
            if no_notify and getattr(rift, "guild", None):
                mem = rift.guild.get_member(ctx.author.id)
                if mem and rift.permissions_for(mem).read_messages:
                    notify = False
                else:
                    notify = True
            else:
                notify = True
            if notify:
                asyncio.ensure_future(
                    rift.send(
                        _("{} has opened a web to here, connecting you to {}."
                          ).format(ctx.author, humanized)))
        await ctx.send(
            _("A web has been opened to {}! Everything you say will be relayed there.\n"
              "Responses will be relayed here.\n"
              "Type `exit` to quit.").format(
                  humanize_list(list(map(str, unique_rifts)))))
Ejemplo n.º 2
0
    async def rift_link(self,
                        ctx: commands.Context,
                        one_way: Optional[bool] = None,
                        *rifts: Messageable):
        """
        Links this channel to the specified destination(s).

        Anything anyone says in this channel will be forwarded.
        All replies will be relayed back here.
        """
        if not rifts:
            raise commands.UserInputError()
        unique_rifts: List[Messageable] = deduplicate_iterables(rifts)
        source = ctx.channel if ctx.guild else ctx.author
        no_notify = await self.bot.is_owner(
            ctx.author) and not await self.config.notify()
        for rift in unique_rifts:
            if (no_notify and getattr(rift, "guild", None)
                    and not isinstance(rift, discord.abc.User)):
                mem = rift.guild.get_member(ctx.author.id)
                if mem and rift.permissions_for(mem).read_messages:
                    notify = False
                else:
                    notify = True
            else:
                notify = True
            self.rifts.add_vectors(source, rift, two_way=not one_way)
            if notify:
                asyncio.ensure_future(rift.send(_("").format()))
        await ctx.send(
            _("A link has been created to {}! Everything said in this channel will be relayed there.\n"
              "Responses will be relayed here.\n"
              "Type `exit` to quit.").format(
                  humanize_list(list(map(str, unique_rifts)))))
Ejemplo n.º 3
0
    async def send(self, ctx: commands.Context, *rifts: Messageable):
        """
        Send a message to the specified destinations.

        Editing or deleting the message you send will still forward
        to the bot's reposts, as in normal rifts.
        """
        if not rifts:
            raise commands.UserInputError()
        unique_rifts = deduplicate_iterables(rifts)
        await ctx.send("What would you like to say?")
        p = MessagePredicate.same_context(ctx=ctx)
        message = await ctx.bot.wait_for("message", check=p)
        await self._send(message, unique_rifts)
Ejemplo n.º 4
0
    async def _unset(
        self,
        ctx: commands.GuildContext,
        scope: Optional[Union[discord.CategoryChannel, GuildVoice]],
        *settings: AsCFIdentifier,
    ):
        """
        Unset various settings, causing them to fall back to the outer scope.

        `scope` is the voice channel or category that you wish to change;
        leave it empty to manage guild-wide settings.
        Unset guild-wide settings tell the bot to take no action.

        See `[p]help invoice set` for info on the various settings available.
        """
        if invalid := set(settings).difference(
                Settings.__annotations__.keys()):
            raise commands.UserInputError("Invalid settings: " +
                                          humanize_list(list(invalid)))
Ejemplo n.º 5
0
    async def rift_open(
        self, ctx: commands.Context, one_way: Optional[bool] = None, *rifts: Messageable
    ):
        """
        Opens a rift to the specified destination(s).

        Only your messages will be forwarded to the specified destinations,
        and all replies will be sent back to you.
        """
        if not rifts:
            raise commands.UserInputError()
        unique_rifts: List[Messageable] = deduplicate_iterables(rifts)
        source = Limited(message=ctx.message) if ctx.guild else ctx.author
        no_notify = await self.bot.is_owner(ctx.author) and not await self.config.notify()
        for rift in unique_rifts:
            if (
                no_notify
                and getattr(rift, "guild", None)
                and not isinstance(rift, discord.abc.User)
            ):
                mem = rift.guild.get_member(ctx.author.id)
                if mem and rift.permissions_for(mem).read_messages:
                    notify = False
                else:
                    notify = True
            else:
                notify = True
            self.rifts.add_vectors(source, rift, two_way=not one_way)
            if notify:
                asyncio.ensure_future(
                    rift.send(
                        _("{} has opened a rift to here from {}.").format(ctx.author, ctx.channel)
                    )
                )
        await ctx.send(
            _(
                "A rift has been opened to {}! Everything you say will be relayed there.\n"
                "Responses will be relayed here.\n"
                "Type `exit` to quit."
            ).format(humanize_list(list(map(str, unique_rifts))))
        )