Пример #1
0
 def render(self, extra):
     try:
         response = json.loads(extra)
         return slack.ephemeral(response)
     except ValueError:
         logging.warning("Invalid message:\n%s", extra)
         return slack.ephemeral(slack.response("Invalid message."))
Пример #2
0
 def nbascore(self, extra):
   tokens = extra.split()
   team_code = tokens[0].upper()
   scores = None
   if len(tokens) >= 2:
     date = tokens[1]
     scores = nba.get_scores_for_team(nba.get_stats(date), team_code)
   else:
     today = datetime.date.today()
     yesterday = datetime.date.today() - datetime.timedelta(days=1)
     for date in (today, yesterday):
       scores = nba.get_scores_for_team(nba.get_stats(str(date)), team_code)
       if scores:
         break
   if not scores:
     return slack.ephemeral(slack.response(
         'No games found for %s on %s.' % (team_code, date)))
   return slack.response(None, nba.format_scores(scores))
Пример #3
0
 def whisper(self, extra):
     original_response = self.run(extra)
     return slack.ephemeral(original_response)