Skip to content

Commit

Permalink
Merge pull request #5 from Namasteh/master
Browse files Browse the repository at this point in the history
Version Update Merge
  • Loading branch information
b0nk committed Apr 18, 2014
2 parents f3cd250 + f39e838 commit 8c31ce1
Show file tree
Hide file tree
Showing 17 changed files with 1,154 additions and 638 deletions.
68 changes: 37 additions & 31 deletions Eve.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'cinch'
require 'redis'
require_relative "lib/eve/plugins/urban_dictionary"
require_relative "lib/eve/plugins/urban"
require_relative "lib/eve/plugins/help"
require_relative "lib/eve/plugins/seen"
require_relative "lib/eve/plugins/greeting"
Expand Down Expand Up @@ -29,6 +29,9 @@
require_relative "lib/eve/plugins/isitup"
require_relative "lib/eve/plugins/relationship_handler"
require_relative "lib/eve/plugins/admin_handler"
require_relative "lib/eve/plugins/four_chan"
require_relative "lib/eve/plugins/dictionary"
require_relative "lib/eve/plugins/news"


# You should have something in the block below as it will have Eve report
Expand All @@ -51,36 +54,39 @@
c.channels = ["#Eve"]
c.nick = "Eve"
c.user = "Eve"
c.realname = "Eve 5.0"
c.realname = "Eve 6.0"
c.plugins.plugins = [Cinch::Plugins::PluginManagement,
Cinch::Plugins::UrbanDictionary,
Cinch::Plugins::Help,
Cinch::Plugins::Seen,
Cinch::Plugins::Greeting,
Cinch::Plugins::Eightball,
Cinch::Plugins::Decide,
Cinch::Plugins::Memo,
Cinch::Plugins::AIRespond,
Cinch::Plugins::ControlPanel,
Cinch::Plugins::ChanopCP,
Cinch::Plugins::PrivateCP,
Cinch::Plugins::PrivChanCP,
Cinch::Plugins::FactCore,
Cinch::Plugins::ActAI,
Cinch::Plugins::UrlScraper,
Cinch::Plugins::Twitter,
Cinch::Plugins::TwitterStatus,
Cinch::Plugins::ValentineBoxx,
Cinch::Plugins::Wikipedia,
Cinch::Plugins::Weather,
Cinch::Plugins::Google,
Cinch::Plugins::YouTube,
Cinch::Plugins::Math,
Cinch::Plugins::Bitcoin,
Cinch::Plugins::UserInfo,
Cinch::Plugins::Isitup,
Cinch::Plugins::RelationshipHandler,
Cinch::Plugins::AdminHandler];
Cinch::Plugins::Urban,
Cinch::Plugins::Help,
Cinch::Plugins::Seen,
Cinch::Plugins::Greeting,
Cinch::Plugins::Eightball,
Cinch::Plugins::Decide,
Cinch::Plugins::Memo,
Cinch::Plugins::Ai,
Cinch::Plugins::ControlPanel,
Cinch::Plugins::ChanopCP,
Cinch::Plugins::PrivateCP,
Cinch::Plugins::PrivChanCP,
Cinch::Plugins::FactCore,
Cinch::Plugins::ActAI,
Cinch::Plugins::UrlScraper,
Cinch::Plugins::Twitter,
Cinch::Plugins::TwitterStatus,
Cinch::Plugins::ValentineBoxx,
Cinch::Plugins::Wikipedia,
Cinch::Plugins::Weather,
Cinch::Plugins::Google,
Cinch::Plugins::YouTube,
Cinch::Plugins::Math,
Cinch::Plugins::Bitcoin,
Cinch::Plugins::UserInfo,
Cinch::Plugins::Isitup,
Cinch::Plugins::RelationshipHandler,
Cinch::Plugins::AdminHandler,
Cinch::Plugins::FourChan,
Cinch::Plugins::Dictionary,
Cinch::Plugins::News];
#c.plugins.options[Cinch::Plugins::UrlScraper] = { enabled_channels: ["#foo", "#bar" "#channel"] }
#c.plugins.options[Cinch::Plugins::Greeting] = { enabled_channels: ["#foo", "#bar" "#channel"] }
#c.plugins.options[Cinch::Plugins::TwitterStatus] = {
Expand All @@ -98,7 +104,7 @@
#}
#}
c.plugins.options[Cinch::Plugins::Weather] = { key: 'foo' }
c.password = "nspass"
c.password = "nspass"
end
end

Expand Down
52 changes: 40 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,50 +12,66 @@ Eve and several of it's plugins have some dependencies. The first of which are v
###-Section A: Installing Ruby, RVM, and RubyGems-

1.) The first thing we need to do is make sure that your package manager is up to date:
sudo apt-get update

> sudo apt-get update
2.) If you don't have curl you need to install it now:
sudo apt-get install curl

> sudo apt-get install curl
3.) Now you need to install RVM:
\curl -L https://get.rvm.io | bash -s stable

> \curl -L https://get.rvm.io | bash -s stable
4.) Now you need to load RVM:
source ~/.rvm/scripts/rvm

> source ~/.rvm/scripts/rvm
5.) Now you need to install RVM's dependencies:
rvm requirements

rvm requirements

6.) Now you need to install Ruby:
rvm install ruby

rvm install ruby

7.) Now you need to tell the system what version to use as default:
rvm use ruby -default

rvm use ruby -default

