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

Update dependency python-telegram-bot to v20 - abandoned #82

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions NekoRobot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ def error_handler(update: Update, context: CallbackContext):
def error_callback(_, context: CallbackContext):
try:
raise context.error
except (BadRequest):
except BadRequest:
pass
# remove update.message.chat_id from conversation list
except TimedOut:
Expand Down Expand Up @@ -465,7 +465,6 @@ def get_help(update: Update, context: CallbackContext) -> None:

# ONLY send help in PM
if chat.type != chat.PRIVATE:

update.effective_message.reply_photo(
HELP_IMG,
HELP_MSG,
Expand Down
1 change: 0 additions & 1 deletion NekoRobot/modules/anime.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,6 @@ def site_search(update: Update, context: CallbackContext, site: str):

result = f"<b>Search results for</b> <code>{html.escape(search_query)}</code> <b>on</b> <code>AnimeKayo</code>: \n"
for entry in search_result:

if entry.text.strip() == "Nothing Found":
result = f"<b>No result found for</b> <code>{html.escape(search_query)}</code> <b>on</b> <code>AnimeKayo</code>"
more_results = False
Expand Down
1 change: 0 additions & 1 deletion NekoRobot/modules/announcements.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def chatmemberupdates(update: Update, context: CallbackContext) -> Optional[str]
cause_name = update.chat_member.from_user.mention_html()
member_name = update.chat_member.new_chat_member.user.mention_html()
if oldtitle != newtitle:

if str(update.chat_member.from_user.id) == str(bot.id):
return "" # we handle these in their respective modules
if oldtitle is None:
Expand Down
1 change: 0 additions & 1 deletion NekoRobot/modules/backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ def import_data(update, context):
# TODO: some of that link logic
# NOTE: consider default permissions stuff?
if conn:

text = f"Backup fully restored on *{chat_name}*."
else:
text = "Backup fully restored"
Expand Down
1 change: 0 additions & 1 deletion NekoRobot/modules/blacklistusers.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ def unbl_user(update: Update, context: CallbackContext) -> str:
message.reply_text("I can't seem to find this user.")
return ""
if sql.is_user_blacklisted(user_id):

sql.unblacklist_user(user_id)
message.reply_text("*notices user*")
return f"#UNBLACKLIST\n<b>Admin:</b> {mention_html(user.id, html.escape(user.first_name))}\n<b>User:</b> {mention_html(target_user.id, html.escape(target_user.first_name))}"
Expand Down
7 changes: 0 additions & 7 deletions NekoRobot/modules/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
@user_admin
@typing_action
def allow_connections(update, context) -> str:

chat = update.effective_chat
args = context.args

Expand Down Expand Up @@ -87,7 +86,6 @@ def allow_connections(update, context) -> str:

@typing_action
def connection_chat(update, context):

chat = update.effective_chat
user = update.effective_user

Expand All @@ -111,7 +109,6 @@ def connection_chat(update, context):

@typing_action
def connect_chat(update, context):

chat = update.effective_chat
user = update.effective_user
if update.effective_chat.type == "private":
Expand Down Expand Up @@ -273,7 +270,6 @@ def connect_chat(update, context):


def disconnect_chat(update, context):

if update.effective_chat.type == "private":
if disconnection_status := sql.disconnect(
update.effective_message.from_user.id
Expand All @@ -292,7 +288,6 @@ def connected(bot: Bot, update: Update, chat, user_id, need_admin=True):
user = update.effective_user

if chat.type == chat.PRIVATE and sql.get_connected_chat(user_id):

conn_id = sql.get_connected_chat(user_id).chat_id
getstatusadmin = bot.get_chat_member(
conn_id,
Expand Down Expand Up @@ -353,7 +348,6 @@ def connected(bot: Bot, update: Update, chat, user_id, need_admin=True):


def help_connect_chat(update, context):

context.args

if update.effective_message.chat.type != "private":
Expand All @@ -363,7 +357,6 @@ def help_connect_chat(update, context):


def connect_button(update, context):

query = update.callback_query
chat = update.effective_chat
user = update.effective_user
Expand Down
1 change: 0 additions & 1 deletion NekoRobot/modules/crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ def section(
indent: int = 2,
underline: bool = False,
) -> str:

text = (bold_ul(title) + n) if underline else bold(title) + n

for key, value in body.items():
Expand Down
1 change: 0 additions & 1 deletion NekoRobot/modules/dbcleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def get_invalid_chats(update: Update, context: CallbackContext, remove: bool = F
progress_message = None

for chat in chats:

if ((100 * chats.index(chat)) / len(chats)) > progress:
progress_bar = f"{progress}% completed in getting invalid chats."
if progress_message:
Expand Down
1 change: 0 additions & 1 deletion NekoRobot/modules/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def logs(update: Update, context: CallbackContext):
return
user = update.effective_user
with open("log.txt", "rb") as f:

context.bot.send_document(document=f, filename=f.name, chat_id=user.id)


Expand Down
2 changes: 0 additions & 2 deletions NekoRobot/modules/global_bans.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ def gban(update: Update, context: CallbackContext):
return

if sql.is_user_gbanned(user_id):

if not reason:
message.reply_text(
"This user is already gbanned; I'd change the reason, but you haven't given me one..."
Expand Down Expand Up @@ -394,7 +393,6 @@ def gbanlist(update: Update, context: CallbackContext):


def check_and_ban(update, user_id, should_message=True):

chat = update.effective_chat # type: Optional[Chat]
try:
sw_ban = sw.get_ban(int(user_id))
Expand Down
1 change: 0 additions & 1 deletion NekoRobot/modules/guess.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

@neko.on(events.NewMessage(pattern="/guess ?(.*)"))
async def wish(e):

if e.is_reply:
mm = random.randint(1, 100)
lol = await e.get_reply_message()
Expand Down
1 change: 0 additions & 1 deletion NekoRobot/modules/helper_funcs/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ def check_update(self, update):
if len(fst_word) > 1 and any(
fst_word.startswith(start) for start in CMD_STARTERS
):

args = message.text.split()[1:]
command = fst_word[1:].split("@")
command.append(message.bot.username)
Expand Down
1 change: 0 additions & 1 deletion NekoRobot/modules/helper_funcs/miku_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ def article(
reply_markup: InlineKeyboardMarkup = None,
disable_web_page_preview: bool = False,
) -> InlineQueryResultArticle:

return InlineQueryResultArticle(
id=uuid4(),
title=title,
Expand Down
1 change: 0 additions & 1 deletion NekoRobot/modules/helper_funcs/msg_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ def get_welcome_type(msg: Message):


def get_filter_type(msg: Message):

if not msg.reply_to_message and msg.text and len(msg.text.split()) >= 3:
content = None
text = msg.text.split(None, 2)[2]
Expand Down
1 change: 0 additions & 1 deletion NekoRobot/modules/helper_funcs/telethn/chatstatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ async def can_add_admins(message):


async def can_delete_messages(message):

if message.is_private:
return True
if message.chat.admin_rights:
Expand Down
2 changes: 0 additions & 2 deletions NekoRobot/modules/imdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@

async def is_register_admin(chat, user):
if isinstance(chat, (types.InputPeerChannel, types.InputChannel)):

return isinstance(
(
await tbot(functions.channels.GetParticipantRequest(chat, user))
).participant,
(types.ChannelParticipantAdmin, types.ChannelParticipantCreator),
)
if isinstance(chat, types.InputPeerChat):

ui = await tbot.get_peer_id(user)
ps = (
await tbot(functions.messages.GetFullChatRequest(chat.chat_id))
Expand Down
1 change: 0 additions & 1 deletion NekoRobot/modules/inline.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,6 @@ def media_query(query: str, update: Update, context: CallbackContext) -> None:
)
)
except Exception as e:

kb = InlineKeyboardMarkup(
[
[
Expand Down
1 change: 0 additions & 1 deletion NekoRobot/modules/meme.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ def slap(update: Update, context: CallbackContext):
return

if user_id:

slapped_user = bot.get_chat(user_id)
user1 = curr_user
user2 = html.escape(slapped_user.first_name)
Expand Down
1 change: 0 additions & 1 deletion NekoRobot/modules/ping.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ def ping_func(to_ping: List[str]) -> List[str]:
ping_result = []

for each_ping in to_ping:

start_time = time.time()
site_to_ping = sites_list[each_ping]
r = requests.get(site_to_ping)
Expand Down
1 change: 0 additions & 1 deletion NekoRobot/modules/reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ def report(update: Update, context: CallbackContext) -> str:
return ""

if chat.username and chat.type == Chat.SUPERGROUP:

reported = f"{mention_html(user.id, user.first_name)} reported {mention_html(reported_user.id, reported_user.first_name)} to the admins!"

msg = (
Expand Down
2 changes: 0 additions & 2 deletions NekoRobot/modules/sql/cleaner_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ def chat_ignore_command(chat_id, ignore):
ignored = SESSION.query(CleanerBlueTextChat).get((str(chat_id), ignore))

if not ignored:

if str(chat_id) not in CLEANER_CHATS:
CLEANER_CHATS.setdefault(
str(chat_id), {"setting": False, "commands": set()}
Expand All @@ -121,7 +120,6 @@ def chat_unignore_command(chat_id, unignore):
unignored = SESSION.query(CleanerBlueTextChat).get((str(chat_id), unignore))

if unignored:

if str(chat_id) not in CLEANER_CHATS:
CLEANER_CHATS.setdefault(
str(chat_id), {"setting": False, "commands": set()}
Expand Down
4 changes: 0 additions & 4 deletions NekoRobot/modules/userinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ def hpmanager(user):
total_hp = (get_user_num_chats(user.id) + 10) * 10

if not is_user_gbanned(user.id):

# Assign new var `new_hp` since we need `total_hp` in
# end to calculate percentage.
new_hp = total_hp
Expand Down Expand Up @@ -150,9 +149,7 @@ def get_id(update: Update, context: CallbackContext):
user_id = extract_user(msg, args)

if user_id:

if msg.reply_to_message and msg.reply_to_message.forward_from:

user1 = message.reply_to_message.from_user
user2 = message.reply_to_message.forward_from

Expand All @@ -164,7 +161,6 @@ def get_id(update: Update, context: CallbackContext):
)

else:

user = bot.get_chat(user_id)
msg.reply_text(
f"{html.escape(user.first_name)}'s id is <code>{user.id}</code>.",
Expand Down
3 changes: 0 additions & 3 deletions NekoRobot/modules/welcome.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ def new_member(update: Update, context: CallbackContext):
new_members = update.effective_message.new_chat_members

for new_mem in new_members:

welcome_log = None
res = None
sent = None
Expand All @@ -174,7 +173,6 @@ def new_member(update: Update, context: CallbackContext):
return

if should_welc:

reply = update.message.message_id
cleanserv = sql.clean_service(chat.id)
# Clean service welcome
Expand Down Expand Up @@ -502,7 +500,6 @@ def left_member(update: Update, context: CallbackContext):

left_mem = update.effective_message.left_chat_member
if left_mem:

# Thingy for spamwatched users
if sw is not None:
sw_ban = sw.get_ban(left_mem.id)
Expand Down
1 change: 0 additions & 1 deletion NekoRobot/modules/wish.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

@neko.on(events.NewMessage(pattern="/wish ?(.*)"))
async def wish(e):

if e.is_reply:
mm = random.randint(1, 100)
lol = await e.get_reply_message()
Expand Down
2 changes: 1 addition & 1 deletion NekoRobot/modules/zombie.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@

OFFICERS = [OWNER_ID] + DEV_USERS + DRAGONS + DEMONS


# Check if user has admin rights
async def is_administrator(user_id: int, message):
admin = False
Expand All @@ -83,7 +84,6 @@ async def zombies(event):
if con != "clean":
find_zombies = await event.respond("Searching For Zombies...")
async for user in event.client.iter_participants(event.chat_id):

if user.deleted:
del_u += 1
await sleep(1)
Expand Down
1 change: 0 additions & 1 deletion NekoRobot/services/sections.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def section(
indent: int = 2,
underline: bool = False,
) -> str:

text = (bold_ul(title) + n) if underline else bold(title) + n

for key, value in body.items():
Expand Down
1 change: 0 additions & 1 deletion NekoRobot/services/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ async def add_task(
*args,
**kwargs,
):

async with TASKS_LOCK:
global tasks

Expand Down
11 changes: 0 additions & 11 deletions NekoRobot/utils/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@


def split_limits(text):

if len(text) < 2048:

return [text]

lines = text.splitlines(True)
Expand All @@ -47,19 +45,15 @@ def split_limits(text):
result = []

for line in lines:

if len(small_msg) + len(line) < 2048:

small_msg += line

else:

result.append(small_msg)

small_msg = line

else:

result.append(small_msg)

return result
Expand All @@ -68,19 +62,15 @@ def split_limits(text):
def capture_err(func):
@wraps(func)
async def capture(client, message, *args, **kwargs):

try:

return await func(client, message, *args, **kwargs)

except ChatWriteForbidden:

await app.leave_chat(message.chat.id)

return

except Exception as err:

exc_type, exc_obj, exc_tb = sys.exc_info()

errors = traceback.format_exception(
Expand All @@ -99,7 +89,6 @@ async def capture(client, message, *args, **kwargs):
)

for x in error_feedback:

await app.send_message(LOG_GROUP_ID, x)

raise err
Expand Down
Loading