cinch-lmgtfy 0.0.1 → 0.0.2
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.
- data/lib/cinch/plugins/lmgtfy.rb +9 -5
- metadata +3 -3
data/lib/cinch/plugins/lmgtfy.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# -*- coding: utf-8 -*-
|
3
|
-
# Copyright (c)
|
3
|
+
# Copyright (c) 2011 Victor Bergöö
|
4
4
|
# This program is made available under the terms of the MIT License.
|
5
5
|
|
6
6
|
require 'cinch'
|
@@ -19,19 +19,23 @@ module Cinch
|
|
19
19
|
match /google ([^\s]*) (.*)/
|
20
20
|
|
21
21
|
def execute m, user, query
|
22
|
+
if not config["username"] or not config["api_key"]
|
23
|
+
@bot.debug "either 'username' or 'api_key' is not set, please add these options"
|
24
|
+
return
|
25
|
+
end
|
26
|
+
|
22
27
|
search = LmgtfyUrl % [query.dup.gsub(/\s+/, "+")]
|
23
28
|
short = ShortnerUrl % [config["username"], config["api_key"], URI.escape(search)]
|
24
29
|
|
25
30
|
call = Curl::Easy.perform(short)
|
26
31
|
json = JSON.parse call.body_str
|
27
32
|
|
28
|
-
suffix = m.user.nick[-1] == 's' ? "'" : "'s"
|
29
33
|
if json["status_code"] == 200
|
30
34
|
url = json["data"]["url"]
|
31
|
-
m.reply "#{user}
|
35
|
+
m.reply "#{user} check this out: #{url}"
|
32
36
|
else
|
33
|
-
error = json["
|
34
|
-
|
37
|
+
error = json["status_txt"]
|
38
|
+
@bot.debug "Something went wrong: #{error}"
|
35
39
|
end
|
36
40
|
end
|
37
41
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 2
|
9
|
+
version: 0.0.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Victor Bergoo
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-03-
|
17
|
+
date: 2011-03-26 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|