🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #31170

Re: newgroup flood from group-admin@isc.com?

#31170
From: Timothy J. Miller
Date: Thu, 03 Sep 1998 00:00
101 lines
3126 bytes
tmill06@ibm.net (Timothy J. Miller) writes:

> 	If anyone's interested I can post it, it's only ~80 lines.  8)

	Note that this works, but makes no attempt at efficiency.  I
tries to handle !-prefixed removals, and will also remove descriptions
for groups no longer in your active file.

	I'm sure it could be rewritten better eight ways from Sunday, but 
since I cat all my checkgroups together into one file, I don't care.  8)

==========================

#!/usr/local/bin/python

import sys,string

active_filename = "/usr/local/news/db/active"
newsgroups_filename = "/usr/local/news/db/newsgroups"

try:
    checkgroups_file = open(sys.argv[1])
except:
    print "Usage: maintain-desc groupnamefile"
    sys.exit(-1)

newsgroups = {}
try:
    newsgroups_file = open(newsgroups_filename)
except:
    print "Cannot find newsgroups file."
    sys.exit(-1)

active = {}
try:
	active_file = open(active_filename)
except:
	print "Cannot open active file."
	sys.exit(-1)


def getnamedesc(line):
	namelist = string.split(line)
	if not namelist:
		return ['','']
	return namelist[0],string.join(namelist[1:])

for i in newsgroups_file.readlines():
	name,desc = getnamedesc(i)
	if not name:
		continue
	newsgroups[name] = desc

newsgroups_file.close()

for i in active_file.readlines():
	name,desc = getnamedesc(i)
	if not name:
		continue
	active[name] = 1

active_file.close()

for i in newsgroups.keys():
	if not active.has_key(i):
		del newsgroups[i]

for i in checkgroups_file.readlines():
	if i[0] == '!':
		name = string.strip(i[1:])
		if newsgroups.has_key(name):
			del newsgroups[name]
		continue
	name,desc = getnamedesc(i)
	if active.has_key(name):
		newsgroups[name] = desc

checkgroups_file.close()

names = newsgroups.keys()
names.sort()

try:
	newsgroups_file = open(newsgroups_filename,'w')
except:
	print "Cannot write to newsgroups file."
	sys.exit(-1)

for i in names:
    newsgroups_file.write(i + '\t' + newsgroups[i] + '\n')

newsgroups_file.close()

==========================

-- 
Cerebus <tmill06@ibm.net>
"Although UNIX is more reliable, NT may become more reliable with time"
      -- Ron Redman, deputy technical director of the Fleet Introduction

Technical Details
Message-ID: <87emtslx9e.fsf@ibm.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
References: <6s94na$jh3$1@valkyrie.OnRamp.Net> <87ogt1z2t6.fsf@ibm.net> <35ED659F.FDB7A6D2@email.bankofny.com> <87hfyqzemq.fsf@ibm.net> <35f55625.6698317@news.nic.utwente.nl> <87lno1xr0i.fsf@ibm.net>

Show Full Headers
Complete Article Headers
Message-ID: <87emtslx9e.fsf@ibm.net>
Subject: Re: newgroup flood from group-admin@isc.com?
Date: Thu, 03 Sep 1998 00:00:00 +0000
From: tmill06@ibm.net (Timothy J. Miller)
References: <6s94na$jh3$1@valkyrie.OnRamp.Net> <87ogt1z2t6.fsf@ibm.net> <35ED659F.FDB7A6D2@email.bankofny.com> <87hfyqzemq.fsf@ibm.net> <35f55625.6698317@news.nic.utwente.nl> <87lno1xr0i.fsf@ibm.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
X-Deja-AN: 387619571
Sender: tmiller@acropolis
X-Trace: 3 Sep 1998 21:08:47 GMT, 32.100.166.50
Organization: IBM.NET
X-Notice: should be reported to postmaster@ibm.net
Newsgroups: news.software.nntp
X-Complaints-To: postmaster@ibm.net