Created
September 30, 2015 19:37
-
-
Save jwhonce/aaf51a27ac0e9022ae60 to your computer and use it in GitHub Desktop.
Send NOTICE message to IRC server
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
#!/usr/bin/python | |
import socket | |
import sys | |
from datetime import datetime | |
try: | |
import json | |
except: | |
import simplejson as json | |
print len(sys.argv) | |
if len(sys.argv) != 2: | |
sys.exit(0) | |
with open(sys.argv[1]) as payload: | |
announcements = json.load(payload) | |
notices = [] | |
for announce in announcements: | |
notices.append('NOTICE {0} :{1} -- {2}\r\n'.format(announce['channel'], announce['nicks'], announce['message'])) | |
network = 'porky.str.redhat.com' | |
port = 6667 | |
irc = socket.socket ( socket.AF_INET, socket.SOCK_STREAM ) | |
irc.connect ( ( network, port ) ) | |
print irc.recv ( 4096 ) | |
irc.send ( 'NICK nagbot\r\n' ) | |
irc.send ( 'USER nagbot nagbot nagbot :Python IRC\r\n' ) | |
irc.send ( 'JOIN #jhonce\r\n' ) | |
for notice in notices: | |
print notice | |
irc.send(notice) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment