Richo Healey avatar Richo Healey committed 5195e7d

Add a beep option to let you know when you're mentioned in -f

Comments (0)

Files changed (4)

 .IP default=account
 Sets account as the default
 .IP colors=<true|false>
-Turns colors on or off in the output from twat.
+Turns colors on or off in the output from twat. [defaults on]
+.IP beep=<true|false>
+Beep when a new tweet mentioning you is recieved (Handy in tmux). [defaults off]
 .IP --update-config
 Twat is a rolling release and as such, sometimes it is necessary to change the
 format of it's internal config file. Rather than making changes without user

lib/twat/actions.rb

     def process_followed(tweets)
       last_id = nil
       tweets.reverse.each do |tweet|
+        beep if config.beep? && tweet.text.mentions?(account_name)
         format(tweet)
         last_id = tweet.id
       end
         end
     end
 
+    def beep
+      print "\a"
+    end
+
   end
 end

lib/twat/config.rb

       Options.bool_true?(colors)
     end
 
+    def beep?
+      beep = config[:beep] || "false"
+      Options.bool_true?(beep)
+    end
+
     def default_account
       raise NoDefaultAccount unless config.include?(:default)
       return config[:default].to_sym

lib/twat/options.rb

       config.save!
     end
 
+    def beep=(value)
+      val = value.to_sym
+      raise InvalidBool unless Options.bool_valid?(val)
+      config[:beep] = val
+      config.save!
+    end
+
   end
 end
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.