pikachu -IrC chat bot

Currently I’m in my 3rd year of my BE. I always wanted to make a chat bot and in this year I got an opportunity to build one.

I have been already known to python but new things are to study about how to connect and ping server and about socket module. As soon as I finished, I started coding.

This are the two modules I have used in my bot.

import socket          
import re                  #For Regular Expression

I have added a main function, and inside that we have done our Socket Programming.

#defines the socket
def main():
 global irc
 botnick = "pikachu"
 channel = "#dgplug"
 port = 6667
 server = "irc.freenode.net"
 irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 #connects to the server
 irc.connect((server, port))
 #user authentication
 irc.send("USER " + botnick + " " + botnick + " " + botnick 
 + " :Hello! I am a test bot!\r\n")
 irc.send("NICK " + botnick + "\n")
 # join the channel
 irc.send("JOIN" + channel + "\n")

Check out the source code to know more about the bot. Feel free to ask anything or to file an issue.

Happy Coding.pikachu

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s