Esempio n. 1
0
class MediaViews():
    def __init__(self, interface_layer):
        """
            Creates the regex routes and callbacks to handle media messages
        """
        self.image_sender = ImageSender(interface_layer)
        self.video_sender = VideoSender(interface_layer)
        self.url_print_sender = UrlPrintSender(interface_layer)
        self.tts_sender = EspeakTtsSender(interface_layer)
        self.routes = [
            ("https?:\/\/(?:[\w\-]+\.)+[a-z]{2,6}(?:\/[^\/#?]+)+\.(?:jpe?g|gif|png)($|\?[^\s]+$)", self.send_image),
            ("https?:\/\/(?:[\w\-]+\.)+[a-z]{2,6}(?:\/[^\/#?]+)+\.(?:mp4|webm)($|\?[^\s]+$)", self.send_video),
            ("^!t(ts)?\s(?P<tts_text>[^$]+)$", self.send_tts)
        ]

    def send_video(self, message, match):
        self.video_sender.send_by_url(jid=message.getFrom(), file_url=message.getBody())

    def send_image(self, message, match):
        self.image_sender.send_by_url(jid=message.getFrom(), file_url=message.getBody())

    def send_url_print(self, message, match):
        url = message.getBody()
        self.url_print_sender.send_by_url(jid=message.getFrom(), file_url=url)

    def send_tts(self, message, match):
        tts_text = match.group("tts_text")
        self.tts_sender.send(jid=message.getFrom(), text=tts_text)
Esempio n. 2
0
class MediaViews():
    def __init__(self, interface_layer):
        """
            Creates the regex routes and callbacks to handle media messages
        """
        self.image_sender = ImageSender(interface_layer)
        self.video_sender = VideoSender(interface_layer)
        self.url_print_sender = UrlPrintSender(interface_layer)
        self.tts_sender = EspeakTtsSender(interface_layer)
        self.routes = [
            ("https?:\/\/(?:[\w\-]+\.)+[a-z]{2,6}(?:\/[^\/#?]+)+\.(?:jpe?g|gif|png)($|\?[^\s]+$)",
             self.send_image),
            ("https?:\/\/(?:[\w\-]+\.)+[a-z]{2,6}(?:\/[^\/#?]+)+\.(?:mp4|webm)($|\?[^\s]+$)",
             self.send_video), ("https?:\/\/[^$]+$", self.send_url_print),
            ("^/t(ts)?\s(?P<tts_text>[^$]+)$", self.send_tts)
        ]

    def send_video(self, message, match):
        self.video_sender.send_by_url(jid=message.getFrom(),
                                      file_url=message.getBody())

    def send_image(self, message, match):
        self.image_sender.send_by_url(jid=message.getFrom(),
                                      file_url=message.getBody())

    def send_url_print(self, message, match):
        url = message.getBody()
        self.url_print_sender.send_by_url(jid=message.getFrom(), file_url=url)

    def send_tts(self, message, match):
        tts_text = match.group("tts_text")
        self.tts_sender.send(jid=message.getFrom(), text=tts_text)
Esempio n. 3
0
 def __init__(self, interface_layer):
     """
         Creates the regex routes and callbacks to handle media messages
     """
     self.image_sender = ImageSender(interface_layer)
     self.video_sender = VideoSender(interface_layer)
     self.url_print_sender = UrlPrintSender(interface_layer)
     self.tts_sender = EspeakTtsSender(interface_layer)
     self.routes = []
Esempio n. 4
0
 def __init__(self, interface_layer):
     """
         Creates the regex routes and callbacks to handle media messages
     """
     self.image_sender = ImageSender(interface_layer)
     self.video_sender = VideoSender(interface_layer)
     self.url_print_sender = UrlPrintSender(interface_layer)
     self.tts_sender = EspeakTtsSender(interface_layer)
     self.routes = [
         ("https?:\/\/(?:[\w\-]+\.)+[a-z]{2,6}(?:\/[^\/#?]+)+\.(?:jpe?g|gif|png)($|\?[^\s]+$)", self.send_image),
         ("https?:\/\/(?:[\w\-]+\.)+[a-z]{2,6}(?:\/[^\/#?]+)+\.(?:mp4|webm)($|\?[^\s]+$)", self.send_video),
         ("https?:\/\/[^$]+$", self.send_url_print),
         ("^/g(ravar)?\s(?P<tts_text>[^$]+)$", self.send_tts)
     ]
