add files
parent
69fda1e884
commit
6b43815d38
|
@ -0,0 +1 @@
|
|||
config.lua
|
|
@ -0,0 +1,7 @@
|
|||
myaccount = IMAP {
|
||||
server = 'hostname',
|
||||
username = 'username',
|
||||
password = 'password',
|
||||
port = 993,
|
||||
ssl = 'true'
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
options.timeout = 120
|
||||
options.namespace = false
|
||||
options.charset = 'UTF-8'
|
||||
|
||||
-- define myaccount object
|
||||
require "config"
|
||||
|
||||
while true
|
||||
do
|
||||
|
||||
count = 0
|
||||
|
||||
results = myaccount.INBOX:is_unseen()
|
||||
for _, message in ipairs(results) do
|
||||
mailbox, uid = table.unpack(message)
|
||||
message = mailbox[uid]:fetch_message()
|
||||
|
||||
file = io.open ("message"..count..".txt", "w")
|
||||
io.output(file)
|
||||
|
||||
io.write(message)
|
||||
io.close(file)
|
||||
count=count+1
|
||||
end
|
||||
|
||||
results:mark_seen()
|
||||
|
||||
if count>0 then
|
||||
os.exit()
|
||||
end
|
||||
|
||||
print("checking")
|
||||
|
||||
myaccount.INBOX:enter_idle()
|
||||
|
||||
end
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
#! /bin/sh
|
||||
|
||||
while true
|
||||
do
|
||||
echo "`date` checking"
|
||||
|
||||
imapfilter -c fetchmsg.lua
|
||||
|
||||
for m in `find . -name "message*.txt"`
|
||||
do
|
||||
|
||||
ID=`(date;echo $$;echo $m)|sha256sum|sed 's/ *-//'`
|
||||
|
||||
mkdir $ID
|
||||
cd $ID
|
||||
munpack ../$m
|
||||
|
||||
ls -l
|
||||
|
||||
TXT=`ls *.desc`
|
||||
|
||||
if [ "$TXT" = "" ]
|
||||
then
|
||||
echo "message $m didn't contain any image";
|
||||
(
|
||||
formail -r <../$m
|
||||
echo ""
|
||||
echo "the message could not be decoded, this is usually an issue with the MIME format"
|
||||
echo "like a mail with text/plain and text/html format"
|
||||
) | /usr/sbin/sendmail -t
|
||||
else
|
||||
mkdir ~/gemini-site/capsule/posts/$ID
|
||||
|
||||
cat $TXT >~/gemini-site/capsule/posts/$ID/post.gmi
|
||||
echo "" >>~/gemini-site/capsule/posts/$ID/post.gmi
|
||||
|
||||
rm -f $TXT
|
||||
|
||||
for img in `find . -name "*.jpg" -o -name "*.gif" -o -name "*.png" -o -name "*.webp" -o -name "*.JPG" -o -name "*.GIF" -o -name "*.PNG" -o -name "*.WEBP"`
|
||||
do
|
||||
echo "=> $img" >> ~/gemini-site/capsule/posts/$ID/post.gmi
|
||||
chmod 644 $img
|
||||
mv $img ~/gemini-site/capsule/posts/$ID
|
||||
done
|
||||
|
||||
(
|
||||
formail -r <../$m
|
||||
echo ""
|
||||
echo "your post has been created with the url"
|
||||
echo ""
|
||||
echo "gemini://gemini.lehmann.cx/posts/$ID/post.gmi"
|
||||
) | /usr/sbin/sendmail -t
|
||||
fi
|
||||
|
||||
cd ..
|
||||
|
||||
rmdir $ID
|
||||
|
||||
rm $m
|
||||
done
|
||||
|
||||
echo "`date` finished processing"
|
||||
done
|
||||
|
Loading…
Reference in New Issue