Beispiel #1
0
    def part(self, irc, msg, args, channel, reason):
        """[<channel>] [<reason>]

        Tells the bot to part the list of channels you give it.  <channel> is
        only necessary if you want the bot to part a channel other than the
        current channel.  If <reason> is specified, use it as the part
        message.  Otherwise, the default part message specified in
        supybot.plugins.Channel.partMsg will be used. No part message will be
        used if no default is configured.
        """
        channel = channel or msg.channel
        if not channel:
            irc.error(Raise=True)
        capability = ircdb.makeChannelCapability(channel, 'op')
        if not ircdb.checkCapabilities(msg.prefix, [capability, 'admin']):
            irc.errorNoCapability(capability, Raise=True)
        try:
            network = conf.supybot.networks.get(irc.network)
            network.channels().remove(channel)
        except KeyError:
            pass
        if channel not in irc.state.channels:
            irc.error(_('I\'m not in %s.') % channel, Raise=True)
        reason = (reason or self.registryValue("partMsg", channel, irc.network))
        reason = ircutils.standardSubstitute(irc, msg, reason)
        irc.queueMsg(ircmsgs.part(channel, reason))
        if msg.nick in irc.state.channels[channel].users:
            irc.noReply()
        else:
            irc.replySuccess()
Beispiel #2
0
    def part(self, irc, msg, args, channel, reason):
        """[<channel>] [<reason>]

        Tells the bot to part the list of channels you give it.  <channel> is
        only necessary if you want the bot to part a channel other than the
        current channel.  If <reason> is specified, use it as the part
        message.  Otherwise, the default part message specified in
        supybot.plugins.Channel.partMsg will be used. No part message will be
        used if no default is configured.
        """
        if channel is None:
            if irc.isChannel(msg.args[0]):
                channel = msg.args[0]
            else:
                irc.error(Raise=True)
        capability = ircdb.makeChannelCapability(channel, 'op')
        hostmask = irc.state.nickToHostmask(msg.nick)
        if not ircdb.checkCapabilities(hostmask, [capability, 'admin']):
            irc.errorNoCapability(capability, Raise=True)
        try:
            network = conf.supybot.networks.get(irc.network)
            network.channels().remove(channel)
        except KeyError:
            pass
        if channel not in irc.state.channels:
            irc.error(_('I\'m not in %s.') % channel, Raise=True)
        reason = (reason or self.registryValue("partMsg", channel))
        reason = ircutils.standardSubstitute(irc, msg, reason)
        irc.queueMsg(ircmsgs.part(channel, reason))
        if msg.nick in irc.state.channels[channel].users:
            irc.noReply()
        else:
            irc.replySuccess()
    def part(self, irc, msg, args, channel, reason):
        """[<channel>] [<reason>]

        Tells the bot to part the list of channels you give it.  <channel> is
        only necessary if you want the bot to part a channel other than the
        current channel.  If <reason> is specified, use it as the part
        message.
        """
        if channel is None:
            if irc.isChannel(msg.args[0]):
                channel = msg.args[0]
            else:
                irc.error(Raise=True)
        try:
            network = conf.supybot.networks.get(irc.network)
            network.channels().remove(channel)
        except KeyError:
            pass
        if channel not in irc.state.channels:
            irc.error(_('I\'m not in %s.') % channel, Raise=True)
        irc.queueMsg(ircmsgs.part(channel, reason or msg.nick))
        if msg.nick in irc.state.channels[channel].users:
            irc.noReply()
        else:
            irc.replySuccess()
Beispiel #4
0
    def part(self, irc, msg, args, channel, reason):
        """[<channel>] [<reason>]

        Tells the bot to part the list of channels you give it.  <channel> is
        only necessary if you want the bot to part a channel other than the
        current channel.  If <reason> is specified, use it as the part
        message.
        """
        if channel is None:
            if irc.isChannel(msg.args[0]):
                channel = msg.args[0]
            else:
                irc.error(Raise=True)
        try:
            network = conf.supybot.networks.get(irc.network)
            network.channels().remove(channel)
        except KeyError:
            pass
        if channel not in irc.state.channels:
            irc.error('I\'m not in %s.' % channel, Raise=True)
        irc.queueMsg(ircmsgs.part(channel, reason or msg.nick))
        if msg.nick in irc.state.channels[channel].users:
            irc.noReply()
        else:
            irc.replySuccess()
Beispiel #5
0
    def cycle(self, irc, msg, args, channel):
        """[<channel>]

        If you have the #channel,op capability, this will cause the bot to
        "cycle", or PART and then JOIN the channel. <channel> is only necessary
        if the message isn't sent in the channel itself.
        """
        self._sendMsg(irc, ircmsgs.part(channel, msg.nick))
        networkGroup = conf.supybot.networks.get(irc.network)
        self._sendMsg(irc, networkGroup.channels.join(channel))
Beispiel #6
0
    def cycle(self, irc, msg, args, channel):
        """[<channel>]

        If you have the #channel,op capability, this will cause the bot to
        "cycle", or PART and then JOIN the channel. <channel> is only necessary
        if the message isn't sent in the channel itself.
        """
        self._sendMsg(irc, ircmsgs.part(channel, msg.nick))
        networkGroup = conf.supybot.networks.get(irc.network)
        self._sendMsg(irc, networkGroup.channels.join(channel))
