def highlight(lrrbot, conn, event, respond_to, description): """ Command: !highlight DESCRIPTION Section: misc For use when something particularly awesome happens onstream, adds an entry on the Highlight Reel spreadsheet: https://docs.google.com/spreadsheets/d/1yrf6d7dPyTiWksFkhISqEc-JR71dxZMkUoYrX4BR40Y """ stream_info = twitch.get_info() if not stream_info["live"]: conn.privmsg(respond_to, "Not currently streaming.") return now = datetime.datetime.now(datetime.timezone.utc) for video in (yield from twitch.get_videos(broadcasts=True)): uptime = now - dateutil.parser.parse(video["recorded_at"]) if video["status"] == "recording": break else: with lrrbot.engine.begin() as pg_conn: pg_conn.execute(lrrbot.metadata.tables["highlights"].insert(), title=stream_info["status"], description=description, time=now, user=event.tags["user-id"]) conn.privmsg(respond_to, "Highlight added.") return yield from gdata.add_rows_to_spreadsheet(SPREADSHEET, [ format_row(stream_info["status"], description, video["url"], uptime, irc.client.NickMask(event.source).nick) ]) conn.privmsg(respond_to, "Highlight added.")
def highlight(lrrbot, conn, event, respond_to, description): """ Command: !highlight DESCRIPTION Section: misc For use when something particularly awesome happens onstream, adds an entry on the Highlight Reel spreadsheet: https://docs.google.com/spreadsheets/d/1yrf6d7dPyTiWksFkhISqEc-JR71dxZMkUoYrX4BR40Y """ stream_info = twitch.get_info() if not stream_info["live"]: conn.privmsg(respond_to, "Not currently streaming.") return now = datetime.datetime.now(datetime.timezone.utc) for video in (yield from twitch.get_videos(broadcasts=True)): uptime = now - dateutil.parser.parse(video["recorded_at"]) if video["status"] == "recording": break else: with lrrbot.engine.begin() as pg_conn: pg_conn.execute(lrrbot.metadata.tables["highlights"].insert(), title=stream_info["status"], description=description, time=now, user_id=event.tags["user-id"]) conn.privmsg(respond_to, "Highlight added.") return yield from gdata.add_rows_to_spreadsheet(SPREADSHEET, [ format_row(stream_info["status"], description, video, uptime, irc.client.NickMask(event.source).nick) ]) conn.privmsg(respond_to, "Highlight added.")
def on_message(self, sender, message): log.info("Got message: %r", message['data']) action = message['data']['moderation_action'] args = message['data']['args'] mod = message['data']['created_by'] if action == 'timeout': user = args[0] action = "Timeout: %s" % ctime.nice_duration(int(args[1])) reason = args[2] if len(args) >= 3 else '' last = self.last_chat.get(user.lower(), [''])[0] elif action == 'ban': user = args[0] action = "Ban" reason = args[1] if len(args) >= 2 else '' last = self.last_chat.get(user.lower(), [''])[0] elif action == 'unban': user = args[0] action = "Unban" reason = '' last = '' elif action == 'untimeout': user = args[0] action = "Untimeout" reason = '' last = '' elif action == 'delete': user = args[0] action = "Delete message" reason = '' last = args[1] else: user = '' reason = repr(args) last = '' now = datetime.datetime.now(config["timezone"]) data = [ ("Timestamp", now.strftime("%Y-%m-%d %H:%M:%S")), ("Timestamp (hours bussed)", self.nice_time(now - DESERTBUS_START)), ("Offender's Username", user), ("Moderator", mod), ("Enforcement option/length", action), ("What was the cause of the enforcement action?", reason), ("Last Line", last), ] log.debug("Add row: %r", data) asyncio.ensure_future( gdata.add_rows_to_spreadsheet(SPREADSHEET, [data]), loop=self.loop).add_done_callback(utils.check_exception)
def main(): if twitch.get_info()["live"]: print("Stream is live.") return highlights = get_staged_highlights() videos = [] for highlight in highlights: highlight["video"] = yield from lookup_video(highlight, videos) yield from gdata.add_rows_to_spreadsheet(SPREADSHEET, [ format_row(highlight["title"], highlight["description"], highlight["video"]["url"], highlight["time"] - highlight["video"]["recorded_at"], highlight["nick"]) for highlight in highlights ]) delete_staged_highlights(highlights)
def main(): if twitch.get_info()["live"]: print("Stream is live.") return highlights = get_staged_highlights() videos = [] for highlight in highlights: highlight["video"] = yield from lookup_video(highlight, videos) yield from gdata.add_rows_to_spreadsheet(SPREADSHEET, [ format_row(highlight["title"], highlight["description"], highlight["video"], highlight["time"] - highlight["video"]["recorded_at"], highlight["nick"]) for highlight in highlights ]) delete_staged_highlights(highlights)
def on_message(self, sender, message): log.info("Got message: %r", message['data']) action = message['data']['moderation_action'] args = message['data']['args'] mod = message['data']['created_by'] if action == 'timeout': user = args[0] action = "Timeout: %s" % ctime.nice_duration(int(args[1])) reason = args[2] if len(args) >= 3 else '' last = self.last_chat.get(user.lower(), [''])[0] elif action == 'ban': user = args[0] action = "Ban" reason = args[1] if len(args) >= 2 else '' last = self.last_chat.get(user.lower(), [''])[0] elif action == 'unban': user = args[0] action = "Unban" reason = '' last = '' elif action == 'untimeout': user = args[0] action = "Untimeout" reason = '' last = '' else: user = '' reason = repr(args) last = '' now = datetime.datetime.now(config["timezone"]) data = [ ("Timestamp", now.strftime("%Y-%m-%d %H:%M:%S")), ("Timestamp (hours bussed)", self.nice_time(now - DESERTBUS_START)), ("Offender's Username", user), ("Moderator", mod), ("Enforcement option/length", action), ("What was the cause of the enforcement action?", reason), ("Last Line", last), ] log.debug("Add row: %r", data) asyncio.ensure_future(gdata.add_rows_to_spreadsheet(SPREADSHEET, [data]), loop=self.loop).add_done_callback(utils.check_exception)