Exemplo n.º 1
0
 async def handle(self):
     self.client.header << website.Header(
         "Cache-Control", "public, max-age=604800, immutable")
     self.client.header << website.Header(
         "Content-Type", "aplication/javascript", "charset=utf-8")
     self.client.buffer << website.buffer.File(website.path +
                                               "resource/js/" +
                                               "/".join(self.request[1:]))
Exemplo n.º 2
0
 async def handle(self):
     self.client.header << website.Header(
         "Cache-Control", "public, max-age=604800, immutable")
     self.client.header << website.Header(
         "Content-Type",
         "image/" + self.request[-1].rsplit(".", 1)[-1].lower())
     self.client.buffer << website.buffer.File(website.path +
                                               "resource/image/" +
                                               "/".join(self.request[1:]))
Exemplo n.º 3
0
    async def handle(self):
        chat = self.request[self.segment-1] # or self.client.query["chatname"].title().replace("+", "").replace("%20", "")

        if chat not in self.client.session.chats: # Login
            if "chatpassword" not in self.client.query or chat not in dbc.chat or self.client.query["chatpassword"] != dbc.chat[chat].password:
                return Home(self)
            self.client.session.chats.add(chat)
        chat = dbc.chat[chat]

        if "msg" in self.client.query: # Message Request
            elms = self.client.query["elm"].split(";")
            dbi = chat.db(self.client.session.id)
            data = await Interface.gather(*(rchat.Message(self, chat, dbi, int(eid)) for eid in elms))
            self.client.header << website.Header("Content-Type", "text/html")
            self.client.buffer << "\n".join(filter(None, data))
            if elms:
                self.client.session.eid = int(elms[-1])
            return

        if "ig" in self.client.query: # IG Request
            coro = []
            for mtype, eid in [(i[0], i[1:]) for i in self.client.query["elm"].split(";")]:
                if mtype == "m":
                    coro.append(rchat.IGReq(self, chat, int(eid)))
                elif mtype == "p":
                    coro.append(rchat.ProfilePic(self, chat, int(eid)))
            return await Interface.gather(*coro)

        try:
            self.client.query["elm"] = int(self.request[self.segment])
        except (IndexError, ValueError):
            if "elm" not in self.client.query:
                self.client.query["elm"] = self.client.session.eid

        # try:
        return await self.tree.traverse(self, chat)
Exemplo n.º 4
0
    async def handle(self):
        try:
            self.client.header << website.Header("Content-Type", "text/html")
            data = await self.chat.ig.element(self.eid)
            if "media" not in data:
                return self.client.buffer << f"""<p id={self.eid} class="exp">Media Expired</p>"""
            media = data["media"]
            if media["type"] == "image":
                return self.client.buffer << f"""<img id="{self.eid}" src="{media["url"]}">"""
            elif media["type"] == "video":
                return self.client.buffer << f"""
                <video id="{self.eid}" width="{media["size"][0]}" height="{media["size"][1]}" loop controls autoplay muted>
                <source src="{media["url"]}">
                </video>"""
            elif media["type"] == "gif":
                return self.client.buffer << f"""<img id="{self.eid}" src="{media["url"]}">"""
            elif media["type"] == "audio":
                return self.client.buffer << f"""<audio id="{self.eid}" controls>
                <source src="{media["url"]}">
                </audio>"""

        except Exception as e:
            print("Err", data, type(e), e)
        return self.client.buffer << self.err()
Exemplo n.º 5
0
 async def handle(self):
     self.client.header << website.Header("Content-Type", "text/css")
     self.client.header << website.Header(
         "Cache-Control", "public, max-age=604800, immutable")
     await self.load_style("/".join(self.request[1:]))
Exemplo n.º 6
0
 async def handle(self):
     self.client.header << website.Header("Content-Type", "text/html")
     return self.client.buffer << f"""<img id={self.eid} class="onload" onload="chat.ext.mda(this, {self.eid}, 'p')" src="{(await self.chat.ig.profile(self.eid))["pfp"]}" onerror="chat.ext.img_err(this)" alt="/img/instagram/default_user.png">"""