Skip to content

Commit

Permalink
add salt to image
Browse files Browse the repository at this point in the history
fix #6
  • Loading branch information
zyujs committed Aug 26, 2021
1 parent a212f4f commit 77ff771
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions rss.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@
import os
import json
import time
import random
import string

import sys
if sys.version_info[0] >= 3:
import html
else:
from html.parser import HTMLParser
html = HTMLParser()
import html

rss_news = {}

Expand Down Expand Up @@ -255,13 +253,17 @@ async def refresh_all_rss():
rss_news[rss_url] = await get_rss_news(rss_url)
save_data()

def add_salt(data):
salt = ''.join(random.sample(string.ascii_letters + string.digits, 6))
return data + bytes(salt, encoding="utf8")

def format_msg(news):
msg = f"{news['feed_title']}更新:\n{news['id']}"
if not check_title_in_content(news['title'], news['content']):
msg += f"\n{news['title']}"
msg += f"\n----------\n{remove_lf(news['content'])}"
if news['image']:
base64_str = f"base64://{base64.b64encode(news['image']).decode()}"
base64_str = f"base64://{base64.b64encode(add_salt(news['image'])).decode()}"
msg += f'[CQ:image,file={base64_str}]'
return msg

Expand Down

0 comments on commit 77ff771

Please sign in to comment.