def execute(bot, data, forward=True): args = {"peer_id": data['peer_id'], "v": "5.60", } if forward: args.update({"forward_messages": data['message_id']}) atts = data['attachments'] Topost = [] for att in atts: try: photo = bot.GetBiggesPic(att, data['message_id']) except: return 'Error' req = urllib.request.Request(photo, headers=HDR) img = urlopen(req).read() Tmp = TempFile(img, 'jpg') att = bot.UploadFromDisk(Tmp.path_) Topost.append(att) Tmp.cachefile(Tmp.path_) Tmp.rem() args['attachment'] = Topost bot.Replyqueue.put(args) return True
def execute(bot, data): args = {"peer_id": data['peer_id'], "v": "5.60", "forward_messages": data['message_id']} sigma = int(data['custom']['sigma']) if 'sigma' in data['custom'] else 5 iter = int(data['custom']['iter']) if 'iter' in data['custom'] else 150 size = int(data['custom']['size']) if 'size' in data['custom'] else 32 Glitch_ = bool(data['custom']['color']) if 'color' in data['custom'] else True random_ = bool(data['custom']['rand']) if 'rand' in data['custom'] else True atts = data['attachments'] Topost = [] for att in atts: try: photo = bot.GetBiggesPic(atts[0], data['message_id']) except: return False req = urllib.request.Request(photo, headers=HDR) img = urlopen(req).read() Tmp = TempFile(img, 'jpg') Glitch(file=Tmp.path_, sigma=sigma, blockSize=size, iterations=iter, random_=random_, Glitch_=Glitch_) Tmp.cachefile(Tmp.path_) att = bot.UploadFromDisk(Tmp.path_) Topost.append(att) Tmp.rem() args['message'] = ':D' args['attachment'] = Topost bot.Replyqueue.put(args) return True
def execute(bot, data, forward=True): args = { "peer_id": data['peer_id'], "v": "5.60", } if forward: args.update({"forward_messages": data['message_id']}) atts = data['attachments'] try: photo = bot.GetBiggesPic(atts[0], data['message_id']) except: return False req = urllib.request.Request(photo, headers=HDR) img = urlopen(req).read() Tmp = TempFile(img, 'jpg', NoCache=True) args['message'] = 'Список фильтров:\n' FArr = dict(enumerate(bot.MODULES.FILTERS)) for filter_ in FArr: Fname = bot.MODULES.FILTERS[FArr[filter_]].desc args['message'] += "{}. {}\n".format(filter_ + 1, Fname) bot.Replyqueue.put(args) print(data['user_id'], data['peer_id']) t = Trigger( cond=lambda Tdata: Tdata['user_id'] == data['user_id'] and Tdata[ 'peer_id'] == data['peer_id'] and Tdata['message'].isnumeric(), callback=Command_Filter.Render, Tmp=Tmp, bot=bot, args=args, FArr=FArr) bot.TRIGGERS.addTrigger(t)
def execute(bot, data, forward=True): args = {"peer_id": data['peer_id'], "v": "5.60", } if forward: args.update({"forward_messages": data['message_id']}) sigma = int(data['custom']['sigma']) if 'sigma' in data['custom'] else 5 iter = int(data['custom']['iter']) if 'iter' in data['custom'] else 150 size = int(data['custom']['size']) if 'size' in data['custom'] else 32 vsh = bool(data['custom']['vsh']) if 'vsh' in data['custom'] else False Glitch_ = bool(data['custom']['color']) if 'color' in data['custom'] else True len_ = int(data['custom']['len']) if 'len' in data['custom'] else 60 random_ = bool(data['custom']['rand']) if 'rand' in data['custom'] else True atts = data['attachments'] Topost = [] for att in atts: print(att) try: if att['type'] == 'doc': try: gif = att['doc']['url'] except: return False req = urllib.request.Request(gif, headers=HDR) img = urlopen(req).read() Tmp = TempFile(img, 'gif') file = GlitchGif(Tmp.path_, sigma=sigma, blockSize=size, iterations=iter, random_=random_, Glitch_=Glitch_) doc, t = bot.UploadDocFromDisk(file) Tmp.rem() os.remove(file) Topost.append(doc) except: pass try: photo = bot.GetBiggesPic(atts[0], data['message_id']) req = urllib.request.Request(photo, headers=HDR) img = urlopen(req).read() Tmp = TempFile(img, 'jpg') file = MakeGlitchGif(image=Tmp.path_, len_=len_, sigma=sigma, blockSize=size, iterations=iter, random_=random_, Glitch_=Glitch_) if not vsh else MakeGlitchGifVSH(Tmp.path_, sigma=sigma, blockSize=size, iterations=iter, random_=random_, Glitch_=Glitch_) doc, t = bot.UploadDocFromDisk(file) Tmp.cachefile(file) os.remove(file) Topost.append(doc) Tmp.rem() except: return False args['message'] = ':D' args['attachment'] = Topost bot.Replyqueue.put(args) return True
def textPlain(text, size, font='times.ttf', x=100, y=200, xsize=1280, ysize=720): im = Image.new('RGB', (xsize, ysize), color=(255, 255, 255)) draw = ImageDraw.Draw(im) font = ImageFont.truetype(font, int(size)) draw.text((x, y), text, font=font, fill=(0, 0, 0, 255)) _path = TempFile.generatePath('png') im.save(_path) return _path
def execute(bot, data, forward=True): args = { "peer_id": data['peer_id'], "v": "5.60", } if forward: args.update({"forward_messages": data['message_id']}) delta = int(args['delta']) if 'delta' in data['custom'] else 20 atts = data['attachments'] Topost = [] for att in atts: try: photo = bot.GetBiggesPic(att, data['message_id']) except: return False req = urllib.request.Request(photo, headers=HDR) img = urlopen(req).read() Tmp = TempFile(img, 'jpg') roll(Tmp.path_, delta) Tmp.cachefile(Tmp.path_) att = bot.UploadFromDisk(Tmp.path_) Topost.append(att) Tmp.rem() args['attachment'] = Topost args['message'] = ':D' bot.Replyqueue.put(args)
def execute(bot, data, forward=True): args = {"peer_id": data['peer_id'], "v": "5.60", } if forward: args.update({"forward_messages": data['message_id']}) atts = data['attachments'] # print(atts) Topost = [] if len(atts) != 2: args['message'] = 'Нужно 2 фотографии' bot.Replyqueue.put(args) return False try: photo = bot.GetBiggesPic(atts[0], data['message_id']) except: return False try: photo1 = bot.GetBiggesPic(atts[1], data['message_id']) except: return False req = urllib.request.Request(photo, headers=HDR) req1 = urllib.request.Request(photo1, headers=HDR) img = urlopen(req).read() img1 = urlopen(req1).read() Tmp = TempFile(img, 'jpg') Tmp1 = TempFile(img1, 'jpg') Wanted(Tmp.path_, Tmp1.path_) att = bot.UploadFromDisk(Tmp.path_) Topost.append(att) Tmp.rem() Tmp1.rem() args['attachment'] = Topost bot.Replyqueue.put(args)
def execute(bot, data, forward=True): args = { "peer_id": data['peer_id'], "v": "5.60", } if forward: args.update({"forward_messages": data['message_id']}) atts = data['attachments'] Topost = [] for att in atts: try: photo = bot.GetBiggesPic(att, data['message_id']) except: return 'Error' req = urllib.request.Request(photo, headers=HDR) img = urlopen(req).read() Tmp = TempFile(img, 'jpg') att = bot.UploadFromDisk(Tmp.path_) Topost.append(att) Tmp.cachefile(Tmp.path_) Tmp.rem() args['attachment'] = Topost bot.Replyqueue.put(args) return True
def execute(bot, data, forward=True): args = { "peer_id": data['peer_id'], "v": "5.60", } if forward: args.update({"forward_messages": data['message_id']}) im = ImageGrab.grab() pt = TempFile.generatePath('jpg') im.save(pt) att = bot.UploadFromDisk(pt) os.remove(pt) args['attachment'] = att bot.Replyqueue.put(args)
def execute(bot, data, forward=True): args = {"peer_id": data['peer_id'], "v": "5.60", } if forward: args.update({"forward_messages": data['message_id']}) atts = data['attachments'] # print(atts) Topost = [] try: photo = bot.GetBiggesPic(atts[0], data['message_id']) req = urllib.request.Request(photo, headers=HDR) img = urlopen(req).read() Tmp = TempFile(img, 'jpg') Tmp.cachefile(Tmp.path_) JonTron(Tmp.path_) att = bot.UploadFromDisk(Tmp.path_) Tmp.rem() except: text = data["custom"]['text'] if 'text' in data["custom"] else 'Meh...' size = data["custom"]['size'] if 'size' in data["custom"] else 120 font = data["custom"]['font'] if 'font' in data["custom"] else 'times.ttf' x = int(data["custom"]['x']) if 'x' in data["custom"] else 100 y = int(data["custom"]['y']) if 'y' in data["custom"] else 150 if text == None: return False _path = textPlain(text, size, font, x, y, 512, 512) JonTron(_path) att = bot.UploadFromDisk(_path) os.remove(_path) del _path Topost.append(att) args['attachment'] = Topost bot.Replyqueue.put(args)
def execute(bot, data, forward=True): args = { "peer_id": data['peer_id'], "v": "5.60", } if forward: args.update({"forward_messages": data['message_id']}) atts = data['attachments'] if 'size' in data['custom']: x = int(data['custom']['size']) if x > 3000: args['message'] = "Неее, слишком жирно" bot.Replyqueue.put(args) return False else: args['message'] = "Размер не указан" bot.Replyqueue.put(args) return False Topost = [] for att in atts: try: photo = bot.GetBiggesPic(att, data['message_id']) except: return False req = urllib.request.Request(photo, headers=HDR) img = urlopen(req).read() Tmp = TempFile(img, 'jpg', NoCache=True) args['message'] = 'Поднимать резкость?\n Да\Нет' bot.Replyqueue.put(args) ans = bot.WaitForMSG(5, data) t = Trigger(cond=lambda Tdata: Tdata['user_id'] == data[ 'user_id'] and Tdata['peer_id'] == data['peer_id'] and (re.match(r'(Д|д)а', Tdata['message']) or re.match( r'(Н|н)ет', Tdata['message'])), callback=Command_Resize.resize, Tmp=Tmp, bot=bot, args=args) bot.TRIGGERS.addTrigger(t)
def execute(bot, data, forward=True): args = { "peer_id": data['peer_id'], "v": "5.60", } if forward: args.update({"forward_messages": data['message_id']}) atts = data['attachments'] # print(atts) Topost = [] if len(atts) != 2: args['message'] = 'Нужно 2 фотографии' bot.Replyqueue.put(args) return False try: photo = bot.GetBiggesPic(atts[0], data['message_id']) except: return False try: photo1 = bot.GetBiggesPic(atts[1], data['message_id']) except: return False req = urllib.request.Request(photo, headers=HDR) req1 = urllib.request.Request(photo1, headers=HDR) img = urlopen(req).read() img1 = urlopen(req1).read() Tmp = TempFile(img, 'jpg') Tmp1 = TempFile(img1, 'jpg') Wanted(Tmp.path_, Tmp1.path_) att = bot.UploadFromDisk(Tmp.path_) Topost.append(att) Tmp.rem() Tmp1.rem() args['attachment'] = Topost bot.Replyqueue.put(args)
def execute(bot, data, forward=True): args = { "peer_id": data['peer_id'], "v": "5.60", } if forward: args.update({"forward_messages": data['message_id']}) sigma = int( data['custom']['sigma']) if 'sigma' in data['custom'] else 5 iter = int(data['custom']['iter']) if 'iter' in data['custom'] else 150 size = int(data['custom']['size']) if 'size' in data['custom'] else 32 Glitch_ = bool( data['custom']['color']) if 'color' in data['custom'] else True random_ = bool( data['custom']['rand']) if 'rand' in data['custom'] else True atts = data['attachments'] Topost = [] for att in atts: try: photo = bot.GetBiggesPic(atts[0], data['message_id']) except: return False req = urllib.request.Request(photo, headers=HDR) img = urlopen(req).read() Tmp = TempFile(img, 'jpg') Glitch(file=Tmp.path_, sigma=sigma, blockSize=size, iterations=iter, random_=random_, Glitch_=Glitch_) Tmp.cachefile(Tmp.path_) att = bot.UploadFromDisk(Tmp.path_) Topost.append(att) Tmp.rem() args['message'] = ':D' args['attachment'] = Topost bot.Replyqueue.put(args) return True
def execute(bot, data, forward=True): args = { "peer_id": data['peer_id'], "v": "5.60", } if forward: args.update({"forward_messages": data['message_id']}) atts = data['attachments'] # print(atts) Topost = [] try: photo = bot.GetBiggesPic(atts[0], data['message_id']) req = urllib.request.Request(photo, headers=HDR) img = urlopen(req).read() Tmp = TempFile(img, 'jpg') Tmp.cachefile(Tmp.path_) JonTron(Tmp.path_) att = bot.UploadFromDisk(Tmp.path_) Tmp.rem() except: text = data["custom"]['text'] if 'text' in data[ "custom"] else 'Meh...' size = data["custom"]['size'] if 'size' in data["custom"] else 120 font = data["custom"]['font'] if 'font' in data[ "custom"] else 'times.ttf' x = int(data["custom"]['x']) if 'x' in data["custom"] else 100 y = int(data["custom"]['y']) if 'y' in data["custom"] else 150 if text == None: return False _path = textPlain(text, size, font, x, y, 512, 512) JonTron(_path) att = bot.UploadFromDisk(_path) os.remove(_path) del _path Topost.append(att) args['attachment'] = Topost bot.Replyqueue.put(args)
def execute(bot, data, forward=True): args = { "peer_id": data['peer_id'], "v": "5.60", } if forward: args.update({"forward_messages": data['message_id']}) try: att = data['attachments'][0] print(att) photo = bot.GetBiggesPic(att, data['message_id']) except: return False req = urllib.request.Request(photo, headers=HDR) img = urlopen(req).read() Tmp = TempFile(img, 'jpg', NoCache=True) kek(Tmp.path_) att = bot.UploadFromDisk(Tmp.path_) Tmp.cachefile(Tmp.path_) Tmp.rem() args['attachment'] = att bot.Replyqueue.put(args)
def execute(bot, data, forward=True): args = { "peer_id": data['peer_id'], "v": "5.60", } if forward: args.update({"forward_messages": data['message_id']}) sigma = int( data['custom']['sigma']) if 'sigma' in data['custom'] else 5 iter = int(data['custom']['iter']) if 'iter' in data['custom'] else 150 size = int(data['custom']['size']) if 'size' in data['custom'] else 32 vsh = bool(data['custom']['vsh']) if 'vsh' in data['custom'] else False Glitch_ = bool( data['custom']['color']) if 'color' in data['custom'] else True len_ = int(data['custom']['len']) if 'len' in data['custom'] else 60 random_ = bool( data['custom']['rand']) if 'rand' in data['custom'] else True atts = data['attachments'] Topost = [] for att in atts: print(att) try: if att['type'] == 'doc': try: gif = att['doc']['url'] except: return False req = urllib.request.Request(gif, headers=HDR) img = urlopen(req).read() Tmp = TempFile(img, 'gif') file = GlitchGif(Tmp.path_, sigma=sigma, blockSize=size, iterations=iter, random_=random_, Glitch_=Glitch_) doc, t = bot.UploadDocFromDisk(file) Tmp.rem() os.remove(file) Topost.append(doc) except: pass try: photo = bot.GetBiggesPic(atts[0], data['message_id']) req = urllib.request.Request(photo, headers=HDR) img = urlopen(req).read() Tmp = TempFile(img, 'jpg') file = MakeGlitchGif( image=Tmp.path_, len_=len_, sigma=sigma, blockSize=size, iterations=iter, random_=random_, Glitch_=Glitch_) if not vsh else MakeGlitchGifVSH( Tmp.path_, sigma=sigma, blockSize=size, iterations=iter, random_=random_, Glitch_=Glitch_) doc, t = bot.UploadDocFromDisk(file) Tmp.cachefile(file) os.remove(file) Topost.append(doc) Tmp.rem() except: return False args['message'] = ':D' args['attachment'] = Topost bot.Replyqueue.put(args) return True