Skip to content
This repository has been archived by the owner on May 15, 2021. It is now read-only.

Commit

Permalink
Rogue (#63)
Browse files Browse the repository at this point in the history
* Fixes and upstreams

* Multi Owner Support

Yeah F* lmao have to change 14 files for it

* Bot Forwards 2.0

- Improved neofetch

* Create .gitpod.Dockerfile

Made it Gitpod Ready

* Create config.conf

re-added Modes in alive

* Added Author Name

Co-Authored-By: ポキ <pokurt@pokurt.cf>

* remove invalid message.quiz

Fixed /uinfo

* tweaked alive

* tweaked bot_forwards

* Moar Fixes

- added more exceptions in youtube inline
- Fixed bot check in spoiler.py
- made vid_upload return message

* Update utube_inline.py

Co-authored-by: ポキ <pokurt@pokurt.cf>
  • Loading branch information
code-rgb and ポキ authored Nov 21, 2020
1 parent eddf613 commit d637b0e
Show file tree
Hide file tree
Showing 35 changed files with 532 additions and 674 deletions.
File renamed without changes.
15 changes: 15 additions & 0 deletions .gitpod.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

FROM gitpod/workspace-full

RUN sudo apt-get update \
&& sudo apt-get install -y --no-install-recommends \
tree \
wget2 \
pv \
p7zip-full \
mediainfo \
neofetch \
ffmpeg \
&& sudo rm -rf /var/lib/apt/lists/*

RUN curl https://cli-assets.heroku.com/install.sh | sh
7 changes: 3 additions & 4 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#image:
#file: .gitpod.Dockerfile
image:
file: .gitpod.Dockerfile

tasks:
# Install dependencies first.
Expand All @@ -9,6 +9,5 @@ tasks:
if [[ -f config.env ]]; then
bash run
else
echo "Please copy the config.env.sample file and edit it to continue."
echo "Please edit the config.env.sample and rename it to 'config.env'. Then to run do-> bash run"
fi
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ RUN apt -qq install -y --no-install-recommends \
wget \
ffmpeg \
jq \
mediainfo
mediainfo \
neofetch

# install chrome
RUN mkdir -p /tmp/ && \
Expand Down
99 changes: 38 additions & 61 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
<h2 align="center"><b>Owner: <a href="https://telegram.dog/deleteduser420">𝚂𝚢𝚗𝚝𝚊𝚡 ░ Σrr♢r</a></b></h2>


<br>


<p align="center">
<a href="https://github.com/code-rgb/USERGE-X"><img src="https://i.imgur.com/53mdl2v.png" alt="Userge-x" width=400px></a>
<br>
<br>
<a href="https://github.com/code-rgb/USERGE-X"><img src="https://i.imgur.com/53mdl2v.png" alt="Userge-x" width=400px></a>
<br>
<br>
</p>

<h1>USERGE-X</h1>
<b>Pluggable Telegram UserBot</b>
<br>
Expand All @@ -30,68 +25,55 @@
[![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod&style=flat-square)](https://gitpod.io/#https://github.com/code-rgb/userge-x)
<br>

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

[![Telegram](https://img.shields.io/badge/Support%20Group-USERGE--X-blue?&logo=telegram&style=social)](https://telegram.dog/x_xtests)
<p align="center">
<a href="https://telegram.dog/x_xtests"><img src="https://img.shields.io/badge/Support%20Group-USERGE--%F0%9D%91%BF-blue?&logo=telegram&style=social" width=220px></a></p>

## Disclaimer

```
```
/**
⚠️Kang at your own risk⚠️
Your Telegram account may get banned.
I am not responsible for any improper use of this bot
This bot is intended for the purpose of having fun with memes,
as well as efficiently managing groups.
It can help you with managing yourself as well.
You ended up spamming groups, getting reported left and right,
and then you ended up in a Final Battle with Telegram
and at the end the Telegram Team
deleted your account?
And after that, you pointed your fingers at us
for getting your account deleted?
We will be rolling on the floor laughing at you.
Yes! you heard it right.
⚠️Kang at your own risk⚠️
Your Telegram account may get banned.
I am not responsible for any improper use of this bot
This bot is intended for the purpose of having fun with memes,
as well as efficiently managing groups.
It can help you with managing yourself as well.
You ended up spamming groups, getting reported left and right,
and then you ended up in a Final Battle with Telegram
and at the end the Telegram Team
deleted your account?
And after that, you pointed your fingers at us
for getting your account deleted?
We will be rolling on the floor laughing at you.
Yes! you heard it right.
/**
```


## Requirements

* Python 3.8 or Higher
* Telegram [API Keys](https://my.telegram.org/apps)
* Google Drive [API Keys](https://console.developers.google.com/)
* MongoDB [Database URL](https://cloud.mongodb.com/)


## How To Deploy
* With Heroku:

<p align="center">
<a href = "https://heroku.com/deploy?template=https://github.com/code-rgb/USERGE-X/tree/alpha"><img src="https://telegra.ph/file/57c4edb389224c9cf9996.png" alt="Press to Takeoff" width="490px"></a></p>
<a href = "https://heroku.com/deploy?template=https://github.com/code-rgb/USERGE-X/tree/alpha"><img src="https://telegra.ph/file/57c4edb389224c9cf9996.png" alt="Press to Takeoff" width="490px"></a>
</p>
<br>

> **NOTE** : your can fill other vars as your need and they are optional. (settings -> reveal config vars)
* First click The Button Above.
* Fill `API_ID`, `API_HASH`, `DATABASE_URL` and `LOG_CHANNEL_ID` and `HEROKU_APP_NAME` (**required**)
* Then fill Dual Mode vars : `OWNER_ID`, `BOT_TOKEN` and `HU_STRING_SESSION`
* Then fill [other **non-required** vars](https://telegra.ph/Heroku-Vars-for-USERGE-X-08-25) later
* Finally **hit deploy** button


> **NOTE** : your can fill other vars as your need and they are optional. (settings -> reveal config vars)
* First click The Button Above.
* Fill `API_ID`, `API_HASH`, `DATABASE_URL`, `LOG_CHANNEL_ID`, `HEROKU_APP_NAME` and `HEROKU_API_KEY` (**required**)
* Then fill Dual Mode vars : `OWNER_ID`, `BOT_TOKEN` and `HU_STRING_SESSION`
* Then fill [other **non-required** vars](https://telegra.ph/Heroku-Vars-for-USERGE-X-08-25) later
* Finally **hit deploy** button
## String Session
**VAR :** `HU_STRING_SESSION`

### HEROKU
- [open your app](https://dashboard.heroku.com/apps/) then go to **more** -> **run console** and paste the command below and click **run**.
> command: `bash genStr`
### REPL
- [**Generate on REPL**](https://stringsessiongen.leorio.repl.run/)

## Read more
**VAR ->** `HU_STRING_SESSION`
#### By HEROKU
- [open your app](https://dashboard.heroku.com/apps/) then go to **more** -> **run console** and type `bash genStr` and click **run**.
#### On REPL
- [Generate on REPL](https://repl.it/@Leorio/stringsessiongen#main.py)
### Read more
<details>
<summary><b>Details and Guides</b></summary>

Expand Down Expand Up @@ -119,11 +101,11 @@
# get string session and add it to config.env
bash genStr

# finally run the Userge ;)
# finally run the USERGE-X ;)
bash run
```


<h2>Guide to Upstream Forked Repo</h2>
<a href="https://telegra.ph/Upstream-Userge-Forked-Repo-Guide-07-04"><b>Upstream Forked Repo</b></a>
<br>
Expand Down Expand Up @@ -182,15 +164,10 @@ async def test_filter(message: Message):

</details>


### Project Credits

* [Pyrogram Assistant](https://github.com/pyrogram/assistant)
* [PyroGramBot](https://github.com/SpEcHiDe/PyroGramBot)
* [PaperPlane](https://github.com/RaphielGang/Telegram-Paperplane)
* [Uniborg](https://github.com/SpEcHiDe/UniBorg)


### Copyright & License

[**GNU General Public License v3.0**](https://github.com/code-rgb/USERGE-X/blob/alpha/LICENSE)
[**GNU General Public License v3.0**](https://github.com/code-rgb/USERGE-X/blob/alpha/LICENSE)
22 changes: 13 additions & 9 deletions config.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ LOG_CHANNEL_ID=""


# USERGE-X MODE
# USERGE-X Utilizes Both [ USER and BOT ] MODE so its a [ DUAL MODE ] userbot
# see below for more info
# Fills Vars for the mode you [ USER ], [ BOT ]
# or [ DUAL MODE ] ( USER + BOT )
# See USERGE-X MODES For More Info


# ----------- OPTIONAL ----------- #
Expand Down Expand Up @@ -133,11 +134,8 @@ DEEP_AI=""
ALIVE_MEDIA=""


# your instagram username
# your instagram username and password
INSTA_ID=""


# your instagram password
INSTA_PASS=""


Expand All @@ -148,6 +146,11 @@ IMGFLIP_ID=""
IMGFLIP_PASS=""


# LastFM username and api key
LASTFM_USERNAME = ""
LASTFM_API_KEY = ""


# ----------- Only If Using Heroku ----------- #


Expand All @@ -159,14 +162,15 @@ HEROKU_API_KEY=""
HEROKU_APP_NAME=""


# ----------- USERGE-X DUAL MODE ----------- #
# Both BOT and USER Sessions are Required

# ----------- USERGE-X MODES ----------- #
# Both BOT and USER Sessions are Required for DUAL MODE

# USER MODE
# get this using [ 'https://GenUserGeString.usergeuserbot.repl.run' or `bash genStr` ]
HU_STRING_SESSION=""


# BOT MODE
# get this from https://t.me/botfather Your USERGE-X Bot
BOT_TOKEN=""
OWNER_ID="" # your user_id
2 changes: 1 addition & 1 deletion tools/genStrSession.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async def genStrSession() -> None: # pylint: disable=missing-function-docstring
) as userge:
print("\nprocessing...")
await userge.send_message(
"me", f"#USERGE #HU_STRING_SESSION\n\n```{await userge.export_session_string()}```")
"me", f"#USERGE-X #HU_STRING_SESSION\n\n```{await userge.export_session_string()}```")
print("Done !, session string has been sent to saved messages!")

if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion userge/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Config:
WORKERS = min(32, int(os.environ.get("WORKERS")) or os.cpu_count() + 4)
BOT_TOKEN = os.environ.get("BOT_TOKEN", None)
HU_STRING_SESSION = os.environ.get("HU_STRING_SESSION", None)
OWNER_ID = int(os.environ.get("OWNER_ID", 0))
OWNER_ID = tuple(filter(lambda x: x, map(int, os.environ.get("OWNER_ID", "0").split())))
LOG_CHANNEL_ID = int(os.environ.get("LOG_CHANNEL_ID"))
DB_URI = os.environ.get("DATABASE_URL")
LANG = os.environ.get("PREFERRED_LANGUAGE")
Expand Down
5 changes: 3 additions & 2 deletions userge/core/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,13 @@ async def _shutdown(sig: signal.Signals) -> None:
running_tasks.append(self.loop.create_task(task()))
logbot.edit_last_msg("USERGE-X has Started Successfully !")
logbot.end()
mode = "[DUAL]" if RawClient.DUAL_MODE else "[BOT]" if Config.BOT_TOKEN else "[USER]"
try:
if coro:
_LOG.info(_LOG_STR, "Running Coroutine")
_LOG.info(_LOG_STR, f"Running Coroutine - {mode}")
self.loop.run_until_complete(coro)
else:
_LOG.info(_LOG_STR, "Idling USERGE-X")
_LOG.info(_LOG_STR, f"Idling USERGE-X - {mode}")
idle()
self.loop.run_until_complete(_finalize())
except (asyncio.exceptions.CancelledError, RuntimeError):
Expand Down
5 changes: 4 additions & 1 deletion userge/core/ext/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ async def _stop():
for _ in range(_WORKERS):
_ASYNC_QUEUE.put_nowait(None)
for task in _TASKS:
await task
try:
await asyncio.wait_for(task, timeout=0.3)
except asyncio.TimeoutError:
task.cancel()
_TASKS.clear()
_LOG.info(_LOG_STR, f"Stopped Pool : {_WORKERS} Workers")
11 changes: 8 additions & 3 deletions userge/core/types/new/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,22 @@ async def mark_read(self, message: Optional[RawMessage] = None) -> bool:
return bool(
await self._client.send_read_acknowledge(chat_id=self._chat_id, message=message))

async def send_message(self, text: str) -> RawMessage:
async def send_message(self,
text: str,
parse_mode: Union[str, object] = object) -> RawMessage:
"""\nSend text messages to the conversation.
Parameters:
text (``str``):
Text of the message to be sent.
parse_mode (``str | object``):
parser to be used to parse text entities.
Returns:
:obj:`Message`: On success, the sent text message is returned.
"""
return await self._client.send_message(chat_id=self._chat_id, text=text)
return await self._client.send_message(chat_id=self._chat_id,
text=text, parse_mode=parse_mode)

async def send_document(self, document: str) -> Optional[RawMessage]:
"""\nSend documents to the conversation.
Expand Down Expand Up @@ -184,4 +189,4 @@ async def __aexit__(self, exc_type, exc_val, exc_tb) -> None:
error = f"ended conversation with {self._chat_id}, message limit reached!"
if error:
_LOG.error(_LOG_STR, error)
raise StopConversation(error)
raise StopConversation(error)
2 changes: 1 addition & 1 deletion userge/core/types/raw/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def parse(cls, command: str, # pylint: disable=arguments-differ
and not m.outgoing
and trigger
and m.from_user and m.text
and ((m.from_user.id == Config.OWNER_ID)
and ((m.from_user.id in Config.OWNER_ID)
or (Config.SUDO_ENABLED and (m.from_user.id in Config.SUDO_USERS)
and (cname.lstrip(trigger) in Config.ALLOWED_COMMANDS)))
and m.text.startswith(Config.SUDO_TRIGGER))
Expand Down
28 changes: 11 additions & 17 deletions userge/plugins/admin/gadmin.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
""" manage your group """

# Copyright (C) 2020 by UsergeTeam@Github, < https://github.com/UsergeTeam >.
#
# This file is part of < https://github.com/UsergeTeam/Userge > project,
# and is released under the "GNU v3.0 License Agreement".
# Please see < https://github.com/uaudith/Userge/blob/master/LICENSE >
#
# All rights reserved.

import asyncio
import os
Expand Down Expand Up @@ -70,14 +63,15 @@ async def promote_usr(message: Message):
can_invite_users=True,
can_pin_messages=True,
)
await asyncio.sleep(2)
await message.client.set_administrator_title(chat_id, user_id, custom_rank)
if custom_rank:
await asyncio.sleep(2)
await message.client.set_administrator_title(chat_id, user_id, custom_rank)
await message.edit("`👑 Promoted Successfully..`", del_in=5)
await CHANNEL.log(
"#PROMOTE\n\n"
f"USER: [{get_mem.user.first_name}](tg://user?id={get_mem.user.id}) "
f"(`{get_mem.user.id}`)\n"
f"CUSTOM TITLE: `{custom_rank}`\n"
f"CUSTOM TITLE: `{custom_rank or None}`\n"
f"CHAT: `{message.chat.title}` (`{chat_id}`)"
)
except UsernameInvalid:
Expand Down Expand Up @@ -457,16 +451,14 @@ async def zombie_clean(message: Message):
)
flags = message.flags
rm_delaccs = "-c" in flags
del_stats = (
r"`Zero zombie accounts found in this chat... WOOHOO group is clean.. \^o^/`"
)
del_users = 0
can_clean = check_user.status in ("administrator", "creator")
if rm_delaccs:
can_clean = check_user.status in ("administrator", "creator")
del_users = 0
del_admins = 0
del_total = 0
del_stats = r"`Zero zombie accounts found in this chat... WOOHOO group is clean.. \^o^/`"
if can_clean:
await message.edit("`Hang on!! cleaning zombie accounts from this chat..`")
del_admins = 0
del_total = 0
async for member in message.client.iter_chat_members(chat_id):
if member.user.is_deleted:
try:
Expand Down Expand Up @@ -500,6 +492,8 @@ async def zombie_clean(message: Message):
r"`i don't have proper permission to do that! (*  ̄︿ ̄)`", del_in=5
)
else:
del_users = 0
del_stats = r"`Zero zombie accounts found in this chat... WOOHOO group is clean.. \^o^/`"
await message.edit("`🔎 Searching for zombie accounts in this chat..`")
async for member in message.client.iter_chat_members(chat_id):
if member.user.is_deleted:
Expand Down
Loading

0 comments on commit d637b0e

Please sign in to comment.