A python bot replying notifications with quotes.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.0 KiB

from mastodon import Mastodon
import config
import memory
import time
secret_file = config.user + '.secret'
def register():
api_base_url = config.instance,
to_file = secret_file
def connect(password):
api = Mastodon(
client_id = secret_file,
api_base_url = config.instance
def scalar(a, b):
return len(a.intersection(b))
def answer(db, notifications):
for notification in notifications:
if notification.type == 'mention':
indexed_input = db.index(notification.status.content)
reply = memory.find_best_quote(db, indexed_input)
def main():
api = connect(???)
db = memory.init('pratchett')
last = None
while True:
notifications = api.notifications(since_id=last)
if len(notifications) > 0:
last = notifications[0]
answer(db, notifications)