[mastodon] New style: double quotes instead of single quotes
This commit is contained in:
parent
b312d11a3f
commit
80a5e59e97
|
@ -43,14 +43,14 @@ class MastodonBot(Censor):
|
|||
last_seen = int(self.model.last_seen)
|
||||
for status in notifications:
|
||||
try:
|
||||
status_id = int(status['status']['id'])
|
||||
status_id = int(status["status"]["id"])
|
||||
except KeyError:
|
||||
continue # ignore notifications which don't have a status
|
||||
if status_id <= last_seen:
|
||||
continue # toot was already processed in the past
|
||||
if status_id > int(self.model.last_seen):
|
||||
await self.model.update(last_seen=str(status_id))
|
||||
text = re.sub(r'<[^>]*>', '', status['status']['content'])
|
||||
text = re.sub(r"<[^>]*>", "", status["status"]["content"])
|
||||
text = re.sub(
|
||||
"(?<=^|(?<=[^a-zA-Z0-9-_.]))@([A-Za-z]+[A-Za-z0-9-_]+)", "", text
|
||||
)
|
||||
|
@ -58,7 +58,7 @@ class MastodonBot(Censor):
|
|||
"Mastodon in %s received toot #%s: %s"
|
||||
% (self.model.hood.name, status_id, text)
|
||||
)
|
||||
if status['status']['visibility'] == 'public':
|
||||
if status["status"]["visibility"] == "public":
|
||||
await self.publish(Message(text, toot_id=status_id))
|
||||
else:
|
||||
await self.publish(Message(text))
|
||||
|
|
|
@ -15,7 +15,7 @@ class MastodonInstance(Model):
|
|||
client_secret: Text()
|
||||
|
||||
class Mapping(Mapping):
|
||||
table_name = 'mastodoninstances'
|
||||
table_name = "mastodoninstances"
|
||||
|
||||
|
||||
class MastodonAccount(Model):
|
||||
|
@ -27,4 +27,4 @@ class MastodonAccount(Model):
|
|||
last_seen: Text()
|
||||
|
||||
class Mapping(Mapping):
|
||||
table_name = 'mastodonaccounts'
|
||||
table_name = "mastodonaccounts"
|
||||
|
|
|
@ -55,9 +55,9 @@ twitter_callback_router = APIRouter()
|
|||
|
||||
|
||||
@router.get(
|
||||
'/public',
|
||||
"/public",
|
||||
# TODO response_model,
|
||||
operation_id='get_mastodons_public',
|
||||
operation_id="get_mastodons_public",
|
||||
)
|
||||
async def mastodon_read_all_public(hood=Depends(get_hood_unauthorized)):
|
||||
mastodonbots = await MastodonAccount.objects.filter(hood=hood).all()
|
||||
|
@ -69,28 +69,28 @@ async def mastodon_read_all_public(hood=Depends(get_hood_unauthorized)):
|
|||
|
||||
|
||||
@router.get(
|
||||
'/',
|
||||
"/",
|
||||
# TODO response_model,
|
||||
operation_id='get_mastodons',
|
||||
operation_id="get_mastodons",
|
||||
)
|
||||
async def mastodon_read_all(hood=Depends(get_hood)):
|
||||
return await MastodonAccount.objects.filter(hood=hood).all()
|
||||
|
||||
|
||||
@router.get(
|
||||
'/{mastodon_id}',
|
||||
"/{mastodon_id}",
|
||||
# TODO response_model
|
||||
operation_id='get_mastodon',
|
||||
operation_id="get_mastodon",
|
||||
)
|
||||
async def mastodon_read(mastodon=Depends(get_mastodon)):
|
||||
return mastodon
|
||||
|
||||
|
||||
@router.delete(
|
||||
'/{mastodon_id}',
|
||||
"/{mastodon_id}",
|
||||
status_code=status.HTTP_204_NO_CONTENT,
|
||||
# TODO response_model
|
||||
operation_id='delete_mastodon',
|
||||
operation_id="delete_mastodon",
|
||||
)
|
||||
async def mastodon_delete(mastodon=Depends(get_mastodon)):
|
||||
spawner.stop(mastodon)
|
||||
|
@ -99,20 +99,20 @@ async def mastodon_delete(mastodon=Depends(get_mastodon)):
|
|||
|
||||
|
||||
@router.get(
|
||||
'/{mastodon_id}/status',
|
||||
"/{mastodon_id}/status",
|
||||
status_code=status.HTTP_200_OK,
|
||||
# TODO response_model
|
||||
operation_id='status_mastodon',
|
||||
operation_id="status_mastodon",
|
||||
)
|
||||
async def mastodon_status(mastodon=Depends(get_mastodon)):
|
||||
return {'status': spawner.get(mastodon).status.name}
|
||||
return {"status": spawner.get(mastodon).status.name}
|
||||
|
||||
|
||||
@router.post(
|
||||
'/{mastodon_id}/start',
|
||||
"/{mastodon_id}/start",
|
||||
status_code=status.HTTP_200_OK,
|
||||
# TODO response_model
|
||||
operation_id='start_mastodon',
|
||||
operation_id="start_mastodon",
|
||||
)
|
||||
async def mastodon_start(mastodon=Depends(get_mastodon)):
|
||||
await mastodon.update(enabled=True)
|
||||
|
@ -121,10 +121,10 @@ async def mastodon_start(mastodon=Depends(get_mastodon)):
|
|||
|
||||
|
||||
@router.post(
|
||||
'/{mastodon_id}/stop',
|
||||
"/{mastodon_id}/stop",
|
||||
status_code=status.HTTP_200_OK,
|
||||
# TODO response_model
|
||||
operation_id='stop_mastodon',
|
||||
operation_id="stop_mastodon",
|
||||
)
|
||||
async def mastodon_stop(mastodon=Depends(get_mastodon)):
|
||||
await mastodon.update(enabled=False)
|
||||
|
@ -133,10 +133,10 @@ async def mastodon_stop(mastodon=Depends(get_mastodon)):
|
|||
|
||||
|
||||
@router.post(
|
||||
'/',
|
||||
"/",
|
||||
status_code=status.HTTP_201_CREATED,
|
||||
# TODO response_model
|
||||
operation_id='create_mastodon',
|
||||
operation_id="create_mastodon",
|
||||
)
|
||||
async def mastodon_create(instance_url, username, password, hood=Depends(get_hood)):
|
||||
"""Add a Mastodon Account to a Ticketfrei account.
|
||||
|
|
Loading…
Reference in a new issue