-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathscreenshot.py
79 lines (66 loc) · 2.23 KB
/
screenshot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# -*- coding: utf-8 -*-
# Module author: @GovnoCodules
# requires: pygments
import io
import logging
import os
import pygments
from pygments.formatters import ImageFormatter
from pygments.lexers import Python3Lexer
from requests import get
from .. import loader, utils
logger = logging.getLogger(__name__)
@loader.tds
class WebShotMod(loader.Module):
"""Screenshot module"""
strings = {"name": "Screenshot"}
async def client_ready(self, client, db):
self.client = client
def __init__(self):
self.name = self.strings["name"]
@loader.sudo
async def webshotcmd(self, message):
"""Reply to link"""
reply = None
link = utils.get_args_raw(message)
if not link:
reply = await message.get_reply_message()
if not reply:
await message.delete()
return
link = reply.raw_text
await message.edit("<b>Screenshotting...</b>")
url = "https://webshot.deam.io/{}/?width=1920&height=1080?type=png"
file = get(url.format(link))
if not file.ok:
await message.edit("<b>Something went wrong...</b>")
return
file = io.BytesIO(file.content)
file.name = "webScreenshot.png"
file.seek(0)
await message.client.send_file(message.to_id, file, reply_to=reply)
await message.delete()
async def fileshotcmd(self, message):
"""Reply to file"""
await message.edit("<b>Screenshotting...</b>")
reply = await message.get_reply_message()
if not reply:
await message.edit("<b>reply to file.py</b>")
return
media = reply.media
if not media:
await message.edit("<b>reply to file.py</b>")
return
file = await message.client.download_file(media)
text = file.decode("utf-8")
pygments.highlight(
text,
Python3Lexer(),
ImageFormatter(font_name="DejaVu Sans Mono", line_numbers=True),
"fileScreenshot.png",
)
await message.client.send_file(
message.to_id, "fileScreenshot.png", force_document=True
)
os.remove("fileScreenshot.png")
await message.delete()