nekos 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +7 -0
  2. data/lib/nekos.rb +153 -0
  3. data/lib/nekos/api.rb +47 -0
  4. data/lib/nekos/ver.rb +3 -0
  5. metadata +102 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ed2271e1fb62e39713695a96686caaeb90326ddcebebe7f79b9a8b3aec88fe2a
4
+ data.tar.gz: 3c90826de225806dd356c2490625375a43c7df3260d6d6fdb4c83380e87e478a
5
+ SHA512:
6
+ metadata.gz: f471a29aa0d4fe76d4175bfd34ae8696231db73db6d1ee367fdf84964dc5669f03f4d17a8fbdc0e9563c848705636e56f8962d165b1471292eaaf45c291f796c
7
+ data.tar.gz: f9b2e7316a483d06e2b2ae23929302b3310a9895cdd10bdd9784c384424a62cc072b6e49005ea112b6a440584ebeaa6783320f493aa7bdfa65a81a14ed71b3fa
@@ -0,0 +1,153 @@
1
+ require 'nekos/api'
2
+
3
+ # nekoslife base module
4
+ module NekosLife
5
+ # The main module for interaction
6
+ class Client
7
+ @image_endpoints = []
8
+
9
+ # @!macro [attach] add_image_endpoint
10
+ # @method $2
11
+ # Gets an image of `$2`
12
+ # @return [String] the image URL with the `$2` type.
13
+ # @!visibility private
14
+ def self.add_image_endpoint(endpoint)
15
+ @image_endpoints.push endpoint
16
+ attr_reader endpoint
17
+ define_method endpoint.downcase do
18
+ API.img(endpoint)['url']
19
+ end
20
+ end
21
+
22
+ add_image_endpoint('feet')
23
+ add_image_endpoint('yuri')
24
+ add_image_endpoint('trap')
25
+ add_image_endpoint('futanari')
26
+ add_image_endpoint('hololewd')
27
+ add_image_endpoint('lewdkemo')
28
+ add_image_endpoint('solog')
29
+ add_image_endpoint('feetg')
30
+ add_image_endpoint('cum')
31
+ add_image_endpoint('erokemo')
32
+ add_image_endpoint('les')
33
+ add_image_endpoint('wallpaper')
34
+ add_image_endpoint('lewdk')
35
+ add_image_endpoint('ngif')
36
+ add_image_endpoint('meow')
37
+ add_image_endpoint('tickle')
38
+ add_image_endpoint('lewd')
39
+ add_image_endpoint('feed')
40
+ add_image_endpoint('gecg')
41
+ add_image_endpoint('eroyuri')
42
+ add_image_endpoint('eron')
43
+ add_image_endpoint('cum_jpg')
44
+ add_image_endpoint('bj')
45
+ add_image_endpoint('nsfw_neko_gif')
46
+ add_image_endpoint('solo')
47
+ add_image_endpoint('kemonomimi')
48
+ add_image_endpoint('nsfw_avatar')
49
+ add_image_endpoint('gasm')
50
+ add_image_endpoint('poke')
51
+ add_image_endpoint('anal')
52
+ add_image_endpoint('slap')
53
+ add_image_endpoint('hentai')
54
+ add_image_endpoint('avatar')
55
+ add_image_endpoint('erofeet')
56
+ add_image_endpoint('holo')
57
+ add_image_endpoint('keta')
58
+ add_image_endpoint('blowjob')
59
+ add_image_endpoint('pussy')
60
+ add_image_endpoint('tits')
61
+ add_image_endpoint('holoero')
62
+ add_image_endpoint('lizard')
63
+ add_image_endpoint('pussy_jpg')
64
+ add_image_endpoint('pwankg')
65
+ add_image_endpoint('classic')
66
+ add_image_endpoint('kuni')
67
+ add_image_endpoint('waifu')
68
+ add_image_endpoint('pat')
69
+ add_image_endpoint('kiss')
70
+ add_image_endpoint('femdom')
71
+ add_image_endpoint('neko')
72
+ add_image_endpoint('spank')
73
+ add_image_endpoint('cuddle')
74
+ add_image_endpoint('erok')
75
+ add_image_endpoint('fox_girl')
76
+ add_image_endpoint('boobs')
77
+ add_image_endpoint('Random_hentai_gif')
78
+ add_image_endpoint('smallboobs')
79
+ add_image_endpoint('hug')
80
+ add_image_endpoint('ero')
81
+
82
+ alias_method :holo_lewd, :hololewd
83
+ alias_method :lwed_holo, :hololewd
84
+ alias_method :lewd_kemo, :lewdkemo
85
+ alias_method :solo_girl, :solog
86
+ alias_method :ero_kemo, :erokemo
87
+ alias_method :lewd_kitsune, :lewdk
88
+ alias_method :neko_gif, :ngif
89
+ alias_method :ero_yuri, :eroyuri
90
+ alias_method :ero_neko, :eron
91
+ alias_method :ero_feet, :erofeet
92
+ alias_method :holo_ero, :holoero
93
+ alias_method :ero_holo, :holoero
94
+ alias_method :erokitsune, :erok
95
+ alias_method :small_boobs, :smallboobs
96
+
97
+ # OwOifys text.
98
+ # @param text [String] text to owoify
99
+ # @return [String] owoified text
100
+ def owoify(text)
101
+ API.get("owoify?text=#{URI.encode(text)}")['owo']
102
+ end
103
+
104
+ # Chat with the API
105
+ # @param text [String] text to query
106
+ # @param owo [true, false] whether or not to owoify response text
107
+ # @return [String] the response
108
+ def chat(text, owo = false)
109
+ API.get("chat?text=#{URI.encode(text)}#{'&owo=true' if owo}")['response']
110
+ end
111
+
112
+ # Gets a random fact
113
+ # @return [String] the fact
114
+ def fact
115
+ API.get('fact')['fact']
116
+ end
117
+
118
+ # Gets a random question
119
+ # @return [String] the question
120
+ def why
121
+ API.get('why')['why']
122
+ end
123
+
124
+ # Gets an ascii cat
125
+ # @return [String] the cat
126
+ def cat
127
+ API.get('cat')['cat']
128
+ end
129
+
130
+ # Gets an ascii cat
131
+ # @return [EightBallResponse] the response given with text and an image url
132
+ def eight_ball
133
+ EightBallResponse.new(API.get('8ball'))
134
+ end
135
+ alias_method :eightball, :eight_ball
136
+ end
137
+
138
+ # A response from the 8ball endpoint
139
+ class EightBallResponse
140
+ # @return [String] the response in text form.
141
+ attr_reader :text
142
+ alias_method :to_s, :text
143
+
144
+ # @return [String] the response in image form.
145
+ attr_reader :image_url
146
+
147
+ # @!visibility private
148
+ def initialize(data)
149
+ @text = data['response']
150
+ @image_url = data['url']
151
+ end
152
+ end
153
+ end
@@ -0,0 +1,47 @@
1
+ require 'nekos/ver'
2
+ require 'json'
3
+ require 'rest-client'
4
+
5
+ module NekosLife
6
+ # Main API functions
7
+ module API
8
+ module_function
9
+
10
+ BASE = 'https://nekos.life/api/v2'.freeze
11
+
12
+ # Request an endpoint easily
13
+ # @return [Hash] the response given in JSON
14
+ def request(type, *attributes)
15
+ parse_json(RestClient.send(type, *attributes))
16
+ rescue RuntimeError => e
17
+ raise e
18
+ end
19
+
20
+ # Requests an image
21
+ # @param type [String] the image type
22
+ # @return [Hash] the response given in JSON
23
+ def img(type)
24
+ request(
25
+ :get,
26
+ "#{BASE}/img/#{type}"
27
+ )
28
+ end
29
+
30
+ # Requests an endpoint
31
+ # @param endpoint [String] the endpoint
32
+ # @return [Hash] the response given in JSON
33
+ def get(endpoint)
34
+ request(
35
+ :get,
36
+ "#{BASE}/#{endpoint}"
37
+ )
38
+ end
39
+
40
+ # @!visibility private
41
+ def parse_json(raw)
42
+ JSON.parse(raw)
43
+ rescue JSON::ParserError
44
+ raw
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,3 @@
1
+ module NekosLife
2
+ VERSION = '1.0.0'.freeze
3
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nekos
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Snazzah
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-07-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: inch
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.8.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.8.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 0.49.1
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 0.49.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: rest-client
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: A gem that utilizes the nekos.life API.
70
+ email: suggesttosnazzy@gmail.com
71
+ executables: []
72
+ extensions: []
73
+ extra_rdoc_files: []
74
+ files:
75
+ - lib/nekos.rb
76
+ - lib/nekos/api.rb
77
+ - lib/nekos/ver.rb
78
+ homepage: https://github.com/Nekos-Life/nekos.rb
79
+ licenses:
80
+ - MIT
81
+ metadata: {}
82
+ post_install_message:
83
+ rdoc_options: []
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ requirements: []
97
+ rubyforge_project:
98
+ rubygems_version: 2.7.6
99
+ signing_key:
100
+ specification_version: 4
101
+ summary: A gem that utilizes the nekos.life API.
102
+ test_files: []