Beispiel #7
0
    def part(self, irc, msg, args, channel):
        """<channel>

        Ceases relaying between the channel <channel> on all networks.  The bot
        will part from the channel on all networks in which it is on the
        channel.
        """
        self.registryValue('channels').discard(channel)
        for otherIrc in world.ircs:
            if channel in otherIrc.state.channels:
                otherIrc.queueMsg(ircmsgs.part(channel))
        irc.replySuccess()
Beispiel #8
0
 def testOpTrack(self):
     cb = self.getCallback()
     self.assertEqual(cb.opped['#test'], False)
     self.op()
     self.assertEqual(cb.opped['#test'], True)
     self.deop()
     self.assertEqual(cb.opped['#test'], False)
     self.op()
     self.irc.feedMsg(ircmsgs.part('#test', prefix=self.prefix))
     self.irc.feedMsg(ircmsgs.join('#test', prefix=self.prefix))
     self.irc.takeMsg() # MODE msg
     self.irc.takeMsg() # WHO msg
     self.assertEqual(cb.opped['#test'], False)
Beispiel #9
0
    def cycle(self, irc, msg, args, channel, reason):
        """[<channel>]

        If you have the #channel,op capability, this will cause the bot to
        "cycle", or PART and then JOIN the channel. <channel> is only necessary
        if the message isn't sent in the channel itself. If <reason> is not
        specified, the default part message specified in
        supybot.plugins.Channel.partMsg will be used. No part message will be
        used if neither a cycle reason nor a default part message is given.
        """
        reason = (reason or self.registryValue("partMsg", channel))
        reason = ircutils.standardSubstitute(irc, msg, reason)
        self._sendMsg(irc, ircmsgs.part(channel, reason))
        networkGroup = conf.supybot.networks.get(irc.network)
        self._sendMsg(irc, networkGroup.channels.join(channel))
Beispiel #10
0
    def cycle(self, irc, msg, args, channel, reason):
        """[<channel>] [<reason>]

        If you have the #channel,op capability, this will cause the bot to
        "cycle", or PART and then JOIN the channel. <channel> is only necessary
        if the message isn't sent in the channel itself. If <reason> is not
        specified, the default part message specified in
        supybot.plugins.Channel.partMsg will be used. No part message will be
        used if neither a cycle reason nor a default part message is given.
        """
        reason = (reason or self.registryValue("partMsg", channel, irc.network))
        reason = ircutils.standardSubstitute(irc, msg, reason)
        self._sendMsg(irc, ircmsgs.part(channel, reason))
        networkGroup = conf.supybot.networks.get(irc.network)
        self._sendMsg(irc, networkGroup.channels.join(channel))
Beispiel #11
0
 def feedBan(self, hostmask, prefix='', channel=None, mode='b'):
     if not channel:
         channel = self.channel
     if not prefix:
         prefix = '[email protected]'
     if mode == 'b':
         ban = ircmsgs.ban(channel, hostmask, prefix=prefix)
     elif mode == 'q':
         ban = quiet(channel, hostmask, prefix=prefix)
     elif mode == 'k':
         ban = ircmsgs.kick(channel, hostmask, s='kthxbye!', prefix=prefix)
     elif mode == 'p':
         ban = ircmsgs.part(channel, prefix=hostmask,
                 s='requested by %s (kthxbye!)' %prefix[:prefix.find('!')])
     self.irc.feedMsg(ban)
     return ban
Beispiel #12
0
 def feedBan(self, hostmask, prefix='', channel=None, mode='b'):
     if not channel:
         channel = self.channel
     if not prefix:
         prefix = '[email protected]'
     if mode == 'b':
         ban = ircmsgs.ban(channel, hostmask, prefix=prefix)
     elif mode == 'q':
         ban = quiet(channel, hostmask, prefix=prefix)
     elif mode == 'k':
         ban = ircmsgs.kick(channel, hostmask, s='kthxbye!', prefix=prefix)
     elif mode == 'p':
         ban = ircmsgs.part(channel,
                            prefix=hostmask,
                            s='requested by %s (kthxbye!)' %
                            prefix[:prefix.find('!')])
     self.irc.feedMsg(ban)
     return ban
Beispiel #13
0
 def _track_time_and_part(self, irc, channel, nick):
     reason = "Your time's up, for new request please contact my owner."
     irc.queueMsg(ircmsgs.kick(channel, nick, reason))
     irc.queueMsg(ircmsgs.part(channel))
 def testPart(self):
     self.prefix = "[email protected]"
     self.assertRegexp("gpg ident", "are identified")
     self.irc.feedMsg(msg=ircmsgs.part("#test", prefix=self.prefix))
     self.assertRegexp("gpg ident", "not identified")
Beispiel #15
0
 def partChannel(self, irc, channel):
     if not self.botInChannel(irc, channel):
         logger.info('already parted '+channel)
     else:
         logger.info('part channel '+channel)
         irc.queueMsg(ircmsgs.part(channel,'Game stopped'))
 def testPart(self):
     self.prefix = '[email protected]'
     self.assertRegexp('gpg ident', 'are identified')
     self.irc.feedMsg(msg=ircmsgs.part("#test", prefix=self.prefix))
     self.assertRegexp('gpg ident', 'not identified')
Beispiel #17
0
 def testPart(self):
     self.prefix = '[email protected]'
     self.assertRegexp('gpg ident', 'are identified')
     self.irc.feedMsg(msg=ircmsgs.part("#test", prefix=self.prefix))
     self.assertRegexp('gpg ident', 'not identified')