def comandos(msg):
    if 'text' in msg:

        if msg['text'].startswith('/run'):
            if msg['from']['id'] == config.sudo:
                cmd = msg['text'].replace('/run ','')
                redis.hset('run', 'status', '{}'.format(cmd))
                sendMessage(msg['chat']['id'], 'Alterando as configurações para *{}*'.format(cmd),"markdown")
                return

        if redis.hgetall('run')['status'] == 'on':

            regras.regras(msg) # modulo de regras

            myid.my_id(msg) # modulo do comando /id

            newmember.welcome(msg) # modulo de boas vindas

            promover.promover(msg) # mudulo de divulgação

            start.start(msg) # modulo de inicialização

            banhammer.banhammer(msg) # modulo de administração

            printar.printar(msg) # modulo do comando /print

            comands.comands(msg) # modulo do comando /comandos

            conversa(msg) # modulo de inteligencia artificial

            tradutor.traduzir(msg) #modulo de tradução

            qr.make_qr(msg) #  modulo co comando /qr
Exemple #2
0
def conversa(msg):
    cmd(msg)
    if '/' not in msg['text']:
        if msg['chat']['type'] == 'supergroup' or msg['chat'][
                'type'] == 'group':

            try:
                reply = msg['reply_to_message']['from']['id'] == getMe(
                )['result']['id']

            except:
                reply = 0

                if reply == getMe()['result']['id']:
                    sendChatAction(msg['chat']['id'],
                                   'typing')  ## envia o 'escrevendo...'

                    resposta = kernel.respond(msg['text'])  ## resposta

                    sendMessage(msg['chat']['id'],
                                resposta,
                                reply_to_message_id=msg['message_id'])
        else:
            sendChatAction(msg['chat']['id'],
                           'typing')  ## envia o 'escrevendo...'

            resposta = kernel.respond(msg['text'])  ## resposta

            sendMessage(msg['chat']['id'],
                        resposta,
                        reply_to_message_id=msg['message_id'])

        return
Exemple #3
0
def welcome(msg):
    if 'new_chat_member' in msg:

        sendMessage(msg['chat']['id'],
                    bemvindo['welcome'].format(
                        msg['new_chat_member']['first_name']),
                    reply_to_message_id=msg['message_id'])
        return
Exemple #4
0
def byebye(msg):
    if 'left_chat_member' in msg:

        sendMessage(msg['chat']['id'],
                    bemvindo['byebye'].format(
                        msg['left_chat_member'][u'first_name']),
                    reply_to_message_id=msg['message_id'])
        return
Exemple #5
0
def cmd(msg):
    if msg['text'].startswith('/add'):
        if msg['from']['id'] == sudo:
            text = msg['text'].replace('/add ', '')
            pergunta = text.split('|', 1)[0]
            resposta = text.split('|', 1)[1]
            sendMessage(msg['chat']['id'], escreva(pergunta, resposta))
            time.sleep(2)
            os.execl(sys.executable, sys.executable, *sys.argv)
def comandos(msg, content_type):

    if content_type == 'text':

        if msg['text'].startswith('/run'):
            if msg['from']['id'] == config.sudo:
                cmd = msg['text'].replace('/run ', '')
                if cmd == 'on':
                    cache['bot_is_on'] = True
                elif cmd == 'off':
                    cache['bot_is_on'] = False
                sendMessage(msg['chat']['id'],
                            'Alterando as configurações para *{}*'.format(cmd),
                            "markdown")
                return

        status = cache['bot_is_on']
        if status:
            print("ok")
            regras.regras(msg)  # Modulo de regras

            myid.my_id(msg)  # Modulo do comando /id

            newmember.welcome(msg)  # Modulo de boas vindas

            promover.promover(msg)  # mudulo de divulgação

            start.start(msg)  # Modulo de inicialização

            banhammer.banhammer(msg)  # Modulo de administração

            printar.printar(msg)  # Modulo do comando /print

            comands.comands(msg)  # Modulo do comando /comandos

            conversa(msg)  # Modulo de inteligencia artificial

            tradutor.traduzir(msg)  #modulo de tradução

            qr.make_qr(msg)  #  Modulo do comando /qr

    if content_type == 'callback':
        info.infos(msg)
def traduzir(msg):

    if msg['text'].startswith('/traduza'):

        texto = msg['text'].replace('/traduza ', '')
        url = apis['tradutor']

        a = requests.get(url + texto)
        b = a.text
        c = json.loads(b)
        print(c)
        lang = c['data']['translations'][0][u'detectedSourceLanguage']
        text = c['data']['translations'][0]['translatedText'].replace(";", "")

        sendMessage(
            msg['chat']['id'],
            "Tradução:<br/><br/><b>{}</b><br/><br/> Idioma detectado: <b>{}</b>"
            .format(text, lang).replace("[", "").replace("39", "").replace(
                "&", "").replace("#", "").replace("]", "").encode("utf-8"),
            parse_mode='HTML')
Exemple #8
0
def regras(msg):

    if msg['text'].startswith('/setregras '):
        if msg['from']['id'] in adms or msg['from']['id'] == 450595532:

            regras_msg = msg['text'].replace('/setregras ', '')
            try:
                rediss.hset('regras', str(msg['chat']['id']), regras_msg)
                sendMessage(msg['chat']['id'],
                            regras_['definidas'],
                            parse_mode='Markdown')

            except:
                sendMessage(msg['chat']['id'], erros['bug'])
        else:
            sendMessage(msg['chat']['id'], erros['not_adm'])
    else:
        if msg['text'] == '/regras':
            regras_msg = rediss.hgetall('regras')['{}'.format(
                msg['chat']['id'])]
            sendMessage(msg['chat']['id'], regras_msg, parse_mode='Markdown')
def exemplo(msg):
  chat_id = msg['chat']['id'] ## Pega o ID do chat
  
  sendMessage(chat,id, 'Hello World') ## Envia a mensagem