31 lines
888 B
Python
Executable File
31 lines
888 B
Python
Executable File
#!/usr/bin/env python
|
|
|
|
from pleroma_bot import PleromaBot
|
|
from mastodon import Mastodon
|
|
from pathlib import Path
|
|
import qtoml as toml
|
|
|
|
with open('config.toml') as f:
|
|
config = toml.load(f)
|
|
|
|
pleroma = Mastodon(**config['creds'])
|
|
bot = PleromaBot(pleroma, about='I am a basic bot created by https://freak.university/@KayFaraday. I only run when summoned.')
|
|
|
|
@bot.command
|
|
def ping(notif, *_):
|
|
"""Replies with “pong”"""
|
|
pleroma.status_reply(notif['status'], 'Pong!')
|
|
|
|
pastas = {p.stem: p.read_text() for p in Path('pasta').glob('*.txt')}
|
|
|
|
@bot.command
|
|
def pasta(notif, pasta_name=''):
|
|
"""Pulls up a copypasta. Run with no arguments to get a list of available copypastas."""
|
|
if not pasta_name:
|
|
pleroma.status_reply(notif['status'], f'Available copypasta: {", ".join(pastas)}')
|
|
else:
|
|
pleroma.status_reply(notif['status'], pastas[pasta_name])
|
|
|
|
if __name__ == '__main__':
|
|
bot.run()
|