-
Notifications
You must be signed in to change notification settings - Fork 3
/
utility.py
37 lines (34 loc) · 1.03 KB
/
utility.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
import qrcode
import os
from os import path
class Utility:
@classmethod
def getQRCodeImageFilePath(self, one_address):
if path.exists(f'qrcodes/{one_address}.png'):
return f'qrcodes/{one_address}.png'
qr = qrcode.QRCode(
version=1,
error_correction=qrcode.constants.ERROR_CORRECT_L,
box_size=10,
border=4,
)
qr.add_data(one_address)
qr.make(fit=True)
img = qr.make_image(fill_color="black", back_color="white")
if not path.exists('qrcodes'):
os.mkdir('qrcodes')
with open(f'qrcodes/{one_address}.png', 'wb') as f:
img.save(f)
return f'qrcodes/{one_address}.png'
@classmethod
def is_valid_amount(self, value):
try:
float(value)
if float(value) <= 0.00000000:
return False
return True
except:
return False
class GlobalVariables:
_logFileName = 'onetippingbot.log'
_minimumTip = float(0.000021)