Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
51ba163
Fixed the retype check
roun512 Jul 31, 2014
f52e4d7
Merge remote-tracking branch 'upstream/master' into upstream
roun512 Jul 31, 2014
144bff3
Merge remote-tracking branch 'upstream/master'
roun512 Jul 31, 2014
e7474de
Merge branch 'master' of https://github.com/roun512/ricer2 into upstream
roun512 Aug 1, 2014
76332e9
Merge remote-tracking branch 'upstream/master'
roun512 Aug 3, 2014
542872f
Reverses a string plugin
roun512 Aug 3, 2014
9d5ae7b
Created wtf that gets meaning from urban dictionary
roun512 Aug 3, 2014
4fe67f3
Merge remote-tracking branch 'origin/upstream'
roun512 Aug 17, 2014
39b4247
Search on Google
roun512 Aug 28, 2014
18bb2cb
Get the weather from a specific city
roun512 Aug 28, 2014
14dfabc
Searches for youtube videos using dorks
roun512 Aug 28, 2014
0aa6624
Lang file
roun512 Aug 28, 2014
90c00e3
Bed time
roun512 Aug 28, 2014
f5bc236
Dog
roun512 Aug 28, 2014
f8bb472
Fixed reboot command
roun512 Aug 28, 2014
094a98e
Added description for new plugin
roun512 Aug 28, 2014
c0afacf
Merge branch 'master' of https://github.com/roun512/ricer2
roun512 Aug 28, 2014
2a08409
Delete en.yml
roun512 Aug 28, 2014
8024958
Updated
roun512 Aug 28, 2014
00bc2f2
Tcp client inside ricer2
roun512 Sep 9, 2014
df3e60d
Create close.rb
roun512 Sep 10, 2014
8226623
Update connect.rb
roun512 Sep 10, 2014
a9a716b
Create current.rb
roun512 Sep 12, 2014
03466c1
Update connect.rb
roun512 Sep 12, 2014
254d170
Update submit.rb
roun512 Sep 12, 2014
7462a0a
Update submit.rb
roun512 Sep 12, 2014
3e3f853
Update disconnect.rb
roun512 Sep 12, 2014
9c75370
Update connect.rb
roun512 Sep 12, 2014
985c65b
Update submit.rb
roun512 Sep 12, 2014
6dd813a
Update connect.rb
roun512 Sep 12, 2014
3e58b3e
Create tcp.rb
roun512 Sep 13, 2014
23a4b07
Update close.rb
roun512 Sep 13, 2014
fcae646
Update connect.rb
roun512 Sep 13, 2014
5e00af9
Update close.rb
roun512 Sep 13, 2014
d6e6786
Update close.rb
roun512 Sep 13, 2014
9e16780
Update connect.rb
roun512 Sep 13, 2014
828d4c9
new imgur plugin
roun512 Oct 27, 2014
f2d219f
botip plugin
roun512 Oct 27, 2014
1890787
Update en.yml
roun512 Oct 27, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion app/models/ricer/plugins/admin/reboot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@ class Reboot < Ricer::Plugin
requires_retype

has_usage :execute_reboot

def execute_reboot
execute_with_message(t(:default_msg, user:sender.displayname))
end

has_usage :execute_with_message, '<..message..>'

def execute_with_message(message)
exec_line "die #{message}"
bot.servers.each do |server|
server.connection.send_quit(@message, message) if server.connected?
end
bot.running = false
pid = spawn "bundle exec rake ricer:start"
Process.detach(pid)
end
Expand Down
18 changes: 18 additions & 0 deletions app/models/ricer/plugins/data/botip.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require "open-uri"

module Ricer::Plugins::Data
class Botip < Ricer::Plugin

trigger_is :botip

has_usage :execute

def execute
Ricer::Thread.execute do
ip = open("http://ipecho.net/plain")
response = ip.read
reply response
end
end
end
end
13 changes: 13 additions & 0 deletions app/models/ricer/plugins/data/google.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module Ricer::Plugins::Data
class Google < Ricer::Plugin

trigger_is :google

has_usage :execute, '<...message...>'

def execute(message)
google_url = "https://www.google.com/search?q=#{URI::encode(message)}"
reply google_url
end
end
end
51 changes: 51 additions & 0 deletions app/models/ricer/plugins/data/imgur.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
require 'json'
require 'open-uri'

