1

Tenho o seguinte código:

import socket
from xml.etree import ElementTree as et
import math, urllib
import random, time, re
global String_1, String_2, String_3, String_4, Chat, Using_Proxies, Raid_Fixed_j2

def Raid():
    try:
            nxat_ids = [i.strip() for i in open('ids.txt','r').read().splitlines()]
            i = random.choice(nxat_ids)
            nxat_id = i.split('&')
            print("\n" + str(nxat_id))
            ID = zat_id[0]
            ID = zat_id[0].strip('UserId=')
            K1 = zat_id[1]
            K1 = zat_id[1].strip('k1=')
    except:
            print("'ids.txt' was not found! Please create one in the same folder that this script is in and add IDs to it SPECIFALLY IN THIS LAYOUT: http://prntscr.com/55tzbi OR use my ids.txt http://pastebin.com/353eebdH\n")
            time.sleep(999)
    if Using_Proxies == 'yes':
            Proxies_txt = [i.strip() for i in open('socks5.txt','r').read().splitlines()]
            Proxy = random.choice(Proxies_txt)
            proxy = Proxy.split(':')
            print "Proxy Being Used: " + str(Proxy[0]) + ":" + str(Proxy[1]) + "\n"
            try:
                    socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, Proxy[0], int(Proxy[1]))
                    test = socks.socksocket
                    Socket = test(socket.AF_INET, socket.SOCK_STREAM, socket.SOL_TCP)
                    Socket.settimeout(5)
                    Socket.connect(("167.114.19.192", 1204))
            except:
                    print "Could not connect using the selected proxy! Or 'socks5.txt' was not found! Re-trying....\n"
                    Raid()
    elif Using_Proxies != 'yes':
            Socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.SOL_TCP)
            Socket.connect(('167.114.19.192', 1204))
            Socket.send('<y r="'+Chat+'" v="0" u="'+ID+'" />\0')
            XML = et.fromstring(Socket.recv(1024).strip('\0')).attrib
            print('Recieved: ' + str(XML))
            Handshake_yi = int(XML['yi'])
            Handshake_yc = int(XML['yc'])
            Handshake_ys = int(XML['ys'])
            ym1 = str(int(2 << (Handshake_yi % 30)) % Handshake_yc + Handshake_yi)
            print("YM1: " + ym1)
            ym2 = str(int(pow(2, Handshake_ys % 32)))
            print("YM2: " + ym2)
            String_1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890'
            String_2 = len(String_1) - 1
            String_4 = ''.join([String_1[random.randint(0, String_2)] for y in range(1, 10)])#Null's name
            Avatar = random.randint(1,1000)
            Socket.send('<j2 cb="0" Y="2" ym1="'+str(ym1)+'" ym2="'+str(ym2)+'" q="1" y="'+str(Handshake_yi)+'" k="'+K1+'" p="0" c="'+Chat+'" u="'+ID+'" d0="0" n="'+String_4+'" a="'+str(Avatar)+'" h="" v="0" />')
            while 1:
                    String_3 = ''.join([String_1[random.randint(0, String_2)] for y in range(1, 15)])#Message
                    Data = Socket.recv(1024)
                    Socket.send('<m t="'+String_3+'" u="'+ID+'" />\0')
                    Raid()
print("-----------------------------")
print("TheFox's nxat.tk Raid Script")
print("---------------------------\n")
Chat = raw_input("Chat's ID: ")
Using_Proxies = raw_input("Would you like to use proxies? Type 'yes' or 'no' : ")
Raid()

E quando coloco a ID do chat e escolho se quero proxies ou não me retorna a seguinte exceção:

'ids.txt' was not found! Please create one in the same folder that this script is in and add IDs to it SPECIFALLY IN THIS LAYOUT: http://prntscr.com/55tzbi OR use my ids.txt http://pastebin.com/353eebdH

O pior é que eu já tenho o arquivo criado na mesma pasta onde está o arquivo .py. O que faço?

1 Resposta 1

0

O erro que está tendo é que zat_id está sendo acessado sem ser definido em:

ID = zat_id[0]
ID = zat_id[0].strip('UserId=')
K1 = zat_id[1]
K1 = zat_id[1].strip('k1=')

No entanto o except pegará qualquer excessão, e não apenas as excessões de abertura de arquivo, que é o comportamento esperado.

Para capturar apenas as excessões relacionadas a arquivos adicione IOError e terá o feedback esperado.

except IOError:
        print("'ids.txt' was not found! Please create one in the same folder that this script is in and add IDs to it SPECIFALLY IN THIS LAYOUT: http://prntscr.com/55tzbi OR use my ids.txt http://pastebin.com/353eebdH\n")
        time.sleep(999)

Agora o erro deverá ser algo como:

Traceback (most recent call last):
  File "ex.py", line 26, in <module>
    Raid()
  File "ex.py", line 13, in Raid
    ID = zat_id[0]
NameError: global name 'zat_id' is not defined.

Sempre devemos evitar utilizar capturas de excessão genéricas demais por este motivo.

Sugiro que dê uma estudada melhor no que o código faz e como o código faz, pois creio que ele deverá ser bem consertado para funcionar como esperado.

Você deve fazer log-in para responder a esta pergunta.

Esta não é a resposta que você está procurando? Pesquise outras perguntas com a tag .