Compare commits
No commits in common. "f92d59dd913e678b21d42265c64c25a8b5542267" and "f449305ccd3dd97ddf6d884a9e31378077d8eb38" have entirely different histories.
f92d59dd91
...
f449305ccd
69
bert.py
69
bert.py
@ -38,8 +38,10 @@ y = "\x038"
|
|||||||
r = "\x034"
|
r = "\x034"
|
||||||
g = "\x033"
|
g = "\x033"
|
||||||
|
|
||||||
# global variable for the socket, see connect()
|
context = ssl.create_default_context()
|
||||||
irc = None
|
with socket.socket(socket.AF_INET6, socket.SOCK_STREAM) as sock:
|
||||||
|
irc = context.wrap_socket(sock, server_hostname=host)
|
||||||
|
|
||||||
|
|
||||||
# Currency API
|
# Currency API
|
||||||
def get_exchange():
|
def get_exchange():
|
||||||
@ -69,11 +71,11 @@ def safeexit():
|
|||||||
|
|
||||||
|
|
||||||
def connect(host, port):
|
def connect(host, port):
|
||||||
global irc
|
|
||||||
print("Connecting to "+host+":"+str(port))
|
print("Connecting to "+host+":"+str(port))
|
||||||
context = ssl.create_default_context()
|
try:
|
||||||
with socket.create_connection((host, port)) as sock:
|
irc.connect((host, port))
|
||||||
irc = context.wrap_socket(sock, server_hostname=host)
|
except Exception as err:
|
||||||
|
print("Connection failed! "+str(err))
|
||||||
|
|
||||||
|
|
||||||
def sendRaw(data):
|
def sendRaw(data):
|
||||||
@ -82,17 +84,26 @@ def sendRaw(data):
|
|||||||
|
|
||||||
def register(nick, host):
|
def register(nick, host):
|
||||||
print("Registering User...")
|
print("Registering User...")
|
||||||
sendRaw("USER "+nick+" "+host+" "+nick+" "+nick+"\n")
|
try:
|
||||||
|
sendRaw("USER "+nick+" "+host+" "+nick+" "+nick+"\n")
|
||||||
|
except Exception as err:
|
||||||
|
print("Failed! "+str(err))
|
||||||
|
|
||||||
|
|
||||||
def name(nick):
|
def name(nick):
|
||||||
print("Setting Nickname to "+nick)
|
print("Setting Nickname to "+nick)
|
||||||
sendRaw("NICK "+nick+"\n")
|
try:
|
||||||
|
sendRaw("NICK "+nick+"\n")
|
||||||
|
except Exception as err:
|
||||||
|
print("Failed! "+str(err))
|
||||||
|
|
||||||
|
|
||||||
def auth(nick, password):
|
def auth(nick, password):
|
||||||
print("Authenticating...")
|
print("Authenticating...")
|
||||||
sendRaw("PRIVMSG NickServ :IDENTIFY "+nick+" "+password+"\n")
|
try:
|
||||||
|
sendRaw("PRIVMSG NickServ :IDENTIFY "+nick+" "+password+"\n")
|
||||||
|
except Exception as err:
|
||||||
|
print(err)
|
||||||
|
|
||||||
|
|
||||||
def join(chan):
|
def join(chan):
|
||||||
@ -105,7 +116,10 @@ def join(chan):
|
|||||||
|
|
||||||
def mode(nick):
|
def mode(nick):
|
||||||
print("Setting modes +B-x")
|
print("Setting modes +B-x")
|
||||||
sendRaw("MODE "+nick+" +B-x\n")
|
try:
|
||||||
|
sendRaw("MODE "+nick+" +B-x\n")
|
||||||
|
except Exception as err:
|
||||||
|
print("Failed! "+str(err))
|
||||||
|
|
||||||
|
|
||||||
def part(chan):
|
def part(chan):
|
||||||
@ -240,19 +254,22 @@ def ping(msg):
|
|||||||
|
|
||||||
|
|
||||||
def start(host, port, nick, password, chans):
|
def start(host, port, nick, password, chans):
|
||||||
connect(host, port)
|
try:
|
||||||
sleep(2)
|
connect(host, port)
|
||||||
register(nick, host)
|
sleep(2)
|
||||||
sleep(2)
|
register(nick, host)
|
||||||
name(nick)
|
sleep(2)
|
||||||
sleep(6)
|
name(nick)
|
||||||
auth(nick, password)
|
sleep(6)
|
||||||
sleep(2)
|
auth(nick, password)
|
||||||
mode(nick)
|
sleep(2)
|
||||||
sleep(2)
|
mode(nick)
|
||||||
for chan in chans:
|
sleep(2)
|
||||||
join(chan)
|
for chan in chans:
|
||||||
sleep(2)
|
join(chan)
|
||||||
|
sleep(2)
|
||||||
|
except Exception as err:
|
||||||
|
print("FAIL: "+str(err))
|
||||||
|
|
||||||
|
|
||||||
def command_loop():
|
def command_loop():
|
||||||
@ -492,11 +509,7 @@ class fefe_thread(threading.Thread):
|
|||||||
fefe_check()
|
fefe_check()
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
try:
|
start(host, port, nick, password, set(join_chans + fefe_chans))
|
||||||
start(host, port, nick, password, set(join_chans + fefe_chans))
|
|
||||||
except Exception as err:
|
|
||||||
print("FAIL: "+str(err))
|
|
||||||
sys.exit(1)
|
|
||||||
thread_command = command_thread(1)
|
thread_command = command_thread(1)
|
||||||
#thread_fefe = fefe_thread(2)
|
#thread_fefe = fefe_thread(2)
|
||||||
thread_command.start()
|
thread_command.start()
|
||||||
|
Loading…
Reference in New Issue
Block a user