Archived
1
0

track primordial goo frontends

This commit is contained in:
Jeff Becker
2016-10-15 09:12:01 -04:00
parent 9e9a1efe06
commit cc089b3401
20 changed files with 900 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
# python nntpchan demo frontend #
## usage ##
add to nntpchan.json hooks section:
{
"name": "pyfront",
"exec": "/path/to/frontend.py"
}

View File

@@ -0,0 +1,9 @@
#!/usr/bin/env python3
import nntpchan
import sys
if __name__ == "__main__":
msgid = sys.argv[1]
group = sys.argv[2]
if nntpchan.addArticle(msgid, group):
nntpchan.regenerate(msgid, group)

View File

@@ -0,0 +1,42 @@
from nntpchan import store
from nntpchan import message
from nntpchan import preprocess
def addArticle(msgid, group):
"""
add article to system
:return True if we need to regenerate otherwise False:
"""
msg = None
# open message
with store.openArticle(msgid) as f:
# read article header
hdr = message.readHeader(f)
mclass = message.MultipartMessage
if hdr.isTextOnly:
# treat as text message instead of multipart
mclass = message.TextMessage
elif hdr.isSigned:
# treat as signed message
mclass = message.TripcodeMessage
# create messgae
msg = mclass(hdr, f)
if msg is not None:
# we got a message that is valid
store.storeMessage(msg)
else:
# invalid message
print("invalid message: {}".format(msgid))
return msg is not None
def regenerate(msgid, group):
"""
regenerate markup
"""
pass