Created
August 7, 2016 19:05
-
-
Save oholiab/52e913caa0a6ea12695518e764a16bd0 to your computer and use it in GitHub Desktop.
half assed attempt at IRC on the EMF TiLDA 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import wifi | |
import socket | |
import ure | |
import ubinascii | |
import pyb | |
import uhashlib | |
uid = str(ubinascii.hexlify(uhashlib.sha256(pyb.unique_id()).digest()), 'ascii') | |
HOST="irc.freenode.net" | |
PORT=6667 | |
NICK="emfbadge_" + uid | |
print("I am " + NICK) | |
IDENT=NICK | |
REALNAME=NICK | |
CHANNEL="#emfbadgetest" | |
mention=ure.compile('oholiab') | |
readbuffer="" | |
if wifi.is_connected(): | |
pass | |
else: | |
wifi.connect() | |
s=socket.socket( ) | |
#s.connect((HOST, PORT)) | |
# Doesn't like hostnames | |
s.connect(('193.10.255.100', PORT)) | |
s.send("NICK %s\r\n" % NICK) | |
s.send("USER %s %s bla :%s\r\n" % (IDENT, HOST, REALNAME)) | |
s.send("JOIN %s\r\n" % CHANNEL) | |
while 1: | |
readbuffer=readbuffer+str(s.recv(1024)) | |
temp=str.split(readbuffer, "\\r\\n") | |
readbuffer=temp.pop() | |
for line in temp: | |
splitline=str.split(line) | |
print("debug: " + line) | |
mentioner = str.split(line, "!")[0] | |
print("mentioned by " + str(mentioner)) | |
if(mention.match(str(str.split(line, CHANNEL + " ")))): | |
print("MENTION! " + line) | |
if(str(splitline[0])=="PING"): | |
print("Got PING sending PONG") | |
s.send("PONG %s\r\n" % splitline[1]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
you can see where I was heading... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment