def _checkPlayer(self, irc, msg, new=0):
            gameChan = self.gameChannel
            if (msg.args[0] != self.gameChannel):
                if msg.nick in irc.state.channels[gameChan].users:
                    irc.error((
                        "That command cannot be sent in this channel. "
                        "Please try again in {0}").format(gameChan))
                else:
                    irc.error(
                        "You need to join {0} and use that command there.".format(gameChan))
                    irc.queueMsg(ircmsgs.invite(msg.nick, gameChan))
                return None

            try:
                player = str(ircdb.users.getUser(msg.prefix))
                player = player.split("name = \"")[1].split("\", ")[0]
            except KeyError:
                irc.errorNotRegistered()

            try:
                test = self.playerData[player]
            except:
                if new is 0:
                    irc.error("Use rpg new to create an RPG character first.")
            return player
 def letmein(self, irc, msg, args):
     """takes no arguments
     
     Gives you voice on #bitcoin-otc if you qualify.
     Also invites you if needed.
     """
     gpgauth = self._checkGPGAuth(irc, msg.prefix)
     if gpgauth is None:
         irc.error("You must authenticate via GPG to use this command.")
         return
     info = self._getGPGInfo(irc, gpgauth['nick'])
     if info is not None:
         regtimestamp = info[4]
     else:
         # this should not happen
         irc.error("No info on your user in the database.")
         return
     trust_nanotube = self._gettrust(irc, 'nanotube', gpgauth['nick'])
     trust_keefe = self._gettrust(irc, 'keefe', gpgauth['nick'])
     mintrust = min(trust_nanotube[0][0] + trust_nanotube[1][0], 
             trust_keefe[0][0] + trust_keefe[1][0])
     if mintrust >= self.registryValue('ratingThreshold') and \
                 time.time() - regtimestamp > self.registryValue('accountAgeThreshold'):
         if msg.nick not in irc.state.channels[self.registryValue('targetChannel')].users and \
                     self.registryValue('invite'):
             irc.queueMsg(ircmsgs.invite(msg.nick, self.registryValue('targetChannel')))
             irc.reply("You have been invited to %s. Type '/j %s' to enter the channel." % (self.registryValue('targetChannel'), self.registryValue('targetChannel'),))
         if msg.nick in irc.state.channels[self.registryValue('targetChannel')].users:
             irc.queueMsg(ircmsgs.voice(self.registryValue('targetChannel'), msg.nick))
             irc.noReply()
     else:
         irc.error("Insufficient account age or rating. Required minimum account age is %s days, and required minimum trust is %s. Yours are %s days and %s, respectively." % (self.registryValue('accountAgeThreshold')/60/60/24, self.registryValue('ratingThreshold'),(time.time() - regtimestamp)/60/60/24, mintrust))
    def social(self, irc, msg, args, channel, user, junk):
        """[#powder] <user>

        Sets a redirection ban from #powder to #powder-social,
        kicks the user (exploiting a users auto-rejoin
        to force them to #powder-social) then lifts the ban.
        Also sends the user a notice informing them of what happened."""

        if channel not in '#powder':
            channel = '#powder'
        hostmask = irc.state.nickToHostmask(user)
        irc.queueMsg(ircmsgs.IrcMsg(
            'MODE #powder +b {0}$#powder-social'.format(hostmask)))
        irc.queueMsg(ircmsgs.IrcMsg(
            'KICK #powder {0} :Take it to #powder-social'.format(user)))
        irc.queueMsg(ircmsgs.invite(user, '#powder-social'))
        irc.queueMsg(ircmsgs.IrcMsg((
            'NOTICE {0} :{1} has requested you take your current conversation',
            'to #powder-social.').format(
                    user, msg.nick)))
        expires = time.time() + 300

        def f():
            irc.queueMsg(ircmsgs.IrcMsg(
                'MODE #powder -b {0}$#powder-social'.format(hostmask)))

        schedule.addEvent(f, expires)
Exemple #4
0
        def _checkPlayer(self, irc, msg, new=0):
            gameChan = self.gameChannel
            if (msg.args[0] != self.gameChannel):
                if msg.nick in irc.state.channels[gameChan].users:
                    irc.error(("That command cannot be sent in this channel. "
                               "Please try again in {0}").format(gameChan))
                else:
                    irc.error(
                        "You need to join {0} and use that command there.".
                        format(gameChan))
                    irc.queueMsg(ircmsgs.invite(msg.nick, gameChan))
                return None

            try:
                player = str(ircdb.users.getUser(msg.prefix))
                player = player.split("name = \"")[1].split("\", ")[0]
            except KeyError:
                irc.errorNotRegistered()

            try:
                test = self.playerData[player]
            except:
                if new == 0:
                    irc.error("Use rpg new to create an RPG character first.")
            return player
Exemple #5
0
    def social(self, irc, msg, args, channel, user, junk):
        """[#powder] <user>

        Sets a redirection ban from #powder to #powder-social,
        kicks the user (exploiting a users auto-rejoin
        to force them to #powder-social) then lifts the ban.
        Also sends the user a notice informing them of what happened."""

        if channel not in '#powder':
            channel = '#powder'
        hostmask = irc.state.nickToHostmask(user)
        irc.queueMsg(
            ircmsgs.IrcMsg(
                'MODE #powder +b {0}$#powder-social'.format(hostmask)))
        irc.queueMsg(
            ircmsgs.IrcMsg(
                'KICK #powder {0} :Take it to #powder-social'.format(user)))
        irc.queueMsg(ircmsgs.invite(user, '#powder-social'))
        irc.queueMsg(
            ircmsgs.IrcMsg((
                'NOTICE {0} :{1} has requested you take your current conversation',
                'to #powder-social.').format(user, msg.nick)))
        expires = time.time() + 300

        def f():
            irc.queueMsg(
                ircmsgs.IrcMsg(
                    'MODE #powder -b {0}$#powder-social'.format(hostmask)))

        schedule.addEvent(f, expires)
Exemple #6
0
        def _checkPlayer(self, irc, msg, new=0):
            if (msg.args[0] != self.gameChannel):
                if msg.nick in irc.state.channels[self.gameChannel].users:
                    irc.error(
                        'That command cannot be sent in this channel. Please try again in %s'
                        % self.gameChannel)
                else:
                    irc.error(
                        'You need to join %s and use that command there.' %
                        self.gameChannel)
                    irc.queueMsg(ircmsgs.invite(msg.nick, self.gameChannel))
                return None

            try:
                player = str(ircdb.users.getUser(msg.prefix))
                player = player.split('name=\"')[1].split('\",')[0]
            except KeyError:
                irc.errorNotRegistered()

            try:
                test = self.playerData[player]
            except:
                if new is 0:
                    irc.error('Use rpg new to create an RPG character first.')
            return player
Exemple #7
0
    def invite(self, irc, msg, args, channel, nick):
        """[<channel>] <nick>

        If you have the #channel,op capability, this will invite <nick>
        to join <channel>. <channel> is only necessary if the message isn't
        sent in the channel itself.
        """
        nick = nick or msg.nick
        self._sendMsg(irc, ircmsgs.invite(nick, channel))
        self.invites[(irc.getRealIrc(), ircutils.toLower(nick))] = irc
Exemple #8
0
    def invite(self, irc, msg, args, channel, nick):
        """[<channel>] <nick>

        If you have the #channel,op capability, this will invite <nick>
        to join <channel>. <channel> is only necessary if the message isn't
        sent in the channel itself.
        """
        nick = nick or msg.nick
        self._sendMsg(irc, ircmsgs.invite(nick, channel))
        self.invites[(irc.getRealIrc(), ircutils.toLower(nick))] = irc
 def doKick(self, irc, msg):
     channel = msg.args[0]
     kicked = msg.args[1].split(',')
     protected = []
     for nick in kicked:
         if ircutils.strEqual(nick, irc.nick):
             return # Channel will handle the rejoin.
     for nick in kicked:
         hostmask = irc.state.nickToHostmask(nick)
         if self.isProtected(irc, channel, hostmask):
             self.log.info('%s was kicked from %s and is protected; '
                           'inviting back.', hostmask, channel)
             irc.queueMsg(ircmsgs.invite(nick, channel))
             protected.append(nick)
     if not self.isOp(irc, channel, msg.prefix):
         self.demote(channel, msg.nick)
Exemple #10
0
        def _checkPlayer(self, irc, msg, new=0):
            if msg.args[0] != self.gameChannel:
                if msg.nick in irc.state.channels[self.gameChannel].users:
                    irc.error("That command cannot be sent in this channel. Please try again in %s" % self.gameChannel)
                else:
                    irc.error("You need to join %s and use that command there." % self.gameChannel)
                    irc.queueMsg(ircmsgs.invite(msg.nick, self.gameChannel))
                return None

            try:
                player = str(ircdb.users.getUser(msg.prefix))
                player = player.split('name="')[1].split('",')[0]
            except KeyError:
                irc.errorNotRegistered()

            try:
                test = self.playerData[player]
            except:
                if new is 0:
                    irc.error("Use rpg new to create an RPG character first.")
            return player
Exemple #11
0
 def doKick(self, irc, msg):
     channel = msg.channel
     kicked = msg.args[1].split(',')
     protected = []
     for nick in kicked:
         if ircutils.strEqual(nick, irc.nick):
             return  # Channel will handle the rejoin.
     for nick in kicked:
         hostmask = irc.state.nickToHostmask(nick)
         if self.isProtected(irc, channel, hostmask):
             self.log.info(
                 '%s was kicked from %s and is protected; '
                 'inviting back.', hostmask, channel)
             hostmask = '%s!%s' % (nick, irc.state.nickToHostmask(nick))
             protected.append(nick)
             bans = []
             for banmask in irc.state.channels[channel].bans:
                 if ircutils.hostmaskPatternEqual(banmask, hostmask):
                     bans.append(banmask)
             irc.queueMsg(ircmsgs.unbans(channel, bans))
             irc.queueMsg(ircmsgs.invite(nick, channel))
     if not self.isOp(irc, channel, msg.prefix):
         self.demote(irc, channel, msg.nick)
Exemple #12
0
 def reinvite():
     if not self.victim in irc.state.channels[self.channel].users:
         self.irc.queueMsg(ircmsgs.invite(self.victim, self.channel))
Exemple #13
0
 def reinvite():
     if not self.victim in irc.state.channels[self.channel].users:
         self.irc.queueMsg(ircmsgs.invite(self.victim,
                                          self.channel))
Exemple #14
0
 def _invite(self, irc, nick, channel):
     irc.queueMsg(ircmsgs.invite(nick, channel))
     part_event = '%s-%s-part' % (channel, nick)
     schedule.addEvent(self._track_time_and_part, time.time() + 900, part_event, args=(irc, channel, nick))