示例#1
0
文件: rpc.py 项目: pyrige/lrrbot
	def get_header_info(self):
		live = twitch.is_stream_live()
		game_id = self.lrrbot.get_game_id()

		data = {
			"is_live": live,
			"channel": config['channel'],
		}

		if live and game_id is not None:
			data['current_game'] = {
				"id": game_id,
				"is_override": self.lrrbot.game_override is not None,
			}
			data['current_show'] = {
				"id": self.lrrbot.get_show_id(),
				"is_override": self.lrrbot.show_override is not None,
			}
		elif not live:
			data['nextstream'] = googlecalendar.get_next_event_text(googlecalendar.CALENDAR_LRL)

		if 'advice' in storage.data['responses']:
			data['advice'] = random.choice(storage.data['responses']['advice']['response'])

		return data
示例#2
0
    def get_header_info(self):
        live = twitch.is_stream_live()
        game_id = self.lrrbot.get_game_id()

        data = {
            "is_live": live,
            "channel": config['channel'],
        }

        if live and game_id is not None:
            data['current_game'] = {
                "id": game_id,
                "is_override": self.lrrbot.game_override is not None,
            }
            data['current_show'] = {
                "id": self.lrrbot.get_show_id(),
                "is_override": self.lrrbot.show_override is not None,
            }
        elif not live:
            data['nextstream'] = googlecalendar.get_next_event_text(
                googlecalendar.CALENDAR_LRL)

        if 'advice' in storage.data['responses']:
            data['advice'] = random.choice(
                storage.data['responses']['advice']['response'])

        return data
示例#3
0
文件: misc.py 项目: pyrige/lrrbot
def nextfan(lrrbot, conn, event, respond_to, timezone):
	"""
	Command: !nextfan
	Section: info

	Gets the next scheduled stream from the fan-streaming calendar
	"""
	conn.privmsg(respond_to, googlecalendar.get_next_event_text(googlecalendar.CALENDAR_FAN, tz=timezone, include_current=True))
示例#4
0
文件: misc.py 项目: keab42/lrrbot
def nextfan(lrrbot, conn, event, respond_to, timezone):
	"""
	Command: !nextfan
	Command: !nextfanstream
	Command: !fansched
	Command: !fanschedule
	Section: info

	Gets the next scheduled stream from the fan-streaming calendar
	"""
	conn.privmsg(respond_to, googlecalendar.get_next_event_text(googlecalendar.CALENDAR_FAN, tz=timezone, include_current=True))
示例#5
0
文件: misc.py 项目: pyrige/lrrbot
def next(lrrbot, conn, event, respond_to, timezone):
	"""
	Command: !next
	Section: info

	Gets the next scheduled stream from the LoadingReadyLive calendar

	Can specify a timezone, to show stream in your local time, eg: !next America/New_York

	If no time zone is specified, times will be shown in Moonbase time.
	"""
	if DESERTBUS_PRESTART < datetime.datetime.now(datetime.timezone.utc) < DESERTBUS_END:
		# If someone says !next before/during Desert Bus, plug that instead
		desertbus(lrrbot, conn, event, respond_to, timezone)
	else:
		conn.privmsg(respond_to, googlecalendar.get_next_event_text(googlecalendar.CALENDAR_LRL, tz=timezone))
示例#6
0
def get_status_msg(lrrbot):
    messages = []
    stream_info = twitch.get_info()
    if stream_info and stream_info.get('live'):
        game_id = lrrbot.get_game_id()
        show_id = lrrbot.get_show_id()

        shows = lrrbot.metadata.tables["shows"]
        games = lrrbot.metadata.tables["games"]
        game_per_show_data = lrrbot.metadata.tables["game_per_show_data"]
        with lrrbot.engine.begin() as conn:
            show = conn.execute(
                sqlalchemy.select([shows.c.name
                                   ]).where(shows.c.id == show_id).where(
                                       shows.c.string_id != "")).first()
            if show is not None:
                show, = show

            if game_id is not None:
                game, = conn.execute(
                    sqlalchemy.select([
                        sqlalchemy.func.coalesce(
                            game_per_show_data.c.display_name, games.c.name)
                    ]).select_from(
                        games.outerjoin(
                            game_per_show_data,
                            (game_per_show_data.c.game_id == games.c.id) &
                            (game_per_show_data.c.show_id == show_id))).where(
                                games.c.id == game_id)).first()
            else:
                game = None

        if game and show:
            messages.append("Currently playing %s on %s." % (game, show))
        elif game:
            messages.append("Currently playing %s." % game)
        elif show:
            messages.append("Currently showing %s." % show)
        messages.append(uptime_msg(stream_info))
    else:
        messages.append(
            googlecalendar.get_next_event_text(googlecalendar.CALENDAR_LRL))
    if 'advice' in storage.data['responses']:
        messages.append(
            random.choice(storage.data['responses']['advice']['response']))
    return ' '.join(messages)
