def single_page_watch(args, bot, chat_id, keyConfig, requestText, user, CommandName): data, total_results, results_this_page = getlink.Google_Custom_Search(args) if 'items' in data and results_this_page >= 0: offset_this_page = 0 total_sent = 0 while offset_this_page < results_this_page: link = data['items'][offset_this_page]['link'] offset_this_page += 1 if user != 'Watcher': if total_sent == 0 and not main.AllWatchesContains(CommandName, chat_id, requestText): watch_message = 'Now watching /' + CommandName + ' ' + requestText + '.' else: watch_message = 'Watched /' + CommandName + ' ' + requestText + ' changed' + '.' bot.sendMessage(chat_id=chat_id, text=watch_message + '\n' + link) total_sent += 1 else: bot.sendMessage(chat_id=chat_id, text='Watched /' + CommandName + ' ' + requestText + ' changed.' + '\n' + link) total_sent += 1 if total_sent == 0: if user != 'Watcher': bot.sendMessage(chat_id=chat_id, text=user + ', watch for /' + CommandName + ' ' + requestText + ' has not changed.') if not main.AllWatchesContains(CommandName, chat_id, requestText): main.addToAllWatches(CommandName, chat_id, requestText) else: if user != 'Watcher': bot.sendMessage(chat_id=chat_id, text='I\'m sorry ' + (user if not user == '' else 'Dave') + ', I\'m afraid I can\'t find any results for /' + CommandName + ' ' + string.capwords(requestText.encode('utf-8')))
def run(bot, chat_id, user, keyConfig, message, totalResults=1): tracks = get_tracks(keyConfig, message) if tracks: track = tracks[0].permalink_url OldValue = getWatchValue(chat_id, message) if OldValue != track: setWatchValue(chat_id, message, track) if OldValue == '': if user != 'Watcher': bot.sendMessage(chat_id=chat_id, text='Now watching /' + watchedCommandName + ' ' + message + '\n' + track) else: bot.sendMessage(chat_id=chat_id, text='Watch for /' + watchedCommandName + ' ' + message + ' has changed.\n' + track) else: if user != 'Watcher': bot.sendMessage(chat_id=chat_id, text='Watch for /' + watchedCommandName + ' ' + message + ' has not changed:\n' + track) if not main.AllWatchesContains(watchedCommandName, chat_id, message): main.addToAllWatches(watchedCommandName, chat_id, message) else: bot.sendMessage( chat_id=chat_id, text='I\'m sorry ' + (user if not user == '' else 'Dave') + ', I\'m afraid I can\'t watch ' + 'because I did not find any results from /' + watchedCommandName, parse_mode='Markdown')
def run(bot, chat_id, user, keyConfig='', message=''): top_games = get_steam_top_games().encode('utf-8') if top_games: OldValue = getWatchValue(chat_id) if OldValue != top_games: setWatchValue(chat_id, top_games) if OldValue == '': if user != 'Watcher': bot.sendMessage(chat_id=chat_id, text='Now watching /' + watchedCommandName+ '\n' + top_games, parse_mode='Markdown') else: games_added, games_removed, newly_added_games = get_add_removed_games(chat_id, top_games, OldValue) message_text = 'Watch for /' + watchedCommandName + ' has changed' + (' order.' if ( games_added == added_games_title and games_removed == removed_games_title) else '.') + '\n' + top_games + ( '\n' + games_added if games_added != added_games_title else '') + ( '\n' + games_removed if games_removed != removed_games_title else '') + ( '\n' + newly_added_games if newly_added_games != newly_added_games_title else '') bot.sendMessage(chat_id=chat_id, text=message_text, parse_mode='Markdown') else: if user != 'Watcher': bot.sendMessage(chat_id=chat_id, text='Watch for /' + watchedCommandName + ' has not changed:\n' + top_games, parse_mode='Markdown') import main if not main.AllWatchesContains(watchedCommandName, chat_id): main.addToAllWatches(watchedCommandName, chat_id) else: bot.sendMessage(chat_id=chat_id, text='I\'m sorry ' + (user if not user == '' else 'Dave') + ', I\'m afraid I can\'t watch ' + 'because I did not find any results from /' + watchedCommandName, parse_mode='Markdown')
def run(bot, chat_id, user, keyConfig='', message='', totalResults=1): pop_games = get_steamcharts_top_games(2).encode('utf-8') if pop_games: setWatchValue(chat_id, pop_games) OldValue = getPreviouslyAddedTitlesValue(chat_id) games_added = get_added_games(chat_id, pop_games, OldValue) if games_added != added_games_title: if OldValue == '': if user != 'Watcher': bot.sendMessage(chat_id=chat_id, text='Now watching /' + watchedCommandName, parse_mode='Markdown') else: if games_added != added_games_title: message_text = 'Watch for /' + watchedCommandName + ' has changed\n' + games_added bot.sendMessage(chat_id=chat_id, text=message_text, parse_mode='Markdown') else: if user != 'Watcher': bot.sendMessage(chat_id=chat_id, text='Watch for /' + watchedCommandName + ' has not changed.', parse_mode='Markdown') import main if not main.AllWatchesContains(watchedCommandName, chat_id): main.addToAllWatches(watchedCommandName, chat_id) else: bot.sendMessage(chat_id=chat_id, text='I\'m sorry ' + (user if not user == '' else 'Dave') + ', I\'m afraid I can\'t watch ' + 'because I did not find any results from /' + watchedCommandName, parse_mode='Markdown')
def run(bot, chat_id, user, keyConfig, message, totalResults=1): exchange_data = get_exchange_data() if exchange_data: OldValue = getWatchValue(chat_id, message) if OldValue != exchange_data: setWatchValue(chat_id, message, exchange_data) if OldValue == '': if user != 'Watcher': bot.sendMessage(chat_id=chat_id, text='Now watching /' + watchedCommandName + ' ' + message + '\n' + exchange_data) else: bot.sendMessage(chat_id=chat_id, text='Watch for /' + watchedCommandName + ' ' + message + ' has changed.\n' + exchange_data) else: if user != 'Watcher': bot.sendMessage(chat_id=chat_id, text='Watch for /' + watchedCommandName + ' ' + message + ' has not changed:\n' + exchange_data) if not main.AllWatchesContains(watchedCommandName, chat_id, message): main.addToAllWatches(watchedCommandName, chat_id, message) else: bot.sendMessage( chat_id=chat_id, text='I\'m sorry ' + (user if not user == '' else 'Dave') + ', I\'m afraid I can\'t watch ' + 'because I did not find any results from /' + watchedCommandName)
def single_page_watch(args, bot, chat_id, keyConfig, requestText, user, watched_command): data, total_results, results_this_page = get.Google_Custom_Search(args) if 'items' in data and results_this_page >= 0: offset_this_page = 0 total_sent = 0 while offset_this_page < results_this_page: imagelink = data['items'][offset_this_page]['link'] offset_this_page += 1 if '?' in imagelink: imagelink = imagelink[:imagelink.index('?')] if not get.wasPreviouslySeenImage(chat_id, imagelink): get.addPreviouslySeenImagesValue(chat_id, imagelink) if imagelink[-len('.gif'):] == '.gif': is_valid = getgif.is_valid_gif(imagelink) else: is_valid = get.is_valid_image(imagelink) if is_valid: if user != 'Watcher': if total_sent == 0 and not main.AllWatchesContains( watched_command.CommandName, chat_id, requestText): watch_message = 'Now watching /' + watched_command.CommandName + ' ' + requestText + '.' else: watch_message = 'Watched /' + watched_command.CommandName + ' ' + requestText + ' changed' + '.' total_sent = send_image_with_watch_message( bot, chat_id, imagelink, keyConfig, requestText, total_sent, user, watch_message) else: total_sent = send_image_with_watch_message( bot, chat_id, imagelink, keyConfig, requestText, total_sent, user, 'Watched /' + watched_command.CommandName + ' ' + requestText + ' changed.') if total_sent == 0: if user != 'Watcher': bot.sendMessage(chat_id=chat_id, text=user + ', watch for /' + watched_command.CommandName + ' ' + requestText + ' has not changed.') if not main.AllWatchesContains(watched_command.CommandName, chat_id, requestText): main.addToAllWatches(watched_command.CommandName, chat_id, requestText) else: if user != 'Watcher': bot.sendMessage(chat_id=chat_id, text='I\'m sorry ' + (user if not user == '' else 'Dave') + ', I\'m afraid I can\'t find any results for /' + watched_command.CommandName + ' ' + string.capwords(requestText.encode('utf-8')))
def run(bot, chat_id, user, keyConfig, message, totalResults=1): requestText = message.replace(bot.name, "").strip() has_iss_results, has_place_results, startDateTime, durationSeconds = iss.get_iss_data( keyConfig, requestText) if has_place_results: if has_iss_results: if has_iss_results: OldValue = getWatchValue(chat_id) if OldValue != startDateTime: setWatchValue(chat_id, requestText, startDateTime) if OldValue == '' and user != 'Watcher' and message == '': url = 'http://www.heavens-above.com/orbitdisplay.aspx?icon=iss&width=400&height=400&satid=25544&uuid=' + \ str(uuid.uuid4()) bot.sendMessage( chat_id=chat_id, text='Now watching /' + watchedCommandName + ' ' + message + '\n' + iss.format_iss_message( durationSeconds, requestText, startDateTime) + '\n' + url) elif OldValue == '' and user != 'Watcher' and message != '': bot.sendMessage( chat_id=chat_id, text='Now watching /' + watchedCommandName + ' changes by ' + message + '\n' + iss.format_iss_message( durationSeconds, requestText, startDateTime)) elif OldValue != '' and user != 'Watcher' and message == '': url = 'http://www.heavens-above.com/orbitdisplay.aspx?icon=iss&width=400&height=400&satid=25544&uuid=' + \ str(uuid.uuid4()) bot.sendMessage( chat_id=chat_id, text='Watch for /' + watchedCommandName + ' has not changed.\n' + iss.format_iss_message( durationSeconds, requestText, startDateTime) + '\n' + url) if not main.AllWatchesContains(watchedCommandName, chat_id, message): main.addToAllWatches(watchedCommandName, chat_id, message) else: bot.sendMessage( chat_id=chat_id, text='I\'m sorry ' + (user if not user == '' else 'Dave') + ', I\'m afraid I can\'t find the next ISS sighting for ' + requestText.encode('utf-8') + '.') else: bot.sendMessage(chat_id=chat_id, text='I\'m sorry ' + (user if not user == '' else 'Dave') + ', I\'m afraid I can\'t find any places for ' + requestText.encode('utf-8') + '.')
def single_page_watch(args, bot, chat_id, keyConfig, requestText, user, watched_command): data, total_results, results_this_page = get.Google_Custom_Search(args) if 'items' in data and results_this_page >= 0: offset_this_page = 0 total_sent = 0 while offset_this_page < results_this_page: imagelink = data['items'][offset_this_page]['link'] offset_this_page += 1 if '?' in imagelink: imagelink = imagelink[:imagelink.index('?')] if not get.wasPreviouslySeenImage(chat_id, imagelink): get.addPreviouslySeenImagesValue(chat_id, imagelink) if imagelink[-len('.gif'):] == '.gif': is_valid = getgif.is_valid_gif(imagelink) else: is_valid = get.is_valid_image(imagelink) if is_valid: if user != 'Watcher': if total_sent == 0 and not main.AllWatchesContains(watched_command.CommandName, chat_id, requestText): watch_message = 'Now watching /' + watched_command.CommandName + ' ' + requestText + '.' else: watch_message = 'Watched /' + watched_command.CommandName + ' ' + requestText + ' changed' + '.' total_sent = send_image_with_watch_message(bot, chat_id, imagelink, keyConfig, requestText, total_sent, user, watch_message) else: total_sent = send_image_with_watch_message(bot, chat_id, imagelink, keyConfig, requestText, total_sent, user, 'Watched /' + watched_command.CommandName + ' ' + requestText + ' changed.') if total_sent == 0: if user != 'Watcher': bot.sendMessage(chat_id=chat_id, text=user + ', watch for /' + watched_command.CommandName + ' ' + requestText + ' has not changed.') if not main.AllWatchesContains(watched_command.CommandName, chat_id, requestText): main.addToAllWatches(watched_command.CommandName, chat_id, requestText) else: if user != 'Watcher': bot.sendMessage(chat_id=chat_id, text='I\'m sorry ' + (user if not user == '' else 'Dave') + ', I\'m afraid I can\'t find any results for /' + watched_command.CommandName + ' ' + string.capwords(requestText.encode('utf-8')))