예제 #1
0
def audio_callback(bot, event):
    source_uin = event.data["source"]["aimId"]
    file_meta = decode_file_id(
        re.search(MessageFilter._FileFilter.FILE_URL_REGEXP,
                  event.data["message"].strip()).group("file_id"))
    bot.send_im(
        target=source_uin,
        message=
        "Audio '{audio}' (length is '{length}') received from '{source_uin}'.".
        format(source_uin=source_uin,
               audio=event.data["message"],
               length=file_meta.length))
예제 #2
0
def image_callback(bot, event):
    source_uin = event.data["source"]["aimId"]
    file_meta = decode_file_id(
        re.search(MessageFilter._FileFilter.FILE_URL_REGEXP,
                  event.data["message"].strip()).group("file_id"))
    bot.send_im(
        target=source_uin,
        message=
        "Image '{image}' (size is '{width}x{height}') received from '{source_uin}'."
        .format(source_uin=source_uin,
                image=event.data["message"],
                width=file_meta.width,
                height=file_meta.height))
예제 #3
0
def video_cb(bot, event):
    source = event.data["source"]["aimId"]
    file_meta = decode_file_id(
        re.search(MessageFilter._FileFilter.FILE_URL_REGEXP,
                  event.data["message"].strip()).group("file_id"))
    bot.send_im(
        target=source,
        message=
        "Video '{video}' (size is '{width}x{height}') received from '{source}'."
        .format(source=source,
                video=event.data["message"],
                width=file_meta.width,
                height=file_meta.height))
예제 #4
0
 def filter(self, event):
     match = MessageFilter.file(event)
     return match and type(
         decode_file_id(match.group("file_id")).file_type) is AudioType