Ejemplo n.º 1
0
def setup_logging():
    verbose = Config.getboolean('Logging', 'VerboseStdout')
    console = logging.StreamHandler()
    console.setLevel(logging.INFO if verbose else logging.WARNING)
    logfile = logging.FileHandler(Config.get('Logging', 'Logfile'))
    logfile.setLevel(logging.INFO)
    logging.basicConfig(
        format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
        level=logging.INFO,
        handlers=[console, logfile])
Ejemplo n.º 2
0
def video(update: Update, context: CallbackContext):
    if not update.message:
        return
    ci, fro, fron, froi = cifrofron(update)
    vid = update.message.video
    fid = vid.file_id
    attr = '%dx%d; length=%d; type=%s' % (vid.width, vid.height, vid.duration,
                                          vid.mime_type)
    size = vid.file_size
    logging.info('%s/%s: video, %d, %s, %s' % (fron, fro, size, fid, attr))
    if (Config.getboolean('Download', 'Video', fallback=True)):
        download_file(context.bot, 'video', fid, fid + '.mp4')
    log_file('video',
             size,
             attr,
             fid,
             conversation=update.message.chat,
             user=update.message.from_user)
Ejemplo n.º 3
0
def document(update: Update, context: CallbackContext):
    if not update.message:
        return
    ci, fro, fron, froi = cifrofron(update)
    doc = update.message.document
    fid = doc.file_id
    size = doc.file_size
    name = doc.file_name
    if not name:
        name = '_unnamed_.mp4'
    attr = 'type=%s; name=%s' % (doc.mime_type, name)
    logging.info('%s/%s: document, %d, %s, %s' % (fron, fro, size, fid, attr))
    if (Config.getboolean('Download', 'Document', fallback=True)):
        download_file(context.bot, 'document', fid, fid + ' ' + name)
    log_file('document',
             size,
             attr,
             fid,
             conversation=update.message.chat,
             user=update.message.from_user)
Ejemplo n.º 4
0
def audio(update: Update, context: CallbackContext):
    if not update.message:
        return
    ci, fro, fron, froi = cifrofron(update)
    aud = update.message.audio
    fid = aud.file_id
    size = aud.file_size
    ext = '.ogg'
    if aud.mime_type == 'audio/mp3':
        ext = '.mp3'
    attr = 'type=%s; duration=%d; performer=%s; title=%s' % (
        aud.mime_type, aud.duration, aud.performer, aud.title)
    logging.info('%s/%s: audio, %d, %s, %s' % (fron, fro, size, fid, attr))
    if (Config.getboolean('Download', 'Audio', fallback=True)):
        download_file(context.bot, 'audio', fid,
                      '%s %s - %s%s' % (fid, aud.performer, aud.title, ext))
    log_file('audio',
             size,
             attr,
             fid,
             conversation=update.message.chat,
             user=update.message.from_user)