Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master #3

Merged
merged 45 commits into from
Aug 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
0e360cf
Fixes Gban Filter Logic 😐 (#44)
Phyco-Ninja Jun 4, 2020
f16a23b
some fixes in gban and UI improvement
rking32 Jun 4, 2020
557a0d5
minor fixes
rking32 Jun 5, 2020
18ebfe4
fixes load cmd and UI improvements
rking32 Jun 6, 2020
ea8056c
minor fixes
rking32 Jun 7, 2020
a7c1695
gban again 🤷‍♂️ and fixes gdrive pattern
rking32 Jun 7, 2020
573e293
security patch + utube bound fixes + (local/global) support for notes…
rking32 Jun 7, 2020
f8d64da
notes and minor fixes + add pp count to whois
rking32 Jun 8, 2020
0e898c4
fixing gban flood wait error (#53)
Phyco-Ninja Jun 9, 2020
d0f2627
pmpermit + utube + minor fixes
rking32 Jun 10, 2020
38040b7
fixes ChatAdminRequired and allow command
rking32 Jun 12, 2020
10a7722
fixes #57
rking32 Jun 14, 2020
ee22511
fixes -> kang , MD to HTML in help , add workers to ENV , missing f i…
rking32 Jun 14, 2020
2bd9896
Add admin check for locks (#70)
Phyco-Ninja Jun 20, 2020
d515ba9
fixes kang , pathlib and add channel support to gdrive
rking32 Jun 20, 2020
6bf0b7c
upload file sorted by name if path is directory (#69)
sumitbot Jun 21, 2020
7af37c6
do not show file size in the Official Mobile Applications 😁 (#75)
SpEcHiDe Jun 21, 2020
8b4e34d
optimize pmpermit , afk , term and this -> closes #76, closes #66, cl…
rking32 Jun 22, 2020
73b36fb
added gdrive index support and this closes #18
rking32 Jun 24, 2020
8107485
fixes gban, gdrive, pymongo escape error, welcome(remove media limit)…
rking32 Jun 29, 2020
f79622b
fix gban and now filters and notes should support any character 🤔
rking32 Jun 29, 2020
4a7c5e3
some formating fixes and add gshare command
rking32 Jun 29, 2020
7bd12f8
fixes input_str
rking32 Jun 29, 2020
ec1e05c
some fixes in pool
rking32 Jun 30, 2020
892f136
redesigned core , some improvements and add bot support (BETA)
rking32 Jul 1, 2020
de58443
fixed build error
rking32 Jul 2, 2020
514cf5e
fixes logs, restart, reload, upload and some fixes
rking32 Jul 2, 2020
6c48e6e
fixed logs + missing things
rking32 Jul 2, 2020
8d2909e
some fixes and add inline menu
rking32 Jul 5, 2020
381327f
Hmmm🌚 Dunno why this Kolaveridi (#90)
Phyco-Ninja Jul 6, 2020
f4dba67
minor fixes + Nonetype has no attribute get
rking32 Jul 7, 2020
a25a592
fixed StopPropagation & ContinuePropagation issue
rking32 Jul 8, 2020
2e7c4c2
some fixes in bot session and add option to change client for checks …
rking32 Jul 8, 2020
c4b3b03
fixes in notes and https://t.me/usergeot/326374
rking32 Jul 8, 2020
560c368
fixing PeerIdInvalid error
rking32 Jul 8, 2020
4fd17fa
typo in updater message (#91)
a092devs Jul 9, 2020
a606f37
Add GitHub Pull App Support (#93)
Jul 9, 2020
c95b4dc
trying to fix floadwait when getFullUser request and fixes client checks
rking32 Jul 8, 2020
c5f9b2a
add buttons to notes
rking32 Jul 9, 2020
7299c38
buttons small fix
rking32 Jul 9, 2020
5c3a0b3
fixes filters error
rking32 Jul 9, 2020
b4f4d42
minor fixes in notes, filters and disable_web_page_preview in help
rking32 Jul 10, 2020
c9493db
minor fixes
rking32 Jul 10, 2020
1a28bff
add -all flag for notes and filters
rking32 Jul 10, 2020
fb6f3d3
small fix in notes and ids
rking32 Jul 14, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/pull.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: "1"
rules:
- base: alpha
upstream: UsergeTeam:alpha
mergeMethod: rebase
mergeUnstable: false
- base: beta
upstream: UsergeTeam:beta
mergeMethod: rebase
- base: master
upstream: UsergeTeam:master
mergeMethod: rebase
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

# Userge 🔥

[![Build Status](https://travis-ci.com/UsergeTeam/Userge.svg?branch=dev)](https://travis-ci.com/UsergeTeam/Userge) [![DeepSource](https://static.deepsource.io/deepsource-badge-light-mini.svg)](https://deepsource.io/gh/UsergeTeam/Userge/?ref=repository-badge)
[![Build Status](https://travis-ci.com/UsergeTeam/Userge.svg?branch=dev)](https://travis-ci.com/UsergeTeam/Userge) ![Python Version](https://img.shields.io/badge/python-3.7/3.8-lightgrey) ![Release](https://img.shields.io/github/v/release/UsergeTeam/Userge) ![Stars](https://img.shields.io/github/stars/UsergeTeam/Userge) ![Forks](https://img.shields.io/github/forks/UsergeTeam/Userge) ![Issues Open](https://img.shields.io/github/issues/UsergeTeam/Userge) ![Issues Closed](https://img.shields.io/github/issues-closed/UsergeTeam/Userge) ![PR Open](https://img.shields.io/github/issues-pr/UsergeTeam/Userge) ![PR Closed](https://img.shields.io/github/issues-pr-closed/UsergeTeam/Userge) ![Contributors](https://img.shields.io/github/contributors/UsergeTeam/Userge) ![Repo Size](https://img.shields.io/github/repo-size/UsergeTeam/Userge) ![License](https://img.shields.io/github/license/UsergeTeam/Userge) ![Commit Activity](https://img.shields.io/github/commit-activity/m/UsergeTeam/Userge) [![Plugins Repo!](https://img.shields.io/badge/Plugins%20Repo-!-orange)](https://github.com/UsergeTeam/Userge-Plugins) [![Join Channel!](https://img.shields.io/badge/Join%20Channel-!-red)](https://t.me/theUserge) [![DeepSource](https://static.deepsource.io/deepsource-badge-light-mini.svg)](https://deepsource.io/gh/UsergeTeam/Userge/?ref=repository-badge)

> **Userge** is a Powerful , _Pluggable_ Telegram UserBot written in _Python_ using [Pyrogram](https://github.com/pyrogram/pyrogram).

Expand Down Expand Up @@ -125,7 +125,7 @@ async def testing(message: Message):

### Video Tutorial 🎥

[![Tutorial](resources/tutorial.jpg)](https://youtu.be/-XJj686zeiY "Tutorial")
[![Tutorial](resources/tutorial.jpg)](https://youtu.be/M4T_BJvFqkc "Tutorial")

### Support & Discussions 👥

Expand Down
23 changes: 19 additions & 4 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@
"description": "Get it by running `bash genStr` command or ignore this",
"required": false
},
"BOT_TOKEN": {
"description": "Get this from https://t.me/botfather if you like to use userge as a bot",
"required": false
},
"OWNER_ID": {
"description": "Your user_id if you are gonna use userge as a bot",
"required": false
},
"WORKERS": {
"description": "Userbot Workers Count : Default = 4",
"required": false
},
"DATABASE_URL": {
"description": "Mongodb url from https://cloud.mongodb.com/"
},
Expand All @@ -35,6 +47,13 @@
"description": "Set True if it is TeamDrive",
"value": "True"
},
"LOG_CHANNEL_ID": {
"description": "Telegram Log Channel ID"
},
"G_DRIVE_INDEX_LINK": {
"description": "Index link for gdrive",
"required": false
},
"LOAD_UNOFFICIAL_PLUGINS": {
"description": "Set True if your like to use unofficial plugins",
"required": false
Expand Down Expand Up @@ -79,10 +98,6 @@
"description": "GDrive Folder ID",
"required": false
},
"LOG_CHANNEL_ID": {
"description": "Telegram Log Channel ID",
"required": false
},
"HEROKU_APP_NAME": {
"description": "given app name to the heroku app",
"required": false
Expand Down
24 changes: 20 additions & 4 deletions config.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,33 @@ G_DRIVE_CLIENT_SECRET = ""
G_DRIVE_IS_TD = False


# Telegram Log Channel ID
LOG_CHANNEL_ID = ""


# Set True if your like to use unofficial plugins
LOAD_UNOFFICIAL_PLUGINS = False


# ----------- OPTIONAL ----------- #


# Get this from https://t.me/botfather if you like to use userge as a bot
BOT_TOKEN = ""


# Your user_id if you are gonna use userge as a bot
OWNER_ID = ""


# Userbot Workers Count : Default = 4
WORKERS = 4


# Index link for gdrive
G_DRIVE_INDEX_LINK = ""


# Set name to your working directory
DOWN_PATH = "downloads/"

Expand Down Expand Up @@ -80,10 +100,6 @@ REMOVE_BG_API_KEY = ""
G_DRIVE_PARENT_ID = ""


# Telegram Log Channel ID
LOG_CHANNEL_ID = ""


# set command prefix
CMD_TRIGGER = "."

Expand Down
4 changes: 3 additions & 1 deletion genStrSession.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# pylint: disable=invalid-name, missing-module-docstring
#
# Copyright (C) 2020 by UsergeTeam@Github, < https://github.com/UsergeTeam >.
#
# This file is part of < https://github.com/UsergeTeam/Userge > project,
Expand All @@ -16,7 +18,7 @@
load_dotenv("config.env")


async def genStrSession() -> None:
async def genStrSession() -> None: # pylint: disable=missing-function-docstring
async with Client(
"Userge",
api_id=int(os.environ.get("API_ID") or input("Enter Telegram APP ID: ")),
Expand Down
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ heroku3
motor
nest_asyncio
oauth2client
Pillow
Pillow==6.2.2
psutil
pybase64
pySmartDL
Expand All @@ -24,11 +24,12 @@ pytz
rarfile
removebg
requests
search-engine-parser
search-engine-parser==0.5.4
selenium==3.141.0
setuptools>=40.3.0
spamwatch
speedtest-cli
stagger
telegraph
tgcrypto
urbandict==0.5
Expand Down
Binary file removed resources/mongo_help/1.jpg
Binary file not shown.
Binary file removed resources/mongo_help/2.jpg
Binary file not shown.
Binary file removed resources/mongo_help/3.jpg
Binary file not shown.
Binary file removed resources/mongo_help/4.jpg
Binary file not shown.
Binary file removed resources/mongo_help/5.jpg
Binary file not shown.
Binary file removed resources/mongo_help/6.jpg
Binary file not shown.
Binary file removed resources/mongo_help/7.jpg
Binary file not shown.
Binary file removed resources/mongo_help/8.jpg
Binary file not shown.
Binary file modified resources/tutorial.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 7 additions & 27 deletions test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# pylint: disable=missing-module-docstring
#
# Copyright (C) 2020 by UsergeTeam@Github, < https://github.com/UsergeTeam >.
#
# This file is part of < https://github.com/UsergeTeam/Userge > project,
Expand All @@ -7,36 +9,14 @@
# All rights reserved.

import os
import asyncio

from userge import userge


async def worker() -> None:
async def worker() -> None: # pylint: disable=missing-function-docstring
chat_id = int(os.environ.get("CHAT_ID") or 0)
await userge.send_message(chat_id, 'testing_userge')
print('sleeping 3 sec...!')
await asyncio.sleep(3)


async def main() -> None:
print('starting client...!')
await userge.start()
tasks = []
print('adding tasks...!')
for task in userge._tasks:
tasks.append(loop.create_task(task()))
print('stating worker...!')
await worker()
print('closing tasks...!')
for task in tasks:
task.cancel()
print('stopping client...!')
await userge.stop()

loop = asyncio.get_event_loop()
print('creating loop...!')
loop.run_until_complete(main())
print('closing loop...!')
loop.close()

print('userge test has been finished!')
if __name__ == "__main__":
userge.begin(worker())
print('userge test has been finished!')
8 changes: 5 additions & 3 deletions userge/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# pylint: disable=missing-module-docstring
#
# Copyright (C) 2020 by UsergeTeam@Github, < https://github.com/UsergeTeam >.
#
# This file is part of < https://github.com/UsergeTeam/Userge > project,
Expand All @@ -6,9 +8,9 @@
#
# All rights reserved.

from userge.logger import logging
from userge.config import Config
from userge.core import (
from userge.logger import logging # noqa
from userge.config import Config, get_version # noqa
from userge.core import ( # noqa
Userge, Filters, Message, get_collection, pool)

userge = Userge() # userge is the client name
2 changes: 2 additions & 0 deletions userge/__main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# pylint: disable=missing-module-docstring
#
# Copyright (C) 2020 by UsergeTeam@Github, < https://github.com/UsergeTeam >.
#
# This file is part of < https://github.com/UsergeTeam/Userge > project,
Expand Down
66 changes: 53 additions & 13 deletions userge/config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# pylint: disable=missing-module-docstring
#
# Copyright (C) 2020 by UsergeTeam@Github, < https://github.com/UsergeTeam >.
#
# This file is part of < https://github.com/UsergeTeam/Userge > project,
Expand All @@ -15,16 +17,18 @@

import heroku3
from git import Repo
from git.exc import InvalidGitRepositoryError, GitCommandError
from pySmartDL import SmartDL
from dotenv import load_dotenv
from pyrogram import Filters

from userge import logging
from . import versions

_LOG = logging.getLogger(__name__)

if sys.version_info[0] < 3 or sys.version_info[1] < 7:
_LOG.info("You MUST have a python version of at least 3.7 !")
_LOG.error("You MUST have a python version of at least 3.7 !")
sys.exit()

_CONFIG_FILE = "config.env"
Expand All @@ -39,12 +43,15 @@


class Config:
"""Configs to setup Userge"""
""" Configs to setup Userge """
API_ID = int(os.environ.get("API_ID", 12345))
API_HASH = os.environ.get("API_HASH", None)
ANTISPAM_SENTRY = bool(os.environ.get("ANTISPAM_SENTRY", False))
WORKERS = int(os.environ.get("WORKERS", 4))
ANTISPAM_SENTRY = os.environ.get("ANTISPAM_SENTRY", "").lower() == "true"
HU_STRING_SESSION = os.environ.get("HU_STRING_SESSION", None)
DB_URI = os.environ.get("DATABASE_URL", None)
BOT_TOKEN = os.environ.get("BOT_TOKEN", None)
OWNER_ID = int(os.environ.get("OWNER_ID", 0))
DB_URI = os.environ.get("DATABASE_URL", '')
LANG = os.environ.get("PREFERRED_LANGUAGE", "en")
DOWN_PATH = os.environ.get("DOWN_PATH", "downloads").rstrip('/') + '/'
SCREENSHOT_API = os.environ.get("SCREENSHOT_API", None)
Expand All @@ -58,14 +65,15 @@ class Config:
G_DRIVE_CLIENT_ID = os.environ.get("G_DRIVE_CLIENT_ID", None)
G_DRIVE_CLIENT_SECRET = os.environ.get("G_DRIVE_CLIENT_SECRET", None)
G_DRIVE_PARENT_ID = os.environ.get("G_DRIVE_PARENT_ID", None)
G_DRIVE_IS_TD = bool(os.environ.get("G_DRIVE_IS_TD", False))
G_DRIVE_IS_TD = os.environ.get("G_DRIVE_IS_TD", "").lower() == "true"
G_DRIVE_INDEX_LINK = os.environ.get("G_DRIVE_INDEX_LINK", None)
GOOGLE_CHROME_DRIVER = os.environ.get("GOOGLE_CHROME_DRIVER", None)
GOOGLE_CHROME_BIN = os.environ.get("GOOGLE_CHROME_BIN", None)
LOG_CHANNEL_ID = int(os.environ.get("LOG_CHANNEL_ID", 0))
UPSTREAM_REPO = os.environ.get("UPSTREAM_REPO", "https://github.com/UsergeTeam/Userge")
HEROKU_API_KEY = os.environ.get("HEROKU_API_KEY", None)
HEROKU_APP_NAME = os.environ.get("HEROKU_APP_NAME", None)
LOAD_UNOFFICIAL_PLUGINS = bool(os.environ.get("LOAD_UNOFFICIAL_PLUGINS", False))
LOAD_UNOFFICIAL_PLUGINS = os.environ.get("LOAD_UNOFFICIAL_PLUGINS", "").lower() == "true"
CMD_TRIGGER = os.environ.get("CMD_TRIGGER", '.')
SUDO_TRIGGER = os.environ.get("SUDO_TRIGGER", '!')
FINISHED_PROGRESS_STR = os.environ.get("FINISHED_PROGRESS_STR", '█')
Expand All @@ -76,12 +84,19 @@ class Config:
WELCOME_DELETE_TIMEOUT = 120
AUTOPIC_TIMEOUT = 300
ALLOWED_CHATS = Filters.chat([])
ALLOW_ALL_PMS = True
USE_USER_FOR_CLIENT_CHECKS = False
SUDO_USERS: Set[int] = set()
ALLOWED_COMMANDS: Set[str] = set()
UPSTREAM_REMOTE = 'upstream'
HEROKU_APP = None
HEROKU_GIT_URL = None


if not Config.LOG_CHANNEL_ID:
_LOG.error("Need LOG_CHANNEL_ID !, Exiting ...")
sys.exit()

if Config.SUDO_TRIGGER == Config.CMD_TRIGGER:
_LOG.info("Invalid SUDO_TRIGGER!, You can't use `%s` as SUDO_TRIGGER", Config.CMD_TRIGGER)
sys.exit()
Expand All @@ -107,6 +122,19 @@ class Config:
shutil.rmtree(tmp_heroku_git_path)
break

_LOG.info("Checking REPO...")
try:
_REPO = Repo()
except InvalidGitRepositoryError:
_REPO = Repo.init()
if Config.UPSTREAM_REMOTE not in _REPO.remotes:
_REPO.create_remote(Config.UPSTREAM_REMOTE, Config.UPSTREAM_REPO)
try:
_REPO.remote(Config.UPSTREAM_REMOTE).fetch()
except GitCommandError as error:
_LOG.error(error)
sys.exit()

if not os.path.exists('bin'):
_LOG.info("Creating BIN...")
os.mkdir('bin')
Expand All @@ -126,11 +154,23 @@ class Config:

if Config.LOAD_UNOFFICIAL_PLUGINS:
_LOG.info("Loading UnOfficial Plugins...")
os.system("git clone --depth=1 https://github.com/UsergeTeam/Userge-Plugins.git")
os.system("pip3 install -U pip")
os.system("pip3 install -r Userge-Plugins/requirements.txt")
os.system("rm -rf userge/plugins/unof_plugins/")
os.system("mv Userge-Plugins/plugins/ userge/plugins/unof_plugins/")
os.system("cp -r Userge-Plugins/resources/* resources/")
os.system("rm -rf Userge-Plugins/")
_CMDS = ["git clone --depth=1 https://github.com/UsergeTeam/Userge-Plugins.git",
"pip3 install -U pip",
"pip3 install -r Userge-Plugins/requirements.txt",
"rm -rf userge/plugins/unofficial/",
"mv Userge-Plugins/plugins/ userge/plugins/unofficial/",
"cp -r Userge-Plugins/resources/* resources/",
"rm -rf Userge-Plugins/"]
os.system(" && ".join(_CMDS)) # nosec
_LOG.info("UnOfficial Plugins Loaded Successfully!")


def get_version() -> str:
""" get userge version """
ver = f"{versions.__major__}.{versions.__minor__}.{versions.__micro__}"
diff = list(_REPO.iter_commits(f'{Config.UPSTREAM_REMOTE}/master..HEAD'))
if diff:
if "/usergeteam/userge" in Config.UPSTREAM_REPO.lower():
return f"{ver}-beta.{len(diff)}"
return f"{ver}-custom.{len(diff)}"
return ver
12 changes: 7 additions & 5 deletions userge/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# pylint: disable=missing-module-docstring
#
# Copyright (C) 2020 by UsergeTeam@Github, < https://github.com/UsergeTeam >.
#
# This file is part of < https://github.com/UsergeTeam/Userge > project,
Expand All @@ -6,9 +8,9 @@
#
# All rights reserved.

from pyrogram import Filters
from pyrogram import Filters # noqa

from .database import get_collection
from .ext import pool
from .client import Userge
from .methods import Message
from .database import get_collection # noqa
from .types.bound import Message # noqa
from .ext import pool # noqa
from .client import Userge # noqa
Loading