cinch-lmgtfy 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. data/LICENSE +20 -0
  2. data/README.rdoc +43 -0
  3. data/lib/cinch/plugins/lmgtfy.rb +39 -0
  4. metadata +105 -0
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Victor Bergöö
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,43 @@
1
+ = cinch-lmgtfy
2
+
3
+ A simple plugin for the IRC-framework cinch to give lazy people a LMGTFY search.
4
+
5
+ == Requirements
6
+
7
+ The plugin requires a bit.ly[http://bit.ly] user and API-key and it also require's a curl installation.
8
+
9
+ sudo apt-get install curl
10
+
11
+ == Example bot
12
+
13
+ require 'cinch'
14
+ require 'cinch/plugins/lmgtfy'
15
+
16
+ bot = Cinch::Bot.new do
17
+ configure do |c|
18
+ c.nick = "Cinchbot"
19
+ c.server = "irc.freenode.org"
20
+ c.channels = ["#cinchbots"]
21
+ c.plugins.plugins = [Cinch::Plugins::LMGTFY]
22
+ c.plugins.options = {
23
+ Cinch::Plugins::LMGTFY => {
24
+ "username" => "SOME_USER",
25
+ "api_key" => "API_KEY"
26
+ }
27
+ }
28
+ end
29
+ end
30
+
31
+ bot.start
32
+
33
+ To interact with the bot, just simply do
34
+
35
+ !google LazyUser how can i find foo
36
+
37
+ == Notice
38
+
39
+ This is just built for fun and I have no affiliation with the LMGTFY-team nor with Google
40
+
41
+ == Copyright
42
+
43
+ Copyright (c) 2011 Victor Bergöö. See LICENSE for details.
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- coding: utf-8 -*-
3
+ # Copyright (c) 2010 Victor Bergöö
4
+ # This program is made available under the terms of the MIT License.
5
+
6
+ require 'cinch'
7
+ require 'curb'
8
+ require 'uri'
9
+ require 'json'
10
+
11
+ module Cinch
12
+ module Plugins
13
+ class LMGTFY
14
+ include Cinch::Plugin
15
+
16
+ LmgtfyUrl = "http://lmgtfy.com/?q=%s"
17
+ ShortnerUrl = "http://api.bitly.com/v3/shorten?login=%s&apiKey=%s&format=json&longUrl=%s"
18
+
19
+ match /google ([^\s]*) (.*)/
20
+
21
+ def execute m, user, query
22
+ search = LmgtfyUrl % [query.dup.gsub(/\s+/, "+")]
23
+ short = ShortnerUrl % [config["username"], config["api_key"], URI.escape(search)]
24
+
25
+ call = Curl::Easy.perform(short)
26
+ json = JSON.parse call.body_str
27
+
28
+ suffix = m.user.nick[-1] == 's' ? "'" : "'s"
29
+ if json["status_code"] == 200
30
+ url = json["data"]["url"]
31
+ m.reply "#{user}#{suffix}: #{url}"
32
+ else
33
+ error = json["status_text"]
34
+ m.reply "Something went wrong: #{error}"
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cinch-lmgtfy
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Victor Bergoo
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-03-23 00:00:00 +01:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: cinch
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :runtime
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
34
+ name: json
35
+ prerelease: false
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
43
+ version: "0"
44
+ type: :runtime
45
+ version_requirements: *id002
46
+ - !ruby/object:Gem::Dependency
47
+ name: curb
48
+ prerelease: false
49
+ requirement: &id003 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ segments:
55
+ - 0
56
+ version: "0"
57
+ type: :runtime
58
+ version_requirements: *id003
59
+ description: A Cinch plugin for Let Me Google That For You!
60
+ email: victor.bergoo@gmail.com
61
+ executables: []
62
+
63
+ extensions: []
64
+
65
+ extra_rdoc_files:
66
+ - LICENSE
67
+ - README.rdoc
68
+ files:
69
+ - LICENSE
70
+ - README.rdoc
71
+ - lib/cinch/plugins/lmgtfy.rb
72
+ has_rdoc: true
73
+ homepage: http://github.com/netfeed/cinch-lmgtfy
74
+ licenses: []
75
+
76
+ post_install_message:
77
+ rdoc_options: []
78
+
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ segments:
87
+ - 0
88
+ version: "0"
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ segments:
95
+ - 0
96
+ version: "0"
97
+ requirements: []
98
+
99
+ rubyforge_project:
100
+ rubygems_version: 1.3.7
101
+ signing_key:
102
+ specification_version: 3
103
+ summary: A Cinch plugin for Let Me Google That For You
104
+ test_files: []
105
+