myrssbot.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:TelegramBots 作者: J-Rios 项目源码 文件源码
def remove_feed(chat_id, feed_url):
    '''Function to remove (unsubscribe) a feed from the chat feeds file'''
    # Create TSjson object for feeds of chat file and read the content
    fjson_chat_feeds = TSjson.TSjson('{}/{}.json'.format(CONST['CHATS_DIR'], chat_id))
    subs_feeds = fjson_chat_feeds.read_content()
    subs_feeds = subs_feeds[0]
    # Get the feed and set json data
    feed = {}
    feedpars = parse(feed_url)
    feed['Title'] = feedpars['feed']['title']
    feed['URL'] = feed_url
    feed['SEARCH_TERMS'] = []
    for sub_feed in subs_feeds['Feeds']:
        if sub_feed['URL'] == feed['URL']:
            feed['SEARCH_TERMS'] = sub_feed['SEARCH_TERMS']
            break
    # Remove the specific feed and update json file
    subs_feeds['Feeds'].remove(feed)
    fjson_chat_feeds.update(subs_feeds, 'Chat_id')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号