Fedora-Arm Mailing List Monitor Bot

So I couldn’t find a reasonable way to manage the amount of mailing list email being sent to my personal and school address so I had to do this. I know you’re probably tired of seeing my various IRC bot scripts but I couldn’t take the amount of email that the mailing list generates. This is a bot which monitors the fedora-arm mailing list and posts any new changes to a given channel. Right now its being tested in the #seneca-cdot-arm channel on the freenode network.

Edit: Last updated on June 30, 2011

mbot.py

import os
import re
import sys
import time

import lbot


def fechfile(filename, urlnstri=""):
	resllist = []
	
	try:
		fileobjc = file("/tmp/%s" % (filename))
		readdata = fileobjc.read()
		fileobjc.close()
	
	except:
		return resllist
	
	readdata = readdata.strip().lower()
	readdata = readdata.replace("\t", "").replace("\r", "").replace("\n", "")
	readdata = readdata.replace("<li>", "\n<li>")
	readdata = readdata.replace("</i>", "</i>\n")
	
	readlist = readdata.split("\n")
	
	for readitem in readlist:
		readitem = readitem.strip()
		
		regxobjc = re.match('^<li><a href="([^"]+)">(.+)</a><a name="[^"]+">[^<]+</a><i>([^<]+)</i>$', readitem)
		
		if (regxobjc):
			reslstri = ("[%s] [%s] [ %s ]" % (regxobjc.group(3), regxobjc.group(2), urlnstri + regxobjc.group(1)))
			resllist.append(reslstri)
	
	return resllist

def ircbmain():
	if (len(sys.argv) < 4):
		print("Usage: %s <nick> - <chan 0> ... <chan N>" % (sys.argv[0]))
		sys.exit(0)
	
	nickname = ""
	chanlist = []
	
	x = 1
	l = len(sys.argv)
	f = 0
	
	while (x < l):
		if (sys.argv[x] == "-"):
			f += 1
		
		elif (f == 0):
			nickname = sys.argv[x]
		
		elif (f == 1):
			chanlist.append(sys.argv[x])
		
		x += 1
	
	websstri = ("http://lists.fedoraproject.org/pipermail/arm/%s-%s/" % (time.strftime("%Y"), time.strftime("%B")))
	
	p = os.fork()
	
	if (p == 0):
		websstri = ("%sdate.html" % (websstri))
		
		lbot.readurls(urlnlist=[websstri], filename=nickname)
		sys.exit(0)
	
	pastdata = []
	presdata = []
	
	lbot.ircbinit(nickname, chanlist)
	
	while (1):
		tempdata = fechfile(nickname, urlnstri=websstri)
		
		if (tempdata):
			presdata = tempdata
			
			if (not pastdata):
				pastdata = presdata
		
		ircdstri = lbot.ircbmain(pastdata, presdata)
		
		if (type(ircdstri) == type(-1)):
			break
		
		if (presdata):
			pastdata = presdata

ircbmain()

7 thoughts on “Fedora-Arm Mailing List Monitor Bot

  1. Alright, smart piece of content. Pleased I noticed it by means of Google, to bad that it was on-page 5 of search results. It appears as if your utilizing WordPress in your internet site, you really should take a look at this plugin for WordPress at myseopressor.com it’s tremendously assisted me with my online site rankings in Google Search. I’d hate to see your useful article not be observed by others. All the best! with your web site.

  2. Hey, I don.t think telling you this on your post Fedora-Arm Mailing List Monitor Bot | Jon's FOSS Blog is the right place but I couldn.t find a contact form in your somewhat cluttered theme (sorry). My readers used to tell me the same so I switched over to a new theme, you should check it out on my website. I.ve only gotten compliments ever since. Regards, Katina Ku

  3. Hi, i think that i saw you visited my web site so i came to “return the favor”.I’m trying to find things to enhance my website!I suppose its ok to use a few of your ideas!!

Leave a reply to Johnette Misty Cancel reply