forked from UsergeTeam/Userge
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
15 changed files
with
128 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,3 +131,4 @@ dmypy.json | |
|
||
#configfile | ||
config.ini | ||
config.env |
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 |
---|---|---|
@@ -1,11 +1,8 @@ | ||
import logging | ||
from .utils import logging | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
logging.basicConfig( | ||
level=logging.INFO, | ||
format='[%(asctime)s - %(levelname)s] - %(name)s - %(message)s', | ||
datefmt='%d-%b-%y %H:%M:%S' | ||
) | ||
|
||
log = logging.getLogger(__name__) | ||
userge = None # userge is the client name | ||
from .client import Userge | ||
|
||
userge = Userge() # userge is the client name |
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,7 @@ | ||
from Userge import userge, logging | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
if __name__ == "__main__": | ||
userge.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from .utils import Config, logging | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
from pyrogram import Client | ||
|
||
logging.getLogger("pyrogram").setLevel(logging.WARNING) | ||
|
||
|
||
class Userge(Client): | ||
def __init__(self): | ||
super().__init__( | ||
Config.HU_STRING_SESSION, | ||
api_id=Config.API_ID, | ||
api_hash=Config.API_HASH, | ||
plugins = dict(root="Userge/plugins") | ||
) |
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 |
---|---|---|
@@ -1,16 +1,19 @@ | ||
from Userge import log | ||
from os.path import dirname, basename, isfile | ||
import glob | ||
from Userge import logging | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
plugins = sorted( | ||
[ | ||
basename(f)[:-3] for f in glob.glob(dirname(__file__) + "/*.py") | ||
if isfile(f) and f.endswith(".py") and not f.endswith("__init__.py") | ||
] | ||
) | ||
|
||
async def get_all_plugins(): | ||
from os.path import dirname, basename, isfile | ||
import glob | ||
|
||
log.info(f"plugins to load: {plugins}") | ||
plugins = sorted( | ||
[ | ||
basename(f)[:-3] for f in glob.glob(dirname(__file__) + "/*.py") | ||
if isfile(f) and f.endswith(".py") and not f.endswith("__init__.py") | ||
] | ||
) | ||
|
||
__all__ = plugins + ["plugins"] | ||
log.info(f"all plugins: {plugins}") | ||
|
||
return plugins |
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 |
---|---|---|
@@ -1,12 +1,16 @@ | ||
from datetime import datetime | ||
from Userge import userge | ||
from Userge import userge, logging | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
from pyrogram import Filters, Message | ||
from datetime import datetime | ||
|
||
|
||
@userge.on_message(Filters.command("ping", ".") & Filters.me) | ||
def pingme(_, message: Message): | ||
async def pingme(_, message: Message): | ||
start = datetime.now() | ||
message.edit('`Pong!`') | ||
await message.edit('`Pong!`') | ||
end = datetime.now() | ||
ms = (end - start).microseconds / 1000 | ||
message.edit(f"**Pong!**\n`{ms} ms`") | ||
await message.edit(f"**Pong!**\n`{ms} ms`") |
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,2 @@ | ||
from .config import Config | ||
from .logger import logging |
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,28 @@ | ||
import os | ||
from dotenv import load_dotenv | ||
from .logger import logging | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
config_file = "config.env" | ||
|
||
if not os.path.isfile(config_file): | ||
log.error(f"{config_file} Not Found!") | ||
quit(1) | ||
|
||
load_dotenv(config_file) | ||
|
||
if os.environ.get("_____REMOVE_____THIS_____LINE_____", None): | ||
log.error("Please remove the line mentioned in the first hashtag from the config.env file") | ||
quit(1) | ||
|
||
|
||
class Config: | ||
|
||
API_ID = int(os.environ.get("API_ID", 12345)) | ||
|
||
API_HASH = os.environ.get("API_HASH", None) | ||
|
||
HU_STRING_SESSION = os.environ.get("HU_STRING_SESSION", None) | ||
|
||
DB_URI = os.environ.get("DATABASE_URL", None) |
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,7 @@ | ||
import logging | ||
|
||
logging.basicConfig( | ||
level=logging.INFO, | ||
format='[%(asctime)s - %(levelname)s] - %(name)s - %(message)s', | ||
datefmt='%d-%b-%y %H:%M:%S' | ||
) |
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,13 @@ | ||
# Remove this line first before doing anything else | ||
_____REMOVE_____THIS_____LINE_____=True | ||
|
||
# | ||
# Get from https://my.telegram.org/ | ||
# | ||
API_ID="" | ||
API_HASH="" | ||
|
||
# | ||
# Get by running `bash genStr` command | ||
# | ||
HU_STRING_SESSION="" |
This file was deleted.
Oops, something went wrong.
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,3 @@ | ||
#!/bin/bash | ||
|
||
python3.8 genStrSession.py |
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,15 @@ | ||
from pyrogram import Client | ||
import asyncio | ||
|
||
|
||
async def genStrSession(): | ||
async with Client( | ||
"Userge", | ||
api_id=int(input("enter Telegram APP ID: ")), | ||
api_hash=input("enter Telegram API HASH: ") | ||
) as Userge: | ||
print(Userge.export_session_string()) | ||
|
||
|
||
if __name__ == "__main__": | ||
asyncio.run(genStrSession()) |
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,3 @@ | ||
python-dotenv | ||
tgcrypto | ||
https://github.com/pyrogram/pyrogram/archive/asyncio.zip |
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,3 @@ | ||
#!/bin/bash | ||
|
||
python3.8 -m Userge |