2021-09-07 08:44:47 +00:00
|
|
|
import hashlib
|
|
|
|
def already_posted(id, path):
|
|
|
|
with open(path) as file:
|
2021-09-06 08:39:24 +00:00
|
|
|
content = file.read().split("\n")
|
|
|
|
sha1 = hashlib.sha1(bytes(id, "utf-8")).hexdigest()
|
|
|
|
if sha1 in content:
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
2021-09-07 08:44:47 +00:00
|
|
|
def mark_as_posted(id, path):
|
|
|
|
with open(path, 'a') as file:
|
2021-09-06 08:39:24 +00:00
|
|
|
sha1 = hashlib.sha1(bytes(id, "utf-8")).hexdigest()
|
|
|
|
file.write(sha1+'\n')
|
|
|
|
|