Fix some bugs

main
t 10 months ago
parent 7fe6869dfc
commit 7514991082

@ -97,23 +97,34 @@ def is_anon(message):
return False
def get_target(message):
try:
# try:
if True:
global users
if len(message.text.split()) > 1 and message.text.split()[1][0] == "@":
username = message.text.split()[1][1:]
global users
read_users()
if sha(username) in users:
return users[sha(username)]
else:
print(1)
return None
elif len(message.text.split()) > 1 and message.text.split()[2][0] == "@":
username = message.text.split()[2][1:]
read_users()
if sha(username) in users:
return users[sha(username)]
else:
print(2)
return None
else:
target = message.reply_to_message.from_user.id
if target not in get_admins(message):
return target
else:
print(3)
return None
except:
return None
# except:
# return None
def get_name(message):
try:
@ -122,6 +133,8 @@ def get_name(message):
# If message with @username
if len(text) > 1 and text[1][0] == '@':
return text[1]
if len(text) > 1 and text[2][0] == '@':
return text[2]
# Reply to message
else:
return telebot.util.user_link(message.reply_to_message.from_user)
@ -207,6 +220,7 @@ def mute(message):
try:
if have_rights(message):
target = get_target(message)
print(target)
if target:
if len(message.text.split()) == 1:
bot.restrict_chat_member(message.chat.id, target, until_date = message.date)
@ -351,7 +365,7 @@ def getid(message):
@bot.message_handler(commands=['del'])
def secret(message):
def delete(message):
try:
if have_rights(message):
bot.delete_message(message.chat.id, message.reply_to_message.id)

Loading…
Cancel
Save