cinch-lmgtfy 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/cinch/plugins/lmgtfy.rb +9 -5
  2. metadata +3 -3
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # -*- coding: utf-8 -*-
3
- # Copyright (c) 2010 Victor Bergöö
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}#{suffix}: #{url}"
35
+ m.reply "#{user} check this out: #{url}"
32
36
  else
33
- error = json["status_text"]
34
- m.reply "Something went wrong: #{error}"
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
- - 1
9
- version: 0.0.1
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-23 00:00:00 +01:00
17
+ date: 2011-03-26 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency