initial commit
This commit is contained in:
commit
13f5a7d412
|
@ -0,0 +1 @@
|
|||
config.toml
|
|
@ -0,0 +1,2 @@
|
|||
api_base_url = 'https://freak.university'
|
||||
access_token = 'secret token'
|
|
@ -0,0 +1,2 @@
|
|||
pleroma.py
|
||||
qtoml
|
|
@ -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 you’re not replying to anyone. Maybe it’s you that should be whacked?',
|
||||
)
|
||||
return
|
||||
|
||||
await pl.reply(
|
||||
slappee,
|
||||
f'***Whack!*** You’ve 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()
|
Loading…
Reference in New Issue