Conditions | 8 |
Total Lines | 29 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | #!/usr/bin/python |
||
14 | def liquid(bot, update): |
||
15 | if update.message.reply_to_message is not None: |
||
16 | parts = update.message.text.split(" ", 1) |
||
17 | else: |
||
18 | parts = update.message.caption.split(" ", 1) |
||
19 | if len(parts) == 1: |
||
20 | power = 60 |
||
21 | else: |
||
22 | try: |
||
23 | power = int(parts[1]) |
||
24 | except: |
||
25 | update.message.reply_text("Paremeter needs to be a number!") |
||
26 | return |
||
27 | if power > 100 or power < 1: |
||
28 | update.message.reply_text("Baka, make it from 1 to 100!") |
||
29 | return |
||
30 | try: |
||
31 | get_image(bot, update, path) |
||
32 | except: |
||
33 | update.message.reply_text("I can't get the image! :(") |
||
34 | return |
||
35 | id = subprocess.Popen("identify " + path + "original.jpg", stdout=subprocess.PIPE).communicate()[0] |
||
|
|||
36 | res = str(id.split()[2])[2:-1] |
||
37 | size = str(100 - (power / 1.3)) |
||
38 | x = "convert " + path + "original.jpg -liquid-rescale " + size + "%x" + size + "% -resize " + res + "! " + path + "liquid.jpg" |
||
39 | subprocess.run(x, shell=True) |
||
40 | with open(path + "liquid.jpg", "rb") as f: |
||
41 | update.message.reply_photo(f) |
||
42 | print(datetime.datetime.now(), ">>>", "Done liquid rescale", ">>>", update.message.from_user.username) |
||
43 |
It is generally discouraged to redefine built-ins as this makes code very hard to read.