Skip to content

Commit

Permalink
add videonote lock (#50)
Browse files Browse the repository at this point in the history
run the following in psql to add the necessary columns for videonote locks.
```
alter table permissions add column videonote bool default false;
```
  • Loading branch information
Peter Parker authored and MD Raza committed Jul 14, 2020
1 parent ec6e53c commit 095b2ed
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
tg_bot/config.py
*.pyc
.idea/
.project
.pydevproject
.directory
.vscode
6 changes: 4 additions & 2 deletions tg_bot/modules/locks.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
'voice': Filters.voice,
'document': Filters.document & ~Filters.animation,
'video': Filters.video,
'videonote': Filters.video_note,
'contact': Filters.contact,
'photo': Filters.photo,
'gif': Filters.animation,
Expand All @@ -34,7 +35,7 @@

GIF = Filters.animation
OTHER = Filters.game | Filters.sticker | GIF
MEDIA = Filters.audio | Filters.document | Filters.video | Filters.voice | Filters.photo
MEDIA = Filters.audio | Filters.document | Filters.video | Filters.video_note | Filters.voice | Filters.photo
MESSAGES = Filters.text | Filters.contact | Filters.location | Filters.venue | Filters.command | MEDIA | OTHER
PREVIEWS = Filters.entity("url")

Expand Down Expand Up @@ -249,6 +250,7 @@ def build_lock_message(chat_id):
"\n - voice = `{}`" \
"\n - document = `{}`" \
"\n - video = `{}`" \
"\n - videonote = `{}`" \
"\n - contact = `{}`" \
"\n - photo = `{}`" \
"\n - gif = `{}`" \
Expand All @@ -257,7 +259,7 @@ def build_lock_message(chat_id):
"\n - forward = `{}`" \
"\n - game = `{}`" \
"\n - location = `{}`".format(locks.sticker, locks.audio, locks.voice, locks.document,
locks.video, locks.contact, locks.photo, locks.gif, locks.url,
locks.video, locks.videonote, locks.contact, locks.photo, locks.gif, locks.url,
locks.bots, locks.forward, locks.game, locks.location)
if restr:
res += "\n - messages = `{}`" \
Expand Down
6 changes: 6 additions & 0 deletions tg_bot/modules/sql/locks_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Permissions(BASE):
voice = Column(Boolean, default=False)
contact = Column(Boolean, default=False)
video = Column(Boolean, default=False)
videonote = Column(Boolean, default=False)
document = Column(Boolean, default=False)
photo = Column(Boolean, default=False)
sticker = Column(Boolean, default=False)
Expand All @@ -30,6 +31,7 @@ def __init__(self, chat_id):
self.voice = False
self.contact = False
self.video = False
self.videonote = False
self.document = False
self.photo = False
self.sticker = False
Expand Down Expand Up @@ -108,6 +110,8 @@ def update_lock(chat_id, lock_type, locked):
curr_perm.contact = locked
elif lock_type == "video":
curr_perm.video = locked
elif lock_type == "videonote":
curr_perm.videonote = locked
elif lock_type == "document":
curr_perm.document = locked
elif lock_type == "photo":
Expand Down Expand Up @@ -173,6 +177,8 @@ def is_locked(chat_id, lock_type):
return curr_perm.contact
elif lock_type == "video":
return curr_perm.video
elif lock_type == "videonote":
return curr_perm.videonote
elif lock_type == "document":
return curr_perm.document
elif lock_type == "gif":
Expand Down

0 comments on commit 095b2ed

Please sign in to comment.