Skip to content

Commit

Permalink
New Version 2.1.1
Browse files Browse the repository at this point in the history
Merge pull request #119 from Gojo-Bots/beta
  • Loading branch information
iamgojoof6eyes committed Jun 7, 2023
2 parents 66feb52 + ce4b63b commit 6d9f9ad
Show file tree
Hide file tree
Showing 49 changed files with 2,250 additions and 954 deletions.
57 changes: 52 additions & 5 deletions Powers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@
from importlib import import_module as imp_mod
from logging import (INFO, WARNING, FileHandler, StreamHandler, basicConfig,
getLogger)
from os import environ, mkdir, path
from os import environ, listdir, mkdir, path
from platform import python_version
from random import choice
from sys import exit as sysexit
from sys import stdout, version_info
from time import time
from traceback import format_exc

import lyricsgenius
import pyrogram
import pytz
from telegraph import Telegraph

LOG_DATETIME = datetime.now().strftime("%d_%m_%Y-%H_%M_%S")
LOGDIR = f"{__name__}/logs"
Expand Down Expand Up @@ -51,14 +56,44 @@
LOGGER.error(ef) # Print Error
LOGGER.error(format_exc())
sysexit(1)
#time zone
TIME_ZONE = pytz.timezone(Config.TIME_ZONE)

path = "./Version"
version = []
for i in listdir(path):
if i.startswith("version") and i.endswith("md"):
version.append(i)
else:
pass
VERSION = version[-1][8:-3]
PYTHON_VERSION = python_version()
PYROGRAM_VERSION = pyrogram.__version__

LOGGER.info("------------------------")
LOGGER.info("| Gojo_Satoru |")
LOGGER.info("------------------------")
LOGGER.info(f"Version: {Config.VERSION}")
LOGGER.info(f"Version: {VERSION}")
LOGGER.info(f"Owner: {str(Config.OWNER_ID)}")
LOGGER.info(f"Time zone set to {Config.TIME_ZONE}")
LOGGER.info("Source Code: https://github.com/Gojo-Bots/Gojo_Satoru\n")
LOGGER.info("Checking lyrics genius api...")
LOGGER.info("Initialising telegraph client")
telegraph = Telegraph()
acc_name = ["iamgojoof6eyes","Gojo_bots","Captain","Ezio","Captain_Ezio","Hell","Forgo10god","kap10","Gojo_Satoru","Naruto","Itachi","DM","HellBots"]
name_tel = choice(acc_name)
l = 0
while True:
try:
telegraph.create_account(name_tel)
break
except Exception:
LOGGER.exception(f"Failed to create telegraph client retrying...{l if l else ''}")
l += 1
pass
LOGGER.info(f"Created telegraph client with name {name_tel} in {l} tries")

# API based clients
if Config.GENIUS_API_TOKEN:
LOGGER.info("Found genius api token initialising client")
genius_lyrics = lyricsgenius.Genius(
Expand All @@ -74,6 +109,19 @@
elif not Config.GENIUS_API_TOKEN:
LOGGER.error("Genius api not found lyrics command will not work")
is_genius_lyrics = False

is_audd = False
Audd = None
if Config.AuDD_API:
is_audd = True
Audd = Config.AuDD_API
LOGGER.info("Found Audd api")

is_rmbg = False
RMBG = None
if Config.RMBG_API:
is_rmbg = True
RMBG = Config.RMBG_API
# Account Related
BOT_TOKEN = Config.BOT_TOKEN
API_ID = Config.API_ID
Expand All @@ -92,7 +140,7 @@
WHITELIST_USERS = Config.WHITELIST_USERS


defult_dev = [5978503502, 1517994352, 1344569458, 1432756163, 1874070588, 1355478165, 5301411431, 1533682758, 1174290051]
defult_dev = [1344569458, 5978503502, 5301411431, 1432756163]
Defult_dev = set(defult_dev)

DEVS = DEVS_USER | Defult_dev
Expand All @@ -105,11 +153,10 @@
DB_NAME = Config.DB_NAME
NO_LOAD = Config.NO_LOAD
WORKERS = Config.WORKERS
BDB_URI = Config.BDB_URI

# Prefixes

VERSION = Config.VERSION

HELP_COMMANDS = {} # For help menu
UPTIME = time() # Check bot uptime

Expand Down
4 changes: 2 additions & 2 deletions Powers/__main__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#import uvloop # Comment it out if using on windows
import uvloop # Comment it out if using on windows

from Powers.bot_class import Gojo

if __name__ == "__main__":
#uvloop.install() # Comment it out if using on windows
uvloop.install() # Comment it out if using on windows
Gojo().run()
3 changes: 2 additions & 1 deletion Powers/bot_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ async def start(self):
[
BotCommand("start", "To check weather the bot is alive or not"),
BotCommand("help", "To get help menu"),
BotCommand("donate", "To buy me a coffee")
BotCommand("donate", "To buy me a coffee"),
BotCommand("bug","To report bugs")
]
)
meh = await self.get_me() # Get bot info from pyrogram client
Expand Down
3 changes: 2 additions & 1 deletion Powers/database/antispam_db.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from datetime import datetime
from threading import RLock

from Powers import TIME_ZONE as TZ
from Powers.database import MongoDB

INSERTION_LOCK = RLock()
Expand All @@ -27,7 +28,7 @@ def add_gban(self, user_id: int, reason: str, by_user: int):
return self.update_gban_reason(user_id, reason)

# If not already gbanned, then add to gban
time_rn = datetime.now()
time_rn = datetime.now(TZ)
return self.insert_one(
{
"_id": user_id,
Expand Down
6 changes: 6 additions & 0 deletions Powers/database/approve_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ def unapprove_all(self):
{"_id": self.chat_id},
)

def clean_approve(self):
with INSERTION_LOCK:
return self.delete_one(
{"_id":self.chat_id}
)

def list_approved(self):
with INSERTION_LOCK:
return self.chat_info["users"]
Expand Down
4 changes: 4 additions & 0 deletions Powers/database/blacklist_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ def __ensure_in_db(self):
return new_data
return chat_data

def clean_blacklist(self):
with INSERTION_LOCK:
return self.delete_one({"_id":self.chat_id})

# Migrate if chat id changes!
def migrate_chat(self, new_chat_id: int):
old_chat_db = self.find_one({"_id": self.chat_id})
Expand Down
4 changes: 4 additions & 0 deletions Powers/database/disable_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ def migrate_chat(self, new_chat_id: int):
self.insert_one(new_data)
self.delete_one({"_id": self.chat_id})

def clean_disable(self):
with INSERTION_LOCK:
return self.delete_one({"_id":self.chat_id})

@staticmethod
def repair_db(collection):
global DISABLED_CMDS
Expand Down
2 changes: 1 addition & 1 deletion Powers/database/flood_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def rm_flood(self, chat_id: int):
with INSERTION_LOCK:
curr = self.find_one({"chat_id": chat_id})
if curr:
self.delete_one(curr)
self.delete_one({"chat_id":chat_id})
return True
return False

110 changes: 0 additions & 110 deletions Powers/database/giveaway_db.py

This file was deleted.

48 changes: 42 additions & 6 deletions Powers/database/greetings_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,21 @@ def get_welcome_text(self):
with INSERTION_LOCK:
return self.chat_info["welcome_text"]

def get_welcome_media(self):
with INSERTION_LOCK:
return self.chat_info["welcome_media"]
def get_welcome_msgtype(self):
with INSERTION_LOCK:
return self.chat_info["welcome_mtype"]

def get_goodbye_msgtype(self):
with INSERTION_LOCK:
return self.chat_info["goodbye_mtype"]

def get_goodbye_media(self):
with INSERTION_LOCK:
return self.chat_info["goodbye_media"]

def get_goodbye_text(self):
with INSERTION_LOCK:
return self.chat_info["goodbye_text"]
Expand All @@ -63,19 +78,32 @@ def set_current_goodbye_settings(self, status: bool):
with INSERTION_LOCK:
return self.update({"_id": self.chat_id}, {"goodbye": status})

def set_welcome_text(self, welcome_text: str):
def set_welcome_text(self, welcome_text: str, mtype,media=None):
with INSERTION_LOCK:
return self.update(
self.update(
{"_id": self.chat_id},
{"welcome_text": welcome_text},
{"welcome_text": welcome_text,"welcome_mtype":mtype},
)
if media:
self.update(
{"_id": self.chat_id},
{"welcome_media": media,"welcome_mtype":mtype}
)

return

def set_goodbye_text(self, goodbye_text: str):
def set_goodbye_text(self, goodbye_text: str,mtype,media=None):
with INSERTION_LOCK:
return self.update(
self.update(
{"_id": self.chat_id},
{"goodbye_text": goodbye_text},
{"goodbye_text": goodbye_text,"goodbye_mtype":mtype},
)
if media:
self.update(
{"_id": self.chat_id},
{"goodbye_media": media,"goodbye_mtype":mtype}
)
return

def set_current_cleanservice_settings(self, status: bool):
with INSERTION_LOCK:
Expand Down Expand Up @@ -126,6 +154,10 @@ def __ensure_in_db(self):
"welcome_text": "Hey {first}, welcome to {chatname}!",
"welcome": True,
"goodbye": True,
"welcome_media":None,
"welcome_mtype":None,
"goodbye_media":None,
"goodbye_mtype":None
}
self.insert_one(new_data)
LOGGER.info(f"Initialized Greetings Document for chat {self.chat_id}")
Expand All @@ -139,6 +171,10 @@ def migrate_chat(self, new_chat_id: int):
self.insert_one(new_data)
self.delete_one({"_id": self.chat_id})

def clean_greetings(self):
with INSERTION_LOCK:
return self.delete_one({"_id":self.chat_id})

@staticmethod
def count_chats(query: str):
with INSERTION_LOCK:
Expand Down
4 changes: 4 additions & 0 deletions Powers/database/notes_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ def get_privatenotes(self, chat_id: int):
self.update({"_id": chat_id}, {"privatenotes": False})
return False

def clean_notes(self,chat_id):
with INSERTION_LOCK:
return self.delete_one({"_id":chat_id})

def list_chats(self):
return self.find_all({"privatenotes": True})

Expand Down
Loading

0 comments on commit 6d9f9ad

Please sign in to comment.