<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>db/migrate/20090305050212_update_twitter_message.rb</filename>
    </added>
    <added>
      <filename>script/twitter</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -145,6 +145,7 @@ class Person &lt; ActiveRecord::Base
   validates_confirmation_of :password, :if =&gt; Proc.new { Person.logged_in }
   validates_uniqueness_of :alternate_email, :allow_nil =&gt; true, :if =&gt; Proc.new { Person.logged_in }
   validates_uniqueness_of :feed_code, :allow_nil =&gt; true
+  validates_uniqueness_of :twitter_account, :allow_nil =&gt; true, :allow_blank =&gt; true
   validates_format_of :website, :allow_nil =&gt; true, :allow_blank =&gt; true, :with =&gt; /^https?\:\/\/.+/, :message =&gt; &quot;has an incorrect format (are you missing 'http://' at the beginning?)&quot;
   validates_format_of :business_website, :allow_nil =&gt; true, :allow_blank =&gt; true, :with =&gt; /^https?\:\/\/.+/, :message =&gt; &quot;has an incorrect format (are you missing 'http://' at the beginning?)&quot;
   validates_format_of :business_email, :allow_nil =&gt; true, :allow_blank =&gt; true, :with =&gt; VALID_EMAIL_ADDRESS, :message =&gt; 'has an incorrect format (something@example.com)'</diff>
      <filename>app/models/person.rb</filename>
    </modified>
    <modified>
      <diff>@@ -21,14 +21,12 @@ class TwitterMessage &lt; ActiveRecord::Base
   belongs_to :person
   
   validates_presence_of :twitter_screen_name
+  validates_uniqueness_of :twitter_message_id
   
   def validate
     if TwitterMessage.count('*', :conditions =&gt; ['created_at &gt;= ?', 1.minutes.ago]) &gt; MAX_MESSAGES_PER_MINUTE
       errors.add_to_base('Too many messages per minute.')
     end
-    unless self.person
-      errors.add(:twitter_screen_name, 'Twitter screen name unknown.')
-    end
   end
     
   def twitter_screen_name=(screen_name)
@@ -38,41 +36,45 @@ class TwitterMessage &lt; ActiveRecord::Base
   
   def build_reply
     raise 'No message' unless self.message.to_s.strip.any?
-    if self.message =~ /^\s*(lookup|phone|mobile|home|work|address)\s*(.+)/
-      lookup_name = sql_lcase(sql_concat('first_name', &quot;' '&quot;, 'last_name'))
-      if found = Person.find(:first, :conditions =&gt; [&quot;#{lookup_name} like ?&quot;, $2.downcase + '%']) \
-        and self.person.can_see?(found)
-        case $1
-        when 'lookup', 'phone', 'mobile'
-          if found.share_mobile_phone_with(self.person) and found.mobile_phone.to_i &gt; 0
-            self.reply = &quot;#{found.mobile_phone} - #{found.name}&quot;
-          else
-            self.reply = &quot;Mobile number not available for #{found.name}&quot;
-          end
-        when 'home'
-          if found.home_phone.to_i &gt; 0
-            self.reply = &quot;#{found.home_phone} - #{found.name}&quot;
-          else
-            self.reply = &quot;Home number not available for #{found.name}&quot;
-          end
-        when 'work'
-          if found.share_work_phone_with(self.person) and found.work_phone.to_i &gt; 0
-            self.reply = &quot;#{found.work_phone} - #{found.name}&quot;
-          else
-            self.reply = &quot;Work number not available for #{found.name}&quot;
-          end
-        when 'address'
-          if found.share_address_with(self.person) and found.address1.to_s.any? and found.city.to_s.any? and found.state.to_s.any?
-            self.reply = &quot;#{found.family.mapable_address} - #{found.name}&quot;
-          else
-            self.reply = &quot;Address not available for #{found.name}&quot;
+    if self.person
+      if self.message =~ /^\s*(lookup|phone|mobile|home|work|address)\s*(.+)/
+        lookup_name = sql_lcase(sql_concat('first_name', &quot;' '&quot;, 'last_name'))
+        if found = Person.find(:first, :conditions =&gt; [&quot;#{lookup_name} like ?&quot;, $2.downcase + '%']) \
+          and self.person.can_see?(found)
+          case $1
+          when 'lookup', 'phone', 'mobile'
+            if found.share_mobile_phone_with(self.person) and found.mobile_phone.to_i &gt; 0
+              self.reply = &quot;#{found.mobile_phone} - #{found.name}&quot;
+            else
+              self.reply = &quot;Mobile number not available for #{found.name}&quot;
+            end
+          when 'home'
+            if found.home_phone.to_i &gt; 0
+              self.reply = &quot;#{found.home_phone} - #{found.name}&quot;
+            else
+              self.reply = &quot;Home number not available for #{found.name}&quot;
+            end
+          when 'work'
+            if found.share_work_phone_with(self.person) and found.work_phone.to_i &gt; 0
+              self.reply = &quot;#{found.work_phone} - #{found.name}&quot;
+            else
+              self.reply = &quot;Work number not available for #{found.name}&quot;
+            end
+          when 'address'
+            if found.share_address_with(self.person) and found.address1.to_s.any? and found.city.to_s.any? and found.state.to_s.any?
+              self.reply = &quot;#{found.family.mapable_address} - #{found.name}&quot;
+            else
+              self.reply = &quot;Address not available for #{found.name}&quot;
+            end
           end
+        else
+          self.reply = 'No one with that name could be found.'
         end
       else
-        self.reply = 'No one with that name could be found.'
+        self.reply = 'Send &quot;mobile John Doe&quot; or &quot;address John Doe&quot; or similar.'
       end
     else
-      self.reply = 'Send &quot;mobile John Doe&quot; or &quot;address John Doe&quot; or similar.'
+      self.reply = &quot;I don't recognize your Twitter account. Update your account at #{Setting.get(:url, :site)}&quot;
     end
   end
 end</diff>
      <filename>app/models/twitter_message.rb</filename>
    </modified>
    <modified>
      <diff>@@ -48,10 +48,6 @@ Name:
     value: a pretend church for testing OneBody
     description: Slogan displayed at top of every page.
 Features: 
-  Twitter Account: 
-    format: string
-    value: 
-    description: Account name of church Twitter account.
   Multisite: 
     format: boolean
     value: false
@@ -74,14 +70,6 @@ Features:
     format: string
     value: 
     description: Message to display across top of all pages on site (HTML), like an alert
-  Twitter Password: 
-    format: password
-    value: 
-    description: Password of church Twitter account.
-  Jabber Password: 
-    format: password
-    value: 
-    description: Password of Jabber account.
   Blog: 
     format: boolean
     value: true
@@ -126,10 +114,6 @@ Features:
     format: boolean
     value: false
     description: Enable Recipe sharing.
-  Jabber Account: 
-    format: string
-    value: 
-    description: Account (email address) for connecting to Twitter through Jabber/XMPP.
   Updates Must Be Approved:
     format: boolean
     value: true</diff>
      <filename>config/settings.yml</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>app/models/twitter_bot.rb</filename>
    </removed>
    <removed>
      <filename>script/twitterbot</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>93d354f298d7b3da557072caff8825e908eadadd</id>
    </parent>
  </parents>
  <author>
    <name>Tim Morgan</name>
    <email>tim@timmorgan.org</email>
  </author>
  <url>http://github.com/seven1m/onebody/commit/d3408219294ed74409c9c4f10d3e1f6720b3cd9d</url>
  <id>d3408219294ed74409c9c4f10d3e1f6720b3cd9d</id>
  <committed-date>2009-03-04T22:11:48-08:00</committed-date>
  <authored-date>2009-03-04T22:11:48-08:00</authored-date>
  <message>Redesign Twitter script to be run from cron and no longer use Jabber.</message>
  <tree>894f58aae1ba31b2203f72d48b05b01bf17b12ea</tree>
  <committer>
    <name>Tim Morgan</name>
    <email>tim@timmorgan.org</email>
  </committer>
</commit>
