-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7439fbb
commit 9de4c04
Showing
42 changed files
with
991 additions
and
421 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
# uvloop.install() # Comment it out if using on windows | ||
Gojo().run() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from threading import RLock | ||
from time import time | ||
|
||
from Powers import LOGGER | ||
from Powers.database import MongoDB | ||
|
||
INSERTION_LOCK = RLock() | ||
|
||
|
||
class AUTOJOIN(MongoDB): | ||
"""class to store auto join requests""" | ||
|
||
db_name = "autojoin" | ||
|
||
def __init__(self) -> None: | ||
super().__init__(self.db_name) | ||
|
||
def load_autojoin(self, chat,mode="auto"): | ||
""" | ||
type = auto or notify | ||
auto to auto accept join requests | ||
notify to notify the admins about the join requests | ||
""" | ||
curr = self.find_one({"chat_id":chat,}) | ||
if not curr: | ||
with INSERTION_LOCK: | ||
self.insert_one({"chat_id":chat,"type":mode}) | ||
return True | ||
return False | ||
|
||
def get_autojoin(self,chat): | ||
curr = self.find_one({"chat_id":chat}) | ||
if not curr: | ||
return False | ||
else: | ||
return curr["type"] | ||
|
||
def update_join_type(self,chat,mode): | ||
curr = self.find_one({"chat_id":chat}) | ||
if curr: | ||
self.update({"chat_id":chat},{"type":mode}) | ||
return | ||
else: | ||
return | ||
|
||
def remove_autojoin(self,chat): | ||
curr = self.find_one({"chat_id":chat}) | ||
if curr: | ||
self.delete_one({"chat_id":chat}) | ||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.