Last active
December 14, 2015 08:09
-
-
Save JanneSalokoski/5055333 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#Define the necessary variables here. | |
network = "chat.eu.freenode.net" | |
port = 6667 | |
nick = "jenn4|ExpBot" | |
user = nick | |
realname = "ExpBot" | |
passw = "none" | |
prefix = "!!" | |
channels = "#jenn4" | |
mode = "8" |
This file contains hidden or 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
Traceback (most recent call last): | |
File "C:\Users\Janne\Desktop\ExpBot\ExpBot.py", line 1, in <module> | |
import IRC | |
File "C:\Users\Janne\Desktop\ExpBot\IRC.py", line 3, in <module> | |
class IRC: | |
File "C:\Users\Janne\Desktop\ExpBot\IRC.py", line 7, in IRC | |
output = s.recv(4096) | |
error: [Errno 10057] A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied |
This file contains hidden or 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 IRC | |
import time | |
c = IRC() | |
import Config | |
c.connect(Config.network, Config.port) | |
time.sleep(2) | |
c.sendConfig(Config.passw, Config.nick, Config.user, Config.channels) | |
while True: | |
output = c.output | |
print(output) |
This file contains hidden or 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 socket | |
# Create the class for IRC functions. | |
class IRC: | |
"""Class including all the necessary functions for IRC.""" | |
# Let's create the socket. | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
output = s.recv(4096) | |
def connect(network, port): | |
"""Function for connecting.""" | |
s.connect((network, port)) | |
def sendNick(nick): | |
"""Function for sending nickname.""" | |
s.send("NICK " + nick + "\r\n") | |
def sendUser(user, mode, realname,): | |
"""Function for sending username.""" | |
s.send("USER " + user + " " + mode + " * " + " :" + realname + "\r\n") | |
def sendPass(passw): | |
"""Function for sending password""" | |
s.send("PASS " + passw + "\r\n") | |
def joinChannel(channels): | |
"""Function for joining channels.""" | |
s.send("JOIN " + channels + "\r\n") | |
def sendConfig(passw, nick, user, channels): | |
"""Function for sending configuration.""" | |
sendPass(passw) | |
sendNick(nick) | |
sendUser(user) | |
joinChannel(channels) | |
def quit(reason): | |
"""Function for quitting.""" | |
s.send("QUIT " + reason + "\r\n") | |
def part(channel, reason): | |
"""Function for leaving channel.""" | |
s.send("PART " + channel + " :" + "reason" + "\r\n") | |
def parseMessages(): | |
"""Function for parsing raw IRC messages""" | |
pass | |
#Implement this. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment