Skip to content
This repository has been archived by the owner on Aug 20, 2023. It is now read-only.

Commit

Permalink
Add migrate handlers and more fix
Browse files Browse the repository at this point in the history
  • Loading branch information
BluLupo committed Jan 23, 2021
1 parent dbacc96 commit 45f76dd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 20 deletions.
5 changes: 2 additions & 3 deletions core/commands/admin/warn.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,24 @@
from core.utilities.message import message
from core.handlers.logs import telegram_loggers

#TODO LOGIC ERROR IN WARN , NEED NEW DATABASE TABLE FOR JOIN
@decorators.admin.user_admin
@decorators.delete.init
def init(update,context):
user = user_reply_object(update)
chat = chat_object(update)
get_user = UserRepository().getUserByGroup([user.id,chat.id])
get_group = GroupRepository().getById(chat.id)

warn_count = get_user['warn_count'] if get_user is not None else 0
max_warn = get_group['max_warn']
default_warn = 1

if warn_count != max_warn:
if get_user:
default_warn_count = 0
username = "@"+user.username
data = [(username,user.id)]
UserRepository().update(data)
data_mtm = [(user.id, chat.id, default_warn)]
data_mtm = [(user.id, chat.id, default_warn_count)]
UserRepository().add_into_mtm(data_mtm)
data_warn = [(user.id,chat.id)]
UserRepository().updateWarn(data_warn)
Expand Down
2 changes: 1 addition & 1 deletion core/commands/owner/superban.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def init(update,context):
ban_user_reply(update,context)
delete_message_reply(update,context)
logs_text = Strings.SUPERBAN_LOG.format(user_id,motivation,save_date,operator_id)
message(update,context,"You got super banned <code>{}</code>".format(user_id))
message(update,context,"You got super banned <code>{}</code>\nGo to: https://squirrel-network.online/knowhere".format(user_id))
telegram_loggers(update,context,logs_text)
formatter = "Superban eseguito da: {}".format(update.message.from_user.id)
sys_loggers("[SUPERBAN_LOGS]",formatter,False,False,True)
Expand Down
14 changes: 2 additions & 12 deletions core/handlers/handlers_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,18 @@
from core import handlers
from core.commands import public
from telegram.ext import (MessageHandler as MH,Filters)
from core.utilities.functions import chat_object, user_object

def test_handler(update,context):
a = print("NO EXE ALLOWED")
return a

def terminal_handler(update):
user = user_object(update)
chat = chat_object(update)
text = str(update.effective_message.text)
msg = "FIRST_NAME: {}\nTG_ID: {}\nCHAT_ID: {}\nCHAT_TITLE: {}\nMESSAGE: {}".format(user.first_name,user.id,chat.id,chat.title,text)
a = print(msg)
return a

def core_handlers(dsp):
function = dsp.add_handler
function(MH(Filters.text("@admin"), public.report.init))
function(MH(Filters.document.exe, test_handler))
function(MH(Filters.status_update.new_chat_members, handlers.welcome.init, run_async=True))
function(MH(Filters.chat_type.groups, group_handlers, run_async=True))
#function(MH(Filters.status_update.migrate, handlers.migrate_chat.init, run_async=True))

def group_handlers(update,context):
handlers.check_status_user.check_status(update,context)
terminal_handler(update)
handlers.check_status_user.check_status(update, context)
handlers.migrate_chat.init(update, context)
13 changes: 9 additions & 4 deletions core/handlers/migrate_chat.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
from core.utilities.message import message
from core.database.repository.group import GroupRepository

def init(update, context):
old_chat_id = update.message.migrate_from_chat_id
new_chat_id = update.message.chat.id
print(old_chat_id)
print(new_chat_id)
if update.message.migrate_from_chat_id:
old_chat_id = update.message.migrate_from_chat_id
new_chat_id = update.message.chat.id
data = [(new_chat_id, old_chat_id)]
GroupRepository().update(data)
message(update,context,"<b>#Automatic handler:</b>\nThe chat has been migrated to <b>supergroup</b> the bot has made the modification on the database.\n<i>It is necessary to put the bot admin</i>")

0 comments on commit 45f76dd

Please sign in to comment.