예제 #1
0
def Function(msg, cmd, ln):
    if "botadded" in cmd[0]:
        api.sendAdmin(text=lang('alertbotadded', 'service', sudo=True).format(
            json.dumps(msg['chat'], indent=1),
            json.dumps(msg['adder'], indent=1)),
                      parse_mode="HTML")
        return utils.msg_replace_(msg, lang('newGroup', ln))
    elif "botremoved" in cmd[0]:
        api.sendAdmin(text=lang('alertbotremoved', 'service',
                                sudo=True).format(
                                    json.dumps(msg['chat'], indent=1),
                                    json.dumps(msg['adder'], indent=1)),
                      parse_mode="HTML")
예제 #2
0
def Function(msg, cmd):
    if 'sudo' in cmd[0]:
        if (cmd[1] == 'update'):
            _all, admin, utility, entertainment = plugins.loadplugins()
            info = "📟 Updated Plugins: {}".format(_all)
            return api.sendMessage(chat_id=msg['chat']['id'], text=info)
        elif (cmd[1] == 'reboot'):
            import os, sys, time
            try:
                api.sendMessage(chat_id=msg['chat']['id'], text='Done')
            finally:
                time.sleep(0.8)
                os.execl(sys.executable, sys.executable, *sys.argv)
    elif cmd[0] == 'resp':
        if not msg["reply"]: return "Respond directly to feedback"
        if not cmd[1]:
            return 'Write something to respond to feedback'
        else:
            input_text = "\n{}\n<b>________________________<\b>\n<b>Sincerely, Support Team.<\b>".format(
                cmd[1])
        msg = msg["reply_to_message"]
        receiver = msg["forward_from"]["id"]
        res = api.sendMessage(msg["chat"]["id"],
                              '<b>Reply sent:<\b>{}\n\n'.format(input_text),
                              "HTML")
        try:
            api.sendMessage(receiver, input_text, "HTML")
        except:
            api.sendMessage(
                msg["chat"]["id"],
                'Oops, the following error occurred: Markdown was used incorrectly!'
            )
    elif 'debug' in cmd[0]:
        format_ = "<code>{}</code>"
        if len(cmd) == 2 and cmd[1] == "user" and "reply" in msg:
            api.sendMessage(chat_id=msg['chat']['id'],
                            text=format_.format(
                                json.dumps(msg['reply']['from'], indent=1)),
                            parse_mode="HTML")
        else:
            api.sendMessage(chat_id=msg['chat']['id'],
                            text=format_.format(json.dumps(msg, indent=1)),
                            parse_mode="HTML")
예제 #3
0
def polling():
    from methods.methods import METHOD as api
    api.deleteWebhook()
    resp = None
    if 'result' in resp:
        temp = 0
        resp = api.getUpdates(offset=temp,
                              timeout=1000 + l_,
                              allowed_updates='message')
        temp = resp['result'][0]['update_id'] + 1
        resp = requests.post("http://localhost:3000/webhook",
                             data=json.dumps(resp['result'][0]))
    return resp
예제 #4
0
def Function(msg, cmd, ln):
    global maintenance
    if 'sudo' in cmd[0]:
        if (cmd[1] == 'update'):
            return api.sendAdmin(chat_id=msg['chat']['id'],
                                 text=lang('updatecommand',
                                           'plugin',
                                           sudo=True).format(plugins_()))

        elif (cmd[1] == 'manut'):
            config['MAINTENACE'] = True
            api.sendAdmin(chat_id=msg['chat']['id'], text="Done")
            return config['MAINTENACE']

        elif (cmd[1] == 'notmanut'):
            config['MAINTENACE'] = False
            api.sendAdmin(chat_id=msg['chat']['id'], text="Done")
            return config['MAINTENACE']

    elif ('shell' in cmd[0]) or ('git' in cmd[0]):
        text = cmd[1].replace('—', '--')
        if ('git' in cmd[0]): text = "git {}".format(text)
        r = utils.bash_(text)
        if len(r) == 0: r = lang('Shell_Not', 'tools', sudo=True)
        api.sendAdmin(chat_id=msg['chat']['id'], text=r)
    elif 'debug' in cmd[0]:
        if len(cmd) == 2 and cmd[1] == "user" and "reply" in msg:
            api.sendAdmin(chat_id=msg['chat']['id'],
                          text="<code>{}</code>".format(
                              json.dumps(msg['reply']['from'], indent=1)),
                          parse_mode="HTML")
        else:
            api.sendAdmin(chat_id=msg['chat']['id'],
                          text="<code>{}</code>".format(
                              json.dumps(msg, indent=1)),
                          parse_mode="HTML")
