Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit cc644db
Showing
6 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Gemfile.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source "http://rubygems.org" | ||
|
||
# Specify your gem's dependencies in siriproxy-thermostat.gemspec | ||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require "bundler/gem_tasks" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#Example configuration options that can be placed in your main SiriProxy config.yml | ||
|
||
########################## | ||
#NOTICE: Modifying these options in this file has no effect. You must put them in SiriProxy's config.yml! | ||
########################## | ||
|
||
- name: 'Twitter' | ||
git: 'git://github.com/netpro2k/SiriProxy-Twitter.git' | ||
consumer_key: "YOUR_KEY" | ||
consumer_secret: "YOUR_SECRET" | ||
oauth_token: "YOUR_TOKEN" | ||
oauth_token_secret: "YOUR_TOKEN_SECRET" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
require 'twitter' | ||
|
||
class SiriProxy::Plugin::Twitter < SiriProxy::Plugin | ||
def initialize(config = {}) | ||
@config = config | ||
|
||
::Twitter.configure do |config| | ||
config.consumer_key = @config['consumer_key'] | ||
config.consumer_secret = @config['consumer_secret'] | ||
config.oauth_token = @config['oauth_token'] | ||
config.oauth_token_secret = @config['oauth_token_secret'] | ||
end | ||
|
||
@twitterClient = ::Twitter::Client.new | ||
end | ||
|
||
listen_for /tweet (.+)/i do |tweetText| | ||
say "Here is your tweet:" | ||
|
||
# send a "Preview" of the Tweet | ||
object = SiriAddViews.new | ||
object.make_root(last_ref_id) | ||
answer = SiriAnswer.new("Tweet", [ | ||
SiriAnswerLine.new('logo','http://cl.ly/1l040J1A392n0M1n1g35/content'), # this just makes things looks nice, but is obviously specific to my username | ||
SiriAnswerLine.new(tweetText) | ||
]) | ||
object.views << SiriAnswerSnippet.new([answer]) | ||
send_object object | ||
|
||
if confirm "Ready to send it?" | ||
say "Posting to twitter..." | ||
Thread.new { | ||
begin | ||
@twitterClient.update(tweetText) | ||
say "Ok it has been posted." | ||
rescue Exception | ||
pp $! | ||
say "Sorry, I encountered an error: #{$!}" | ||
ensure | ||
request_completed | ||
end | ||
} | ||
else | ||
say "Ok I won't send it." | ||
request_completed | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# -*- encoding: utf-8 -*- | ||
$:.push File.expand_path("../lib", __FILE__) | ||
|
||
Gem::Specification.new do |s| | ||
s.name = "siriproxy-twitter" | ||
s.version = "0.0.1" | ||
s.authors = ["netpro2k"] | ||
s.email = ["netpro2k@gmail.com"] | ||
s.homepage = "http://netpro2k.com" | ||
s.summary = %q{Teach Siri how to tweet} | ||
s.description = %q{This is a very simple plugin for posting to twitter from siri} | ||
|
||
s.rubyforge_project = "siriproxy-twitter" | ||
|
||
s.files = `git ls-files`.split("\n") | ||
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") | ||
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } | ||
s.require_paths = ["lib"] | ||
|
||
s.add_runtime_dependency "twitter" | ||
|
||
s.add_development_dependency "rspec" | ||
s.add_development_dependency "guard-rspec" | ||
s.add_development_dependency "rake" | ||
|
||
end |