| Conditions | 7 |
| Total Lines | 27 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| Bugs | 1 | Features | 1 |
| 1 | #!/usr/bin/python |
||
| 13 | def lego(bot, update): |
||
| 14 | if update.message.reply_to_message is not None: |
||
| 15 | parts = update.message.text.split(" ", 1) |
||
| 16 | else: |
||
| 17 | parts = update.message.caption.split(" ", 1) |
||
| 18 | if len(parts) == 1: |
||
| 19 | size = 60 |
||
| 20 | else: |
||
| 21 | try: |
||
| 22 | size = int(parts[1]) |
||
| 23 | except: |
||
| 24 | update.message.reply_text("Paremeter needs to be a number!") |
||
| 25 | return |
||
| 26 | if size > 100: |
||
| 27 | update.message.reply_text("Baka, make it from 1 to 100!") |
||
| 28 | return |
||
| 29 | try: |
||
| 30 | get_image(bot, update, lego_folder) |
||
| 31 | except: |
||
| 32 | update.message.reply_text("Can't get the image! :(") |
||
| 33 | return |
||
| 34 | legofy.main(image_path=lego_folder+"original.jpg", |
||
| 35 | output_path=lego_folder+"legofied.jpg", |
||
| 36 | size=size, palette_mode=None, dither=False) |
||
| 37 | with open(lego_folder+"legofied.jpg", "rb") as f: |
||
| 38 | update.message.reply_photo(f) |
||
| 39 | print(datetime.datetime.now(), ">>>", "Done legofying", ">>>", update.message.from_user.username) |