コード例 #1
0
ファイル: message.py プロジェクト: sealabr/whatsapp-framework
    def build(self):
        if helper.is_text_message(self.message_entity):
            self.message = helper.clean_message(self.message_entity)
            self.text = helper.clean_message(self.message_entity)
            self.put_command()
            self.valid = True

        elif helper.is_media_message(self.message_entity):
            try:
                self.file_path = downloader.get_file(self.message_entity)
                self.text = self.message_entity.getCaption()
                self.message = self.message_entity.getCaption()
                self.valid = True
            except:
                print("Unsupported media file")
        else:
            print("Unsupported message")
コード例 #2
0
def message_has_identifier(message_entity):
    for receiver in receivers:
        message = helper.clean_message(message_entity)
        id_len = len(receiver.identifier)
        if message[:id_len] == receiver.identifier:
            return receiver

    return None
コード例 #3
0
 def handle_answer(self, message_entity=None):
     message = helper.clean_message(message_entity)
     if is_youtube_url(message):
         try:
             yt = YouTube(message)
             video = yt.get('mp4', '720p')
             video.download('app/videos')
             path = "app/videos/" + yt.filename + ".mp4"
             mac.send_video(self.instance, self.conversation, path,
                            self.caption)
         except:
             print("Could send video")
コード例 #4
0
ファイル: mac_youtube.py プロジェクト: fakiehmaulana/MacBot
    def handle_answer(self, message_entity=None):
        message = helper.clean_message(message_entity)
        if is_youtube_url(message):
            yt = YouTube(message)
            video = get_default_video(yt)

            path = "app/assets/videos/" + yt.filename + ".mp4"
            if os.path.exists(path):
                os.remove(path)

            video.download('app/assets/videos')
            mac.send_video(self.instance,
                           self.conversation,
                           path,
                           caption="video")
コード例 #5
0
    def __init__(self, message_entity):
        self.message = helper.clean_message(message_entity)
        self.who = helper.get_who_send(message_entity)
        self.who_name = helper.sender_name(message_entity)
        self.conversation = message_entity.getFrom()
        self.message_entity = message_entity

        # These two attributes are just easier ways to identify instructions
        # But they are not really needed since you have the whole message
        # But I use these a lot so f**k it, lemme be happy
        # ===================================================================
        # command is what goes after '!'
        self.command = helper.command(message_entity)
        # predicate is what goes after the command
        self.predicate = helper.predicate(message_entity)
コード例 #6
0
 def build_text_message(self):
     self.message = helper.clean_message(self.message_entity)
     self.text = helper.clean_message(self.message_entity)
     self.put_command()
     self.valid = True