def broadcast_tweet(sender, text, user, id_str, **kwargs): if config.TWITTER_BROADCAST_FOLLOW: if user['screen_name'].lower() not in config.TWITTER_BROADCAST_FOLLOW.lower().split(","): return say( content="\n".join([ "https://twitter.com/%s/status/%s" % (user['screen_name'], id_str), "[ %s: %s ]" % (user['screen_name'], text.replace("\n", "")) ]), tags=['twitter_stream'], )
def timeout_current_skip(): skip = get_current_skip() while skip: staleness = 30 - (time.time() - skip['last_update']) logger.debug("Checking if the skip is timed out - staleness is %r" % staleness) if staleness <= 0: logger.debug("The skip is timed out") delete_current_skip() say( content='Vote timed out after 30 seconds', ) return logger.debug("%d seconds to timeout" % staleness) gevent.sleep(staleness) skip = get_current_skip()
def update_forecast(): for point in Point.objects.all(): forecast = requests.get( "https://api.forecast.io/forecast/%(apikey)s/%(lat)s,%(lon)s" % dict(apikey=point.api, lat=point.lat, lon=point.lon) ) data = forecast.json() content = "Stay %(dry)s this %(lunchtime)s %(kids)s, %(weatherman)s says: %(itswet)s" % dict( dry=random.choice(["dry", "warm", "toasty", "snug"]), lunchtime=random.choice(["lunch", "lunchtime", "dinner", "eating time"]), kids=random.choice(["kids", "folk", "silly people"]), weatherman=random.choice(["the weatherman", "the forecast", "the weatherbot", "pubbot"]), itswet=data["minutely"]["summary"], ) say(content=content, tags=[point.tag] if point.tag else [])
def push_to_chat(sender, payload, **kwargs): fmt = '\x0303%(author)s \x0302%(repname)s \x0310%(rev)s\x0314\x0f: %(msg)s' org, rep = payload.repo repname = '/'.join(payload.repo) payload = payload.payload for c in payload.get('commits', [])[:4]: if not c["distinct"]: continue author = c['author']['name'] rev = c['sha'][:6] msg = c['message'] trailer = ' ...' ircmsg = fmt % locals() ircmsg = ircmsg[:240 - len(trailer)] + trailer say( content=ircmsg, tags=['github:' + repname, 'github:' + org], )
def multikill(sender, committer, **kwargs): if date.today().weekday() > 4: # No cheeky weekend killing sprees! ;-) return killer = cache.get("multikill_killer") if killer and killer != committer: say( content='%s ended the killing spree! poor %s' % (committer, killer), tags=['multikill'], ) cache.set("multikill_killer", committer) cache.set("multikill_kills", 1) return kills = cache.get("multikill_kills", 0) + 1 cache.set("multikill_kills", kills) if kills == 2: say(content="Double Kill", tags=['multikill']) elif kills == 3: say(content="Multi Kill", tags=['multikill']) elif kills == 4: say(content="Ultra Kill", tags=['multikill']) # play_sound("ultrakill.wav") elif kills == 5: say(content="Megakill", tags=['multikill']) # play_sound("megakill.wav") elif kills == 6: say(content="MONSTTTTTTTEEER KILLLLL", tags=['multikill'])
def notlikely(sender, message, committer, **kwargs): if 'final' in message.lower(): say( content="Final? Not likely, %s" % committer, )
def svnwoot(sender, revision, **kwargs): if revision in (1337, 1000, 2000, 1, 100, 200, 13337, 666, 700, 777, 501): say( content="r%d - \o/" % revision, )
def current_song_notification(sender, **kwargs): say( content="%(title)s - %(artist)s (%(album)s)" % kwargs, tags=['current_song_notification'], notice=True, )