def check_for_steam_dota_rss_update(channel, setkey=True): last_rss_check = settings.trygetset('%s_last_dota_rss_check' % channel, time.time()) if time.time() - last_rss_check < 30.0: return settings.setdata('%s_last_dota_rss_check' % channel, time.time(), announce=False) rs = [li for li in node.get_steam_rss() if li] last_feed_url = settings.trygetset('%s_dota_last_steam_rss_update_url' % channel, '0') for item in rs: if not item: continue if item['author'] == 'Valve' and 'Dota 2 Update' in item['title']: if item['guid'] != last_feed_url: if last_feed_url == 'derp': last_feed_url = '0' try: bpn_old = int([x for x in last_feed_url.split('/') if x][-1]) bpn_new = int([x for x in item['guid'].split('/') if x][-1]) if bpn_old >= bpn_new: break except Exception as e: print '[Dota-RSS] Error checking steam rss:', e break settings.setdata('%s_dota_last_steam_rss_update_url' % channel, str(item['guid'])) settings.setdata('%s_last_dota_rss_check' % channel, last_rss_check, announce=False) return str("Steam News Feed: %s - %s" % (item['title'], item['guid'])) else: break rs = [li for li in node.get_dota_rss() if li] last_feed_url = settings.trygetset('%s_dota_last_dota2_rss_update_url' % channel, '0') for item in rs: if not item: continue if item['guid'] != last_feed_url: if last_feed_url == 'derp': last_feed_url = '0' try: bpn_old = int(last_feed_url.split('=')[-1]) bpn_new = int(item['guid'].split('=')[-1]) if bpn_old >= bpn_new: break except Exception as e: print '[Dota-RSS] Error checking dota rss:', e break settings.setdata('%s_dota_last_dota2_rss_update_url' % channel, str(item['guid'])) return str("Dota 2 Blog Post: %s - %s" % (item['title'], item['link'])) else: break
def get_latest_steam_dota_rss_update(): rs = node.get_steam_rss() for item in rs: if item['author'] == 'Valve' and 'Dota 2 Update' in item['title']: return str("Steam RSS News Feed: %s - %s" % (item['title'], item['guid']))