Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def toot(cls, ctx, acc, visibility=None, in_reply_to=None):
m = cls.get_session(acc)
if ctx.msg.is_image() or ctx.msg.is_gif() or ctx.msg.is_video() or ctx.msg._view_type in (dc.const.DC_MSG_AUDIO, dc.const.DC_MSG_VOICE):
if ctx.msg.filename.endswith('.aac'):
aac_file = AudioSegment.from_file(ctx.msg.filename, 'aac')
filename = ctx.msg.filename[:-4]+'.mp3'
aac_file.export(filename, format='mp3')
else:
filename = ctx.msg.filename
media = [m.media_post(filename).id]
if in_reply_to:
m.status_reply(m.status(in_reply_to), ctx.text,
media_ids=media, visibility=visibility)
else:
m.status_post(ctx.text, media_ids=media, visibility=visibility)
elif ctx.text:
if in_reply_to:
m.status_reply(m.status(in_reply_to),
ctx.text, visibility=visibility)