更新规则

This commit is contained in:
qcminecraft 2021-02-04 08:22:39 +08:00
parent 988d884e8c
commit eac23a7510
5 changed files with 20 additions and 9 deletions

Binary file not shown.

View File

@ -3,12 +3,14 @@
"name": "misskey.io",
"url" : "https://misskey.io",
"token": "9v1t2poJeEh5RI74VqBCzJLHk9N6Weds",
"visibility": "specified",
"channel": "8hrcz5rdvp"
},
"misskey.dev": {
"name": "misskey.dev",
"url" : "https://misskey.dev",
"token": "qnZl1OmgnAlTRbRO",
"visibility": "public",
"channel": false
}
}

View File

@ -9,15 +9,11 @@ class Misskey:
config = {}
debug = True
def post(self, baseurl, content, channel=""):
def post(self, baseurl, content, channel="", visibility="public"):
print("Creating new post to", baseurl, ":", content)
req_url = baseurl + "/api/notes/create"
if self.debug:
visb = "specified"
else:
visb = "public"
body = {
"visibility": visb,
"visibility": visibility,
"text": content,
"localOnly": channel != "",
"i": self.config['token']

View File

@ -1,6 +1,10 @@
{
"DWNews":{
"rss_source": "https://rsshub.app/dwnews/yaowen/global",
"identify": "misskey.io"
"identity": "misskey.io"
},
"NHK": {
"rss_source": "https://rsshub.app/nhk/news_web_easy",
"identity": "misskey.io"
}
}

View File

@ -37,6 +37,13 @@ def spider(rule_name, rss_url):
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()))
item_list = result['rss']['channel']['item']
for i in item_list:
print("Got: ", i['title'])
desc = i['description'].replace("<blockquote>", "").replace("</blockquote>", "")
c.execute('INSERT INTO "main"."result" ("rule_name", "url", "title", "description", "timestamp")'
' VALUES (?, ?, ?, ?, ?)', (rule_name, i['link'], i['title'], desc, time.time()))
c.close()
end = time.time()
print("Fetch done in", end - start, "s")
@ -49,14 +56,16 @@ def fetch_detail(url):
if __name__ == '__main__':
print("Misskey X61 RSS Bot initialized")
spider("DuoWei", "https://rsshub.app/dwnews/yaowen/global")
config = json_read("config.json")
rules = json_read("rules.json")
for key in rules:
spider(key, rules[key]['rss_source'])
Misskey.config = config['misskey.io']
req = Misskey.post(baseurl="https://misskey.io", content="Beep.. Beep Beep! Beep:" + str(time.time()), self=Misskey)
# req = Misskey.post(baseurl="https://misskey.io", content="Beep.. Beep Beep! Beep:" + str(time.time()), self=Misskey)
conn.commit()
conn.close()