示例#7
0
文件: misc.py 项目: keab42/lrrbot
def next(lrrbot, conn, event, respond_to, timezone):
	"""
	Command: !next
	Command: !nextstream
	Command: !sched
	Command: !schedule
	Section: info

	Gets the next scheduled stream from the LoadingReadyLive calendar

	Can specify a timezone, to show stream in your local time, eg: !next America/New_York

	If no time zone is specified, times will be shown in Moonbase time.
	"""
	if datetime.datetime.now(datetime.timezone.utc) < DESERTBUS_END:
		# If someone says !next before/during Desert Bus, plug that instead
		desertbus(lrrbot, conn, event, respond_to, timezone)
	else:
		conn.privmsg(respond_to, googlecalendar.get_next_event_text(googlecalendar.CALENDAR_LRL, tz=timezone))
示例#8
0
文件: misc.py 项目: TomHanra/lrrbot
def get_status_msg(lrrbot):
	messages = []
	stream_info = twitch.get_info()
	if stream_info and stream_info.get('live'):
		game = lrrbot.get_current_game()
		game = game and game.get("display", game["name"])
		show = lrrbot.show_override or lrrbot.show
		show = show and storage.data.get("shows", {}).get(show, {}).get("name", show)
		if game and show:
			messages.append("Currently playing %s on %s." % (game, show))
		elif game:
			messages.append("Currently playing %s." % game)
		elif show:
			messages.append("Currently showing %s." % show)
		messages.append(uptime_msg(stream_info))
	else:
		messages.append(googlecalendar.get_next_event_text(googlecalendar.CALENDAR_LRL))
	if 'advice' in storage.data['responses']:
		messages.append(random.choice(storage.data['responses']['advice']['response']))
	return ' '.join(messages)
示例#9
0
文件: misc.py 项目: pyrige/lrrbot
def get_status_msg(lrrbot):
	messages = []
	stream_info = twitch.get_info()
	if stream_info and stream_info.get('live'):
		game_id = lrrbot.get_game_id()
		show_id = lrrbot.get_show_id()

		shows = lrrbot.metadata.tables["shows"]
		games = lrrbot.metadata.tables["games"]
		game_per_show_data = lrrbot.metadata.tables["game_per_show_data"]
		with lrrbot.engine.begin() as conn:
			show = conn.execute(sqlalchemy.select([shows.c.name])
				.where(shows.c.id == show_id)
				.where(shows.c.string_id != "")).first()
			if show is not None:
				show, = show

			if game_id is not None:
				game, = conn.execute(sqlalchemy.select([
					sqlalchemy.func.coalesce(game_per_show_data.c.display_name, games.c.name)
				]).select_from(
					games.outerjoin(game_per_show_data,
						(game_per_show_data.c.game_id == games.c.id) &
							(game_per_show_data.c.show_id == show_id))
				).where(games.c.id == game_id)).first()
			else:
				game = None

		if game and show:
			messages.append("Currently playing %s on %s." % (game, show))
		elif game:
			messages.append("Currently playing %s." % game)
		elif show:
			messages.append("Currently showing %s." % show)
		messages.append(uptime_msg(stream_info))
	else:
		messages.append(googlecalendar.get_next_event_text(googlecalendar.CALENDAR_LRL))
	if 'advice' in storage.data['responses']:
		messages.append(random.choice(storage.data['responses']['advice']['response']))
	return ' '.join(messages)
示例#10
0
def nextstream(lrrbot, user, data):
    return googlecalendar.get_next_event_text(googlecalendar.CALENDAR_LRL,
                                              verbose=False)
示例#11
0
文件: rpc.py 项目: pyrige/lrrbot
	def nextstream(self):
		return googlecalendar.get_next_event_text(googlecalendar.CALENDAR_LRL, verbose=False)
示例#12
0
def nextstream(lrrbot, user, data):
	return googlecalendar.get_next_event_text(googlecalendar.CALENDAR_LRL, verbose=False)
示例#13
0
 def nextstream(self):
     return googlecalendar.get_next_event_text(googlecalendar.CALENDAR_LRL,
                                               verbose=False)