Sha256: 95e467b7e96f0a29d0f4e23988700f6e1ad941c4a01aee08e52ac119b00e559d
Contents?: true
Size: 1.66 KB
Versions: 1
Compression:
Stored size: 1.66 KB
Contents
# doc on https://github.com/sferik/twitter # get tokens on https://apps.twitter.com require 'twitter' require 'awesome_print' module Cinch module Plugins class Tweet include Cinch::Plugin match /t ?([^ ]*)?( ?.*)/ set :plugin_name, 'tweet' set :help, <<EOT Tweet makes the bot can query twittter API .t search <term> : searches the public timelines EOT def client @_client ||= Twitter::REST::Client.new do |c| c.consumer_key = @bot.config.options['cogconf']['tweet']['consumer_key'] c.consumer_secret = @bot.config.options['cogconf']['tweet']['consumer_secret'] c.access_token = @bot.config.options['cogconf']['tweet']['access_token'] c.access_token_secret = @bot.config.options['cogconf']['tweet']['access_token_secret'] end end def new(bot) @bot = bot end def exec(command, args) back = '' #back += "command: #{command} / args: #{args}\n" begin case command when 'search' client.search(args).take(3).each do |status| back += Format(:bold, :underline, :yellow, "@#{status.user.screen_name}") + " " + status.text + "\n" end else back += "Usage: .t search <term> : searches the public timelines" #back += Twitter.send(command,args.split(',')) end rescue Exception => e back += "Bad request\n" back += e.inspect back += e.backtrace.join("\n") end return back end def execute(m,command,args) m.reply(exec(command,args.strip)) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cogbot-0.1.1 | plugins/tweet.rb |