initial commit

This commit is contained in:
Kay Faraday 2023-08-16 05:23:15 +00:00
commit 13f5a7d412
5 changed files with 44 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
config.toml

2
config.example.toml Normal file
View File

@ -0,0 +1,2 @@
api_base_url = 'https://freak.university'
access_token = 'secret token'

2
requirements.txt Normal file
View File

@ -0,0 +1,2 @@
pleroma.py
qtoml

BIN
trout.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 KiB

39
trout.py Executable file
View File

@ -0,0 +1,39 @@
#!/usr/bin/env python
import pleroma
import qtoml as toml
async def amain():
with open('config.toml') as f:
config = toml.load(f)
async with pleroma.Pleroma(**config) as pl:
async for post in pl.stream_local_timeline():
if '{{trout}}' in post['content']:
await trout(pl, post)
async def trout(pl, post):
context = await pl.status_context(post['id'])
try:
slappee = context['ancestors'][-1]
except IndexError:
await pl.reply(
post,
'Looks like youre not replying to anyone. Maybe its you that should be whacked?',
)
return
await pl.reply(
slappee,
f'***Whack!*** Youve been whacked with a wet trout by @{post["account"]["acct"]}.',
content_type='text/markdown',
files=[pleroma.File(fp='trout.png', mime_type='image/png', description='A large trout')],
)
def main():
import anyio
anyio.run(amain)
if __name__ == '__main__':
main()