Ejemplo n.º 1
0
 def command_not8th(self, data):
     if on_cooldown(self.cooldowns['!not8th'], three_mins): return True
     for better in self.betters:
         add_points(self, better, 1)
     self.cooldowns['!not8th'] = set_cooldown()
     return 'Yay not 8th!  All betters get 1 %s! (%s)' % (
         self.fmt_currency_name(1), ', '.join(self.betters))
Ejemplo n.º 2
0
 def command_bonus(self, data):
     if on_cooldown(self.cooldowns['!bonus'], three_mins): return True
     for better in self.betters:
         add_points(self, better, 5)
     self.cooldowns['!bonus'] = set_cooldown()
     return 'Yay Bonus! All betters get 5 %s! (%s)' % (
         self.fmt_currency_name(5), ', '.join(self.betters))
Ejemplo n.º 3
0
    def check_timer(self):
        if on_cooldown(self.lastRun, self.delay):
            return

        self.getCurrentUsers()
        self.incrementCurrency()
        self.lastRun = set_cooldown()
Ejemplo n.º 4
0
 def command_content(self, instance, data):
     if not self.voting_open:
         opts = sample(options.keys(), 4)
         for i in range(1, 5):
             index = str(i)
             self.options[index] = dict()
             self.options[index]['option'] = opts[i - 1]
             self.options[index]['votes'] = 0
         self.voting_open = True
         self.start_time = set_cooldown()
         text = ["Vote for the content you want to see (!content #):"]
         text += [
             '%s : %s' % (x, self.options[x]['option'])
             for x in sorted(self.options.keys())
         ]
         return text
     else:
         data = filter(None, data)
         if len(data) > 1 and data[1] in self.options:
             if len(data) == 3:
                 vote_inc = int(data[2]) / 100
                 try:
                     if sub_points(instance, instance.user, vote_inc * 100):
                         self.options[data[1]]['votes'] += vote_inc
                 except ValueError:
                     pass
             if len(data) > 1 and instance.user not in self.voted:
                 self.options[data[1]]['votes'] += 1
                 self.voted.append(instance.user)
         return True
Ejemplo n.º 5
0
 def command_wipe(self, data):
     if not self.raid: return True
     gil = 1
     if not on_cooldown(self.cooldowns['!wipe'], one_min):
         gil = 5
         self.cooldowns['!wipe'] = set_cooldown()
     if add_points(self, self.user, gil):
         return 'Thanks %s! Have %s %s!' % (self.user, gil,
                                            self.fmt_currency_name(gil))
     else:
         return 'Thanks %s!' % self.user
Ejemplo n.º 6
0
    def main(self):
        if on_cooldown(self.cooldown, thirty_mins):
            return

        video_dict = None

        # loop until we get a long enough video
        for count in range(0, 10):
            video_id, timestamp, video_dict = self.getYTVideoWithTimestamp(
                video_dict, count)
            if timestamp != 0: break

        self.makeWebPage(video_id, timestamp)
        self.cooldown = set_cooldown()
Ejemplo n.º 7
0
    def __init__(self, db_path=r'\Data\Databases\currency.db'):
        self.db_path = db_path
        self.lastRun = set_cooldown()
        self.delay = five_mins
        self.increment = 1  # per delay

        # track users
        self.url = 'https://tmi.twitch.tv/group/user/luckyariane/chatters'
        self.current_users = list()

        # database
        self.con = sqlite.connect(ROOT_PATH + self.db_path)
        self.cur = self.con.cursor()
        self.__initDB()
Ejemplo n.º 8
0
 def command_race(self, instance, data):
     if not self.instance: self.instance = instance
     if self.entry_open == False:
         if on_cooldown(instance.cooldowns['!race'], two_mins, test=self.test):
             return "%s is trying to register for the Chocobo Racing Lucky Cup, but they forgot to train their chocobo.  Try again in %s seconds." % (self.instance.user, get_cooldown(instance.cooldowns['!race'], two_mins))
         if not self.race_pending:
             if self.register_racer(data):
                 self.entry_open = True
                 self.race_pending = True
                 self.open_time = set_cooldown()
                 return "%s has registered for the Chocobo Racing Lucky Cup. Everyone can join!  To join type: !race <amount>" % self.instance.user
     else:
         self.register_racer(data)
     return True
Ejemplo n.º 9
0
    def updateStreamData(self):
        if on_cooldown(self.lastUpdate, self.updateInterval): return

        stream_data = convert_json(get_webpage(self.url, h=H_BASIC))        
        if stream_data['stream'] == None: 
            self.live = False
            self.stream_start = None 
            self.game = None
        else:
            self.live = True 
            self.stream_start = convert_timestamp(stream_data['stream']['created_at'])
            self.game = stream_data['stream']['game']

        print self.live 
        print self.stream_start
        print self.game
        print self.lastUpdate
        self.lastUpdate = set_cooldown()
Ejemplo n.º 10
0
 def run_race(self):
     winners = list()
     all_winners = True
     for racer in self.racers.keys():
         result = choice(['win', 'lose'])
         if result == 'win':
             if add_points(self.instance, racer, int(self.racers[racer]) * 2):
                 winners.append(racer)
         else:
             all_winners = False
     self.racers = dict()
     self.instance.cooldowns['!race'] = set_cooldown()
     self.race_pending = False
     if len(winners) == 0:
         return "The briars were everywhere today.  No one won their race."
     if all_winners:
         return "Everyone won their race!  Congratulations %s!" % ', '.join(winners)
     else:
         return "The race is over.  Congratulations to the winners: %s!" % ', '.join(winners)
Ejemplo n.º 11
0
 def command_betpay(self, data):
     if on_cooldown(self.cooldowns['!betpay'], one_min):
         return True
     try:
         payout = int(data[1])
     except ValueError:
         return 'Incorrect payout set.  Format must be !betpay <payout #> option1 option2 etc'
     win_opts = data[2:]
     winners = list()
     for opt in win_opts:
         try:
             val = int(opt)
         except ValueError:
             continue
         if val in self.bet_options:
             add_points_multi(self, self.bet_options[val]['users'], payout)
             winners += self.bet_options[val]['users']
     self.con.commit()
     self.cooldowns['!betpay'] = set_cooldown()
     return 'Added %s %s to: %s' % (payout, self.currency_name,
                                    ', '.join(winners))
Ejemplo n.º 12
0
 def check_timer(self):
     if not on_cooldown(self.cooldown, fifteen_mins):
         self.cooldown = set_cooldown()
         return choice(announcements)