-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathutils.py
60 lines (43 loc) · 2.42 KB
/
utils.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
from pony.orm import *
from pyrogram.types import Message
from os import listdir
# ========= DB build =========
db = Database()
class User(db.Entity):
uid = PrimaryKey(int, auto=True)
status = Required(int) # status-user: "INSERT"/"NOT-INSERT"
db.bind(provider='sqlite', filename='zipbot.sqlite', create_db=True)
db.generate_mapping(create_tables=True)
# ========= helping func =========
def dir_work(uid: int) -> str:
""" static-user folder """
return f"static/{uid}/"
def zip_work(uid: int) -> str:
""" zip-archive file """
return f'static/{uid}.zip'
def list_dir(uid: int) -> list:
""" items in static-user folder """
return listdir(dir_work(uid))
def up_progress(current, total, msg: Message):
""" edit status-msg with progress of the uploading """
msg.edit(f"**התקדמות ההעלאה: {current * 100 / total:.1f}%**")
# ========= MSG class =========
class Msg:
def start(msg: Message) -> str:
""" return start-message text """
txt = f"[](https://github.com/M100achuz2/archive-bot.git)היי {msg.from_user.mention}!\n" \
"באמצעות בוט זה תוכלו לדחוס קבצים לארכיון. שלחו /zip, ופעלו על פי ההוראות." \
"\n\nרובוט זה נוצר על ידי [Yeuda-By](t.me/m100achuzBots) מצוות [רובוטריק](t.me/robottrick)." \
"\nלקוד המקור [לחצו כאן](https://github.com/M100achuz2/archive-bot)."
return txt
zip = "שלחו את הקבצים שהנכם רוצים לדחוס, ובסיום שלחו /stopzip לאחר שכל הקבצים ירדו. \n`הבוט תומך בקבצים עד 20mb, " \
"ועד 20 קבצים לארכיון אחד.` "
too_big = "הקובץ גדול מידי ):"
too_much = "ניתן לדחוס עד 20 קבצים בלבד."
send_zip = "השתמשו בפקודת /zip בשביל לדחוס קבצים (:"
zipping = "מתחיל בדחיסת {} קבצים..."
uploading = "מעלה ארכיון..."
unknow_error = "התרחשה שגיאה לא ידועה. \nשים לב לסדר הפעולות, ניתן להתחיל מחדש על ידי שליחת /start. \nבדוק אם " \
"שלחת קבצים לדחיסה, ואם חיכית שכולם ירדו. \nבבקשה שלח זה למפתח:\n ```{}``` "
downloading = "מוריד קובץ:"
zero_files = "לא נשלחו קבצים."