Esempio n. 5
0
 def __init__(self, interface_layer):
     self.image_sender = ImageSender(interface_layer)
     self.video_sender = VideoSender(interface_layer)
     self.yt_sender = YoutubeSender(interface_layer)
     self.url_print_sender = UrlPrintSender(interface_layer)
     self.routes = [
         (".*https?:\/\/(?:www\.|m\.)?youtu(?:be.com\/watch\?v=|\.be/)(?P<video_id>[\w-]+)(&\S*)?$",
          self.send_yt_video),
         ("/s(earch)?\s(?P<term>[^$]+)$", self.google_search),
     ]
 def __init__(self, interface_layer):
     """
         Creates the regex routes and callbacks to handle media messages
     """
     self.image_sender = ImageSender(interface_layer)
     self.video_sender = VideoSender(interface_layer)
     self.url_print_sender = UrlPrintSender(interface_layer)
     self.routes = [
         ("https?:\/\/(?:[\w\-]+\.)+[a-z]{2,6}(?:\/[^\/#?]+)+\.(?:jpe?g|gif|png)($|\?[^\s]+$)", self.send_image),
         ("https?:\/\/(?:[\w\-]+\.)+[a-z]{2,6}(?:\/[^\/#?]+)+\.(?:mp4|webm)($|\?[^\s]+$)", self.send_video),
         ("https?:\/\/[^$]+$", self.send_url_print),
     ]
Esempio n. 7
0
 def __init__(self, interface_layer):
     self.image_sender = ImageSender(interface_layer)
     self.video_sender = VideoSender(interface_layer)
     self.yt_sender = YoutubeSender(interface_layer)
     self.url_print_sender = UrlPrintSender(interface_layer)
     self.google_tts_sender = GoogleTtsSender(interface_layer)
     self.routes = [
         (".*https?:\/\/(?:www\.|m\.)?youtu(?:be.com\/watch\?v=|\.be/)(?P<video_id>[\w-]+)(&\S*)?$",
          self.send_yt_video),
         ("/t(ts)?\s(?P<text>[^\[]{1,500})\s?\[?(?P<lang>[A-Za-z\-]{2,6})?\]?$",
          self.send_tts),
         ("/s(earch)?\s(?P<term>[^$]+)$", self.google_search),
         ("/i(mage)?\s(?P<term>[^$]+)$", self.google_image_search)
     ]
Esempio n. 8
0
class MediaViews():
    def __init__(self, interface_layer):
        """
            Creates the regex routes and callbacks to handle media messages
        """
        self.image_sender = ImageSender(interface_layer)
        self.video_sender = VideoSender(interface_layer)
        self.url_print_sender = UrlPrintSender(interface_layer)
        self.tts_sender = EspeakTtsSender(interface_layer)
        self.routes = []

    def send_video(self, message, match):
        self.video_sender.send_by_url(jid=message.getFrom(), file_url=message.getBody())

    def send_image(self, message, match):
        self.image_sender.send_by_url(jid=message.getFrom(), file_url=message.getBody())

    def send_url_print(self, message, match):
        url = message.getBody()
        self.url_print_sender.send_by_url(jid=message.getFrom(), file_url=url)

    def send_tts(self, message, match):
        tts_text = match.group("tts_text")
        self.tts_sender.send(jid=message.getFrom(), text=tts_text)
Esempio n. 9
0
 def __init__(self, interface_layer):
     """
         Creates the regex routes and callbacks to handle media messages
     """
     self.image_sender = ImageSender(interface_layer)
     self.video_sender = VideoSender(interface_layer)
     self.url_print_sender = UrlPrintSender(interface_layer)
     self.tts_sender = EspeakTtsSender(interface_layer)
     self.routes = [
         ("https?:\/\/(?:[\w\-]+\.)+[a-z]{2,6}(?:\/[^\/#?]+)+\.(?:jpe?g|gif|png)($|\?[^\s]+$)", self.send_image),
         ("https?:\/\/(?:[\w\-]+\.)+[a-z]{2,6}(?:\/[^\/#?]+)+\.(?:mp4|webm)($|\?[^\s]+$)", self.send_video),
         # ("https?:\/\/[^$]+$", self.send_url_print),
         ("^/t(ts)?\s(?P<tts_text>[^$]+)$", self.send_tts)
         # ("/w(isdom)?\s([\"])(?P<top>[^\"$]+)\"\s([\"])(?P<bottom>[^$]+)([\"])", self.send_wisdom)
     ]