예제 #5
0
def handler_():
	if request.method == 'GET' and request.path == "/webhook_int":
		allowed = ["message", "edited_message", "callback_query"]
		r = api.setWebhook("{}/webhook".format(request.host), max_connections=int(1), allowed_updates=json.dumps(allowed))
		resp = lang('started_webhook', 'main', sudo='True').format(r['description'])
		return Response(response=resp,status=200)
		
	elif request.method == 'POST' and request.path == "/webhook":
		msg = request.get_json(silent=True, force=True)
		if config['DEBUG_REQUEST'] == True: print(json.dumps(msg, indent=1))
		if ('message' in msg) or ('callback_query' in msg) or ('edited_message' in msg):
			if ('callback_query' in msg):
					msg = msg['callback_query']
					msg['text'] = '###cb: {}'.format(msg['data'])
					msg['old_text'] = msg['message']['text']
					msg['date'] = msg['message']['date']
					msg['cb'] = True
					msg['cb_id'] = msg['id']
					msg['message_id'] = msg['message']['message_id']
					msg['chat'] = msg['message']['chat']
					msg['message'] = None
					return msg_receive_(msg)
			elif ('edited_message' in msg):
					msg['message'] = msg['edited_message']
					msg['edited_message'] = None
			elif ('message' in msg):
					msg = msg['message']
					msg['action'] = True
					msg['text_action'] = True
					if 'text' in msg: msg['action'] = "###text"
					if ("migrate_to_chat_id" in msg) or ('migrate_from_chat_id' in msg):
							msg['action'] = '###migrate'
							if ("migrate_from_chat_id" in msg): msg['migrate_to_chat_id'] = msg['migrate_from_chat_id']
							msg['old'] = msg['migrate_to_chat_id']
							msg['new'] = msg['chat']['id']
							return msg_receive_(msg)
					elif ('new_chat_member' in msg) or ('left_chat_member' in msg) or ('group_chat_created' in msg):
						msg['service'] = True
						if ("new_chat_member" in msg):
								if str(msg['new_chat_member']['id']) == str(config['IDBOT']):
										msg['action'] = '###botadded'
								else: 
										msg['action'] = '###added'
										msg['adder'] = msg['from']
										msg['added'] = msg['new_chat_member']
						elif ("left_chat_member" in msg):
								if str(msg['left_chat_member']['id']) == str(config['IDBOT']): 
										msg['action'] = '###botremoved'
								else: 
										msg['action'] = '###removed'
										msg['remover'] = msg['from']
										msg['removed'] = msg['left_chat_member']
						elif ("group_chat_created" in msg):
										msg['chat_created'] = True
										msg['adder'] = msg['from']
										msg['action'] = '###botadded'
						return msg_receive_(msg)
					elif ('forward_from' in msg):
						if (msg['forward_from']["is_bot"] == True): msg['action'] = '###forwardbot'
						msg['action'] = '###forward'
						return msg_receive_(msg)
					elif ('reply_to_message' in msg):
						msg['action'] = "###reply"
						msg['reply'] = msg["reply_to_message"]
						if ("caption" in msg['reply']): msg['text'] = msg['reply']['caption']
						return msg_receive_(msg)
					elif ('pinned_message' in msg):
						msg['action'] = "###pinned_message"
						msg['text'] = msg['pinned_message']['text']
						return msg_receive_(msg)
					elif ('photo'  in msg) or ('video'  in msg) or ('document'  in msg) or ('voice'  in msg) or ('audio'  in msg) or ('sticker'  in msg) or ('entities'  in msg):
						if ('photo' in msg):msg['action'] = "###Photo"
						elif ('sticker' in msg):msg['action'] = "###Sticker"
						elif ('voice' in msg):msg['action'] = "###Voice"
						elif ('audio' in msg):msg['action'] = "###Audio"
						elif ('video' in msg):msg['action'] = "###Video"
						elif ('contact' in msg):msg['action'] = "###contact"
						elif ('document' in msg and msg['document']['mime_type']):
								document = msg['document']['mime_type']
								if (document == "video/mp4"):msg['action'] = "###gif"
								elif (document == "application/x-bittorrent"):msg['action'] = "###pdf_file"    
								elif (document == "application/vnd.android.package-archive"):msg['action'] = "###app"    
								elif (document == "application/x-rar"):msg['action'] = "###rar_file"    
								elif (document == "application/x-zip"):msg['action'] = "###zip_file"    
								elif (document == "text/x-python"):msg['action'] = "###script_in_python"    
								elif (document == "text/plain"):msg['action'] = "###text_file"    
								elif (document == "application/x-shellscript"):msg['action'] = "###script_in_shell"    
								elif (document == "text/x-lua"):msg['action'] = "###script_in_lua"    
								elif (document == "text/html"):msg['action'] = "###script_in_HTML"    
								elif (document == "application/json"):msg['action'] = "###script_in_JSON"    
								elif (document == "application/javascript"):msg['action'] = "###script_in_JavaScript"    
								elif (document == "application/octet-stream"):msg['action'] = "###script_in_octet-stream"    
								elif (document == "text/markdown"):msg['action'] = "###script_in_Markdown"    
								elif (document == "application/x-yaml"):msg['action'] = "###script_in_yaml."
								else:msg['action'] = "###file"
						elif ('entities' in msg):
								if (msg['entities'][0]['type'] == "url"):
									msg['action'] = '###url'
								elif (msg['entities'][0]['type'] == "mention"):
									msg['action'] = '###mention'
								elif (msg['entities'][0]['type'] == "bot_command"):
									msg['action'] = '###bot_command'
									msg['text'] = msg['text'].replace("@{}".format(config['USERNAMEBOT']),'')
						return msg_receive_(msg)
					else: msg_receive_(msg)