From b5096846462504be1cbc8912541bc30765b0977d Mon Sep 17 00:00:00 2001 From: qcminecraft Date: Sat, 6 Feb 2021 11:58:25 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BE=93=E5=87=BA=E6=96=B0=E9=97=BB=E5=86=85?= =?UTF-8?q?=E5=AE=B9=EF=BC=88beta=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- misskey.py | 3 +++ rules.json | 7 ++++++- x61bot.py | 10 +++++++--- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/misskey.py b/misskey.py index bcb07a9..9e665d2 100644 --- a/misskey.py +++ b/misskey.py @@ -13,6 +13,9 @@ class Misskey: print("Creating new post to", self.baseurl, ":", content) req_url = self.baseurl + "/api/notes/create" body = { + "noExtractMentions": True, + "noExtractHashtags": True, + "noExtractEmojis": True, "visibility": visibility, "text": content, "localOnly": channel != "", diff --git a/rules.json b/rules.json index 07d01ee..54f9725 100644 --- a/rules.json +++ b/rules.json @@ -6,7 +6,7 @@ }, "NHK": { "rss_source": "https://rsshub.app/nhk/news_web_easy", - "identity": "misskey.io", + "identity": "NHK_Easybot@x61.uk", "extra_content": "" }, "SoliDot": { @@ -23,5 +23,10 @@ "rss_source": "https://rsshub.app/nikkei/index", "identity": "NIKKEI@x61.uk", "extra_content": "#News" + }, + "Asahi": { + "rss_source": "https://rsshub.app/asahichinese-j/whatsnew", + "identity": "AsahiBot@x61.uk", + "extra_content": "#News" } } \ No newline at end of file diff --git a/x61bot.py b/x61bot.py index b58e6d6..944b8a1 100644 --- a/x61bot.py +++ b/x61bot.py @@ -39,7 +39,7 @@ def spider(rule_name, rss_url): return False result = xmltodict.parse(fetch.content) c.execute('INSERT INTO "main"."spider_log" ("rule_name", "rss_url", "result_json", "timestamp") ' - 'VALUES (?, ?, ?, ?)', (rule_name, rss_url, json.dumps(result), time.time())) + 'VALUES (?, ?, ?, ?)', (rule_name, rss_url, "{}", time.time())) item_list = result['rss']['channel']['item'] for i in item_list: unique = c.execute('SELECT * FROM "main"."result" WHERE "title" = ? LIMIT 0,1', (i['title'],)).fetchone() @@ -49,7 +49,7 @@ def spider(rule_name, rss_url): print("Skip: ", title) continue print("Got: ", title) - desc = i['description'].replace("
", "“").replace("
", "”") + desc = i['description'].replace("
", "“").replace("
", "”") c.execute('INSERT INTO "main"."result" ("rule_name", "url", "title", "description", "timestamp")' ' VALUES (?, ?, ?, ?, ?)', (rule_name, i['link'], title, desc, time.time())) @@ -81,7 +81,11 @@ if __name__ == '__main__': if not(r is None): res = c.execute('UPDATE "main"."result" SET "post_time" = ? WHERE rowid = ?', (time.time(), r[0])) if not (res is None): - content = r[3]+"\n<"+r[2]+">\n\n"+rules[key]['extra_content'] + reg = re.compile('<[^>]*>') + desc = reg.sub('', r[4]).replace('\n\n', '\n').replace(' ', '').replace('\n\n\n', '') + content = "**"+r[3]+"**\n\n"+desc+"\n<"+r[2]+">\n"+rules[key]['extra_content'] + if Misskey.debug: + config[name]['visibility'] = "specified" Misskey.post(self=Misskey, content=content, i=config[name]['token'], visibility=config[name]['visibility'])