InfoScraper
Tools and techniques to extract information from web pages and newsletters



Subscribe to "InfoScraper" in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.
 

 

 
 September 10, 2002
  8:22:12 AM  

Mail-to-Blog:

More ...

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++}}}}


Click here to visit the Radio UserLand website. © Copyright 2002 Eric Hartwell.
Last update: 03/10/2002; 10:59:49 AM.
This theme is based on the SoundWaves (blue) Manila theme.

September 2002
Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30          
Aug   Oct


"Data! data! data!" he cried impatiently. "I can't make bricks without clay."
— Sherlock Holmes to Dr. Watson in "The Adventure of the Copper Beeches" by Arthur Conan Doyle. 


"I like deadlines," cartoonist Scott Adams once said. "I especially like the whooshing sound they make as they fly by."


"There is nothing like that feeling of spending days and days banging your head against a wall trying to solve a programming problem then suddenly finding that one tiny obscure and seemingly unrelated piece of the puzzle that unlocks the solution. Oh yeah!"

- Chris Maunder, CodeProject Newsletter 28 Jan 2002


"Management at eSnipe, which is me, is also feeling the pain of the 2002 bear market. So rather than pout about it, I bought some stuff on eBay that I really didn’t need, but made me feel better."

- Tom Campbell, president of eSnipe