Simple IRC Announce System in Python

I am developing a system to give alerts in IRC channels in python.
Here is a very simple IRC  bot which can give some announcement/alert in any channel or to any person as private message.

—————-
#filename: irc-announce.py
impirt irclib
import time

# Connection information
network = ‘IRC.SERVER.NAME’
port = 6667
channel = ‘CHANNELNAME’
nick = ‘NICKNAME’
name = ‘REAL NAME’

# Connect
irc = irclib.IRC()
server = irc.server()
server.connect ( network, port, nick, ircname = name )

# Message both the channel and you
server.privmsg ( channel, ‘Hello Everybody. Nice to see you’ )
server.privmsg ( ‘ANY USER NAME’, ‘Private Message to User’ )

#irc.process_forever()
#All the scripts in internet use process_forever(). But it keeps the script to be running forever.
#I want this script to quit after sending the message. So using a sleep for the giving sometime for the bot #to finish all its network operations

time.sleep(5)
——————-

Using this, I automated a reporting system to ping in our internal IRC channels about the recent updates in our internal tracker.

One thought on “Simple IRC Announce System in Python

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