Example #1
0
    def spin(self, msg, args):
        if not glob(msg.frm, self.bot_config.BOT_ADMINS):
            return "You're not my dad!"

        if not self.config:
            return "This plugin needs to be configured... run !plugin config Raffle and follow the directions."

        try:
            room = msg.frm.room
        except AttributeError:
            room = self._bot.rooms()[0]

        viewers = [
            x for x in room.occupants
            if not glob(x.person, self.config['IGNORED'])
        ]
        if not viewers:
            return "sorry, pool's empty."

        winner = random.choice(viewers).nick
        prefix_text = self.config['PREFIX']

        dest = room if msg.is_group else msg.frm
        self.send(dest,
                  tenv().get_template('prefix.html').render(viewers=viewers))
        if not (args == 'quick'):
            sleep(1)
            for i in range(5):
                self.send(dest, ' :catface: ' * i)
                sleep(1)
            sleep(2)
        self.send(
            dest,
            tenv().get_template('winner.html').render(prefix=prefix_text,
                                                      winner=winner))
Example #2
0
 def check_user(self, msg, flow):
     """Checks to make sure that either the user started the flow, or is a bot admin"""
     if glob(get_acl_usr(msg), self.bot_config.BOT_ADMINS):
         return True
     elif glob(get_acl_usr(msg), flow.requestor.person):
         return True
     return False
Example #3
0
    def spin(self, msg, args):
        if not glob(msg.frm, self.bot_config.BOT_ADMINS):
            return "You're not my dad!"

        if not self.config:
            return "This plugin needs to be configured... run !plugin config Raffle and follow the directions."

        try:
            room = msg.frm.room
        except AttributeError:
            room = self._bot.rooms()[0]

        viewers = [x for x in room.occupants if not glob(x.person, self.config['IGNORED'])]
        if not viewers:
            return "sorry, pool's empty."

        winner = random.choice(viewers).nick
        prefix_text = self.config['PREFIX']

        dest = room if msg.is_group else msg.frm
        self.send(dest, tenv().get_template('prefix.html').render( viewers=viewers ))
        if not (args == 'quick'):
            sleep(1)
            for i in range(5):
                self.send(dest, ' :catface: ' * i)
                sleep(1)
            sleep(2)
        self.send(dest, tenv().get_template('winner.html').render( prefix=prefix_text, winner=winner ))
Example #4
0
File: flows.py Project: zoni/errbot
 def check_user(self, msg, flow):
     """Checks to make sure that either the user started the flow, or is a bot admin
     """
     if glob(get_acl_usr(msg), self.bot_config.BOT_ADMINS):
         return True
     elif glob(get_acl_usr(msg), flow.requestor.person):
         return True
     return False