8.) Now you need to install RubyGems:
rvm rubygems current

rvm rubygems current

Excellent. Now you are done installing RVM, Ruby, and RubyGems!

###-Section B: Installing the Framework-

1.) This is really easy:
gem install cinch

gem install cinch

###-Section C: Installing Plugin Dependencies-

As of now there are only two dependencies needed for the plugins.

1.) If you want to have Eve do anything that has to do with web fetching you must install the Nokogiri gem:
gem install nokogiri

gem install nokogiri

2.) If you want to have Eve fetch tweets from any twitter account you need to install the Twitter gem:
gem install cinch-twitter

gem install cinch-twitter

3.) Most of Eve's plugins rely on JSON:

gem install json

###-Section D: Getting Eve-

Now you just need to get Eve from the repo:
git clone https://github.com/Namasteh/Eve-Bot.git

git clone https://github.com/Namasteh/Eve-Bot.git

###-Section E: Configuring Eve-

Expand All @@ -70,3 +86,15 @@ Next you need to make sure the plugins you want loaded are in the c.plugins.plug
Next are your Twitter options, you need to put your API keys in this section or the Twitter plugin will not work!

In c.password you need to put Eve's NickServ pass so she can identify upon connecting.

###-Section F: Adding Yourself As Master-

When you run Eve, you will need the bot to recognize you as master, and you must add yourself as a master to the bot's userinfo.yaml file in order for any of the userinfo dependent plugins to work.

So open docs/userinfo.yaml and place the following inside, save, and close

---
yourircnick:
auth: yourauthname
master: true

98 changes: 71 additions & 27 deletions lib/eve/plugins/bitcoin.rb
Original file line number Diff line number Diff line change
@@ -1,27 +1,71 @@
require 'cinch'
require 'ostruct'
require 'open-uri'
require 'json'

module Cinch
module Plugins
class Bitcoin
include Cinch::Plugin

set :plugin_name, 'bitcoin'
set :help, <<-USAGE.gsub(/^ {6}/, '')
Just a seen plugin!
Usage:
* !btcv: Returns the latest value of 1 (one) Bitcoin in USD
USAGE

match /btcv/

def execute(m)
data = JSON.parse(open("http://blockchain.info/ticker").read)
value = data['USD']['15m']
m.reply "Current value of 1 BTC in USD is: #{value}", true
end
end
end
end
require 'cinch'
require 'ostruct'
require 'open-uri'
require 'json'

module Cinch
module Plugins
class Bitcoin
include Cinch::Plugin

set :plugin_name, 'bitcoin'
set :help, <<-USAGE.gsub(/^ {6}/, '')
Bitcoin plugin that fetches results from Blockchain.info!
Usage:
* !btcv <currency>: Returns the latest value of 1 (one) Bitcoin in <currency>
* !btc <currency> <Bitcoin amount>: Returns the value of <Bitcoin amount> in <currency>.
USAGE

match /btcv (\w{3})/

def execute(m, currency)
data = JSON.parse(open("http://blockchain.info/ticker").read)

coins = ['USD', 'CNY', 'JPY', 'SGD', 'HKD', 'CAD', 'NZD', 'AUD', 'CLP', 'GBP', 'HKK', 'SEK', 'ISK', 'CHF', 'BRL', 'EUR', 'RUB', 'PLN', 'THB', 'KRW', 'TWD']

currency = currency.upcase

if !coins.include?(currency)
m.reply "That currency isn't in my database!"
m.user.notice "You can use: #{coins}"
return
end

value = data[currency]['15m']
value = value.round(2).to_f
value = value.to_s.reverse.gsub(/(\d{3})(?=\d)/, '\\1,').reverse

symbol = data[currency]['symbol']

m.reply "Current value of 1 BTC in #{currency} is: #{symbol}#{value}", true
end

match /btc (\w{3}) (.+)/, method: :conversion

def conversion(m, currency, btc)
data = JSON.parse(open("http://blockchain.info/ticker").read)

coins = ['USD', 'CNY', 'JPY', 'SGD', 'HKD', 'CAD', 'NZD', 'AUD', 'CLP', 'GBP', 'HKK', 'SEK', 'ISK', 'CHF', 'BRL', 'EUR', 'RUB', 'PLN', 'THB', 'KRW', 'TWD']

currency = currency.upcase

if !coins.include?(currency)
m.reply "That currency isn't in my database!"
m.user.notice "You can use: #{coins}"
return
end
value = data[currency]['15m']
value = value.round(2).to_f

symbol = data[currency]['symbol']

btc = btc.to_f

conv = (btc * value).round(2)
conv = conv.to_s.reverse.gsub(/(\d{3})(?=\d)/, '\\1,').reverse

m.reply "The value of #{btc}BTC is #{symbol}#{conv}.", true
end
end
end
end
27 changes: 27 additions & 0 deletions lib/eve/plugins/config/check_auth.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require 'cinch'
require 'yaml'

module Cinch
module Helpers

def check_auth(user)
reload
user.refresh

return false unless !user.authname.nil?

if ((@storage.key?(user.nick)) && (@storage[user.nick].key? 'auth'))
auth = @storage[user.nick]['auth']
return auth == user.authname
end
end

def reload
if File.exist?('docs/userinfo.yaml')
@storage = YAML.load_file('docs/userinfo.yaml')
else
@storage = {}
end
end
end
end
Loading

0 comments on commit 8c31ce1

Please sign in to comment.