system.verbs.apps.blogger.mailToBlog.Checkmail.script:
«Changes
«8/14/01; 9:07:56 AM by DW
«Runs in a separate thread, watching a mail account you specify. When a message appears, if its subject is the secret subject, post the contents of the message to your Blogger blog.
«This script is derived from Radio's mail-to-weblog feature, myUserLandSuite.blog.checkMail.
«http://frontier.userland.com/blogger#mailToBlog
blogger.init ();
if user.blogger.mailToBlog.enabled {
msg ("blogger.mailToBlog.checkMail.script");
try {
local (msgtable, adrmsg);
with user.blogger.mailToBlog {
tcp.getmail (server, account, password, @msgtable, deleteMessages:true, flMessages: false);
user.blogger.mailToBlog.stats.ctMailToBlogChecks++};
for adrmsg in @msgtable {
bundle { //process the text first, allow callbacks to change it
local (s = adrmsg^.text);
s = string.quotedPrintableDecode (s);
s = string.replaceAll (s, "\n", "");
s = string.trimWhitespace (s);
adrmsg^.blogPostText = s};
bundle { //run msg through callbacks
try {
if defined (user.blogger.callbacks.mailToBlog) {
local (adrcallback);
for adrcallback in @user.blogger.callbacks.mailToBlog {
while typeOf (adrcallback^) == addressType {
adrcallback = adrcallback^};
try {adrcallback^ (adrmsg)}}}}};
if adrmsg^.subject == string (user.blogger.mailToBlog.secretSubject) {
blogger.newPost (adrmsg^.blogPostText);
user.blogger.mailToBlog.stats.ctMailToBlogPosts++}}};
msg ("")};
bundle { //schedule wakeup for next whole minute
local (day, month, year, hour, minute, second);
date.get (clock.now (), @day, @month, @year, @hour, @minute, @second);
thread.sleepFor (60 - second)} //wake up once a minute, on the minute
system.verbs.builtins.radio.weblog.checkMail:
«Changes
«11/23/01; 3:09:57 PM by JES
«Save the adrpost returned by radio.weblog.post, and pass it to radio.weblog.updatePagesForPost, to update all of the pages that the post appears in.
«10/19/01; 4:16:56 PM by DW
«Testing, debugging, fixing for 7.1.
«string.trimwhitespace the posts. No need for trailing carriage returns on the posts.
«Add pref to control how often mail is checked. Initialized in radio.weblog.init.
«10/19/01; 4:16:42 PM by DW
«Check out for Radio 7.1.
«3/25/01; 9:53:05 AM by DW
«Add callback support. Loop over all the scripts in myUserLandData.callbacks.blogCheckMail passing the address of each message. Ignore any returned value or script error.
«Comment out assignment to scratchpad.emailText.
«3/1/01; 5:53:14 PM by JES
«Convert quoted printable text to ASCII. Untaint text before posting. Remove linefeeds.
«2/24/01; 7:30:49 AM by DW
«This is the My.UserLand.On.The.Blackberry feature that Scott Loftesness asked for.
«If enabled, we check a mail address and see if there are any posts available for us.
«The subject must match the "secret subject", the body contains the post.
local (adrblog = radio.weblog.init ());
if adrblog^.prefs.mailPosting.enabled {
if not defined (system.temp.radio.misc.lastMailPostingCheck) {
system.temp.radio.misc.lastMailPostingCheck = date (0)};
if clock.now () > (system.temp.radio.misc.lastMailPostingCheck + adrblog^.prefs.mailPosting.ctSecondsBetweenChecks) {
system.temp.radio.misc.lastMailPostingCheck = clock.now ();
local (msgtable, adrmsg);
with adrblog^.prefs.mailPosting {
tcp.getmail (server, account, password, @msgtable, deleteMessages:true, flMessages: false);
adrblog^.stats.ctMailToBlogChecks++};
for adrmsg in @msgtable {
bundle { //run msg through callbacks
try {
if defined (adrblog^.callbacks.weblogCheckMail) {
local (adrcallback);
for adrcallback in @adrblog^.callbacks.weblogCheckMail {
while typeOf (adrcallback^) == addressType {
adrcallback = adrcallback^};
try {adrcallback^ (adrmsg)}}}}};
if adrmsg^.subject == string (adrblog^.prefs.mailPosting.secretSubject) {
local (s = adrmsg^.text);
s = string.trimWhitespace (s);
s = string.quotedPrintableDecode (s);
s = string.replaceAll (s, "\r\n", "\r");
s = radio.string.untaint (s);
local (adrpost = radio.weblog.post (s, adrblog));
radio.weblog.updatePagesForPost (adrpost);
adrblog^.stats.ctMailToBlogPosts++}}}}