module Ricer::Plugins::Data
class Imgur < Ricer::Plugin

trigger_is :imgur
has_usage :execute
has_usage :execute_msg, '<...message...>'
def execute
Ricer::Thread.execute do
uri = open("https://api.imgur.com/3/gallery/random/random/",
'Authorization' => 'Client-ID a90bec0cef5bd5c',
'Accept' => 'application/json'
)
buffer = uri.read
result = ActiveSupport::JSON.decode(buffer)
# result = JSON.parse(buffer)
id = rand(7)
imgur = result['data'][id]
reply "#{imgur['title']} - #{imgur['link']} \u000303#{imgur['ups']}\u000f\u2934 \u000304#{imgur['downs']}\u000f\u2935"
end
end

def execute_msg(message)
case message
when "hot"
group = "hot"
when "viral"
group = "viral"
when "top"
group = "top"
else
execute
return false
end
page = rand(4)
Ricer::Thread.execute do
url = open("https://api.imgur.com/3/gallery/#{group}/top/#{page}.json",
'Authorization' => 'Client-ID a90bec0cef5bd5c',
'Accept' => 'application/json'
)
buffer = url.read
result = ActiveSupport::JSON.decode(buffer)
id = rand(7)
imgur = result['data'][id]
reply "#{imgur['title']} - #{imgur['link']} \u000303#{imgur['ups']}\u000f\u2934 \u000304#{imgur['downs']}\u000f\u2935"
end
end
end
end
10 changes: 10 additions & 0 deletions app/models/ricer/plugins/data/lang/en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
en:
ricer:
plugins:
data:
imgur:
description: 'Displays a random image from imgur.'
botip:
description: 'Displays the bot ip.'
weather:
description: 'Displays the weather of the given city or country'
25 changes: 25 additions & 0 deletions app/models/ricer/plugins/data/weather.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require "nokogiri"
require "open-uri"

module Ricer::Plugins::Data
class Weather < Ricer::Plugin

trigger_is :weather

has_usage :execute, '<...message...>'

def execute(city)
url = "http://api.openweathermap.org/data/2.5/forecast?q=#{city}&mode=xml"
Ricer::Thread.execute do
doc = Nokogiri::XML(open(url), nil, "UTF-8")
data = doc.xpath("//temperature").first
temp = data.attr("value")
city = city
min = data.attr("min")
max = data.attr("max")
# set.each {|s| reply s.to_s}
reply "The temperature is around #{temp} celsius in #{city} and the minimum temperature is #{min} while the maximum temperature is #{max}"
end
end
end
end
12 changes: 12 additions & 0 deletions app/models/ricer/plugins/data/ytsearch.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module Ricer::Plugins::Data
class Ytsearch < Ricer::Plugin

trigger_is :ytsearch

has_usage :execute, '<...message...>'

def execute(message)
rply :link, message:message
end
end
end
16 changes: 16 additions & 0 deletions app/models/ricer/plugins/fun/bed.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module Ricer::Plugins::Fun
class Bed < Ricer::Plugin

trigger_is :bed

has_usage :execute

def execute()
user = sender.name
case rand(0..1)
when 0; rply :bed1, user:user
when 1; rply :bed2, user:user
end
end
end
end
16 changes: 16 additions & 0 deletions app/models/ricer/plugins/fun/cat.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module Ricer::Plugins::Fun
class Cat < Ricer::Plugin

trigger_is :cat

has_usage :execute

def execute()
case rand(0..2)
when 0; rply :cat1
when 1; rply :cat2
when 2; rply :cat3
end
end
end
end
15 changes: 15 additions & 0 deletions app/models/ricer/plugins/fun/lang/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,18 @@ en:
tumbleweed: 'makes the tumbleweed sound.'
happy_hour:
description: 'Used by gizmore to inititate happy hour mode in #wechall'
reverse:
description: 'Reverses a string backwards.'
wtf:
description: 'gets the word meaning from urbandictionary.'
err_not_found: 'Not found.'
msg_example: "Example: %{example}"
bed:
description: 'You can use this function to goto bed.'
bed1: 'nighty night %{user}'
bed2: 'good night %{user}'
cat:
description: 'Dog sees a cat!'
cat1: 'Bark! Bark!'
cat2: 'Woof! Woof!'
cat3: 'Shrug!'
10 changes: 10 additions & 0 deletions app/models/ricer/plugins/fun/reverse.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Ricer::Plugins::Fun
class Reverse < Ricer::Plugin

trigger_is :reverse
has_usage :execute_reverse, '<...message...>'
def execute_reverse(message)
reply message.reverse
end
end
end
21 changes: 21 additions & 0 deletions app/models/ricer/plugins/fun/wtf.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'nokogiri'
require 'open-uri'

module Ricer::Plugins::Fun
class Wtf < Ricer::Plugin

trigger_is :wtf

has_usage :wtf, '<...message...>'

def wtf(message)
message.gsub!(/\s/, '+')
ud = 'http://www.urbandictionary.com/define.php?term=' + message
doc = Nokogiri::HTML(open(ud), nil, 'UTF-8')
meaning = doc.at_css('.meaning').content.strip
example = doc.at_css('.example').content.strip
reply meaning
reply "Example: " + example
end
end
end
15 changes: 15 additions & 0 deletions app/models/ricer/plugins/tcp/close.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'socket'

require_relative 'connect'

module Ricer::Plugins::Tcp
class Close < Ricer::Plugin
def execute_close
tcp_connection = sender.instance_variable_get(:@ricer_tcp_plugin_connection)
unless tcp_connection.nil?
tcp_connection.close
reply "Previous connection closed"
end
end
end
end
43 changes: 43 additions & 0 deletions app/models/ricer/plugins/tcp/connect.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
require 'socket'

require_relative 'disconnect'
require_relative 'submit'

module Ricer::Plugins::Tcp
class Connect < Ricer::Plugin

permission_is :voice

trigger_is :connect

has_usage :connect, '<host> <port>'

def connect(host, port)
tcp_connection = sender.instance_variable_get(:@ricer_tcp_plugin_connection)
unless tcp_connection.nil?
get_plugin('Tcp/Close').execute_close
end
Ricer::Thread.execute do
begin
socket = TCPSocket.open(host, port)
if socket
reply "Connected"
else
reply "Couldn't connect"
end


# response = socket.read
# reply response

#user.instance_variable_set(:@ricer_tcp_plugin_connection, socket)
sender.instance_variable_set(:@ricer_tcp_plugin_connection, socket)
sender.instance_variable_set(:@ricer_tcp_plugin_host, host)
sender.instance_variable_set(:@ricer_tcp_plugin_port, port)
rescue => se
byebug
end
end
end
end
end
21 changes: 21 additions & 0 deletions app/models/ricer/plugins/tcp/current.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module
require_relative 'connect'

permission_is :voice

trigger_is :current

has_usage :execute

def execute
tcp_connection = sender.instance_variable_get(:@ricer_tcp_plugin_connection)
if tcp_connection.nil?
reply "You are not connected to anything yet!"
else
host = sender.instance_variable_get(:@ricer_tcp_plugin_host)
port = sender.instance_variable_get(:@ricer_tcp_plugin_port)
reply host unless host.nil?
reply port unless port.nil?
end

end
26 changes: 26 additions & 0 deletions app/models/ricer/plugins/tcp/disconnect.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
require 'socket'

require_relative 'connect'
require_relative 'submit'

module Ricer::Plugins::Tcp
class Disconnect < Ricer::Plugin

permission_is :voice

trigger_is :disconnect

has_usage :disconnect

def disconnect
tcp_connection = sender.instance_variable_get(:@ricer_tcp_plugin_connection)
if tcp_connection.nil?
reply "You are not connected to anything yet!"
else
sender.remove_instance_variable(:@ricer_tcp_plugin_connection)
tcp_connection.close
reply "Closed connection"
end
end
end
end
7 changes: 7 additions & 0 deletions app/models/ricer/plugins/tcp/export/host_param.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Ricer::Plug::Params
class HostParam < Base
def convert_in!(input, option, message)
input
end
end
end
7 changes: 7 additions & 0 deletions app/models/ricer/plugins/tcp/export/port_param.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Ricer::Plug::Params
class PortParam < Base
def convert_in!(input, option, message)
input
end
end
end
Loading