Class: Mrweb::API
- Inherits:
-
Object
- Object
- Mrweb::API
- Defined in:
- lib/mrweb.rb
Instance Method Summary collapse
- #barcode(code) ⇒ Object
- #bing_dalle(text) ⇒ Object
- #chrome_extention(id, file) ⇒ Object
- #domain_check(domain) ⇒ Object
- #email(to, subject, text) ⇒ Object
- #fakesite(site) ⇒ Object
- #fal(filename) ⇒ Object
- #google_drive(link) ⇒ Object
- #imagegen(text) ⇒ Object
-
#initialize(apikey = nil, use_testkey = false, env = false) ⇒ API
constructor
A new instance of API.
- #insta(link) ⇒ Object
- #ipinfo(ip) ⇒ Object
- #isaitext(text) ⇒ Object
- #isbadword(text) ⇒ Object
- #notebook(text, savetofile = false, filename = nil) ⇒ Object
- #ocr(to, url) ⇒ Object
- #proxy ⇒ Object
- #qr(texturl, action = 'encode', savefile = true) ⇒ Object
- #randbio ⇒ Object
- #sendweb3(privatekey = nil, address = nil, amount = nil, rpc = nil, chainid = nil) ⇒ Object
- #translate(to, text) ⇒ Object
- #voicemaker(text, sayas = 'man', filename = nil) ⇒ Object
- #webshot(site, filesave) ⇒ Object
- #wikipedia(text) ⇒ Object
- #worldclock ⇒ Object
- #youtube(vid) ⇒ Object
Constructor Details
#initialize(apikey = nil, use_testkey = false, env = false) ⇒ API
Returns a new instance of API.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/mrweb.rb', line 12 def initialize(apikey = nil, use_testkey = false, env = false) @apikey = apikey if use_testkey @apikey = 'testkey' elsif env begin @apikey = ENV['MRWEB_APIKEY'] rescue raise EnvError, 'Failed To Get APIKEY From env please Set By Name MRWEB_APIKEY in environ variable name' end end end |
Instance Method Details
#barcode(code) ⇒ Object
183 184 185 186 187 188 189 190 191 |
# File 'lib/mrweb.rb', line 183 def (code) apikey = @apikey api = Net::HTTP.get(URI("https://mrapiweb.ir/api/barcode.php?key=#{apikey}&code=#{code}")) begin return JSON.parse(api)['result'] rescue return JSON.parse(api)['message'] end end |
#bing_dalle(text) ⇒ Object
151 152 153 |
# File 'lib/mrweb.rb', line 151 def bing_dalle(text) raise EndSupport, 'Bing Dalle Is End Of Support' end |
#chrome_extention(id, file) ⇒ Object
159 160 161 162 163 164 |
# File 'lib/mrweb.rb', line 159 def chrome_extention(id, file) api = Net::HTTP.get(URI("https://mrapiweb.ir/api/chrome.php?id=#{id}")) File.open(file, 'wb') do |f| f.write(api) end end |
#domain_check(domain) ⇒ Object
193 194 195 196 |
# File 'lib/mrweb.rb', line 193 def domain_check(domain) api = JSON.parse(Net::HTTP.get(URI("https://mrapiweb.ir/api/domain.php?domain=#{domain}"))) return api end |
#email(to, subject, text) ⇒ Object
79 80 81 82 83 |
# File 'lib/mrweb.rb', line 79 def email(to, subject, text) send = "to=#{to}&subject=#{subject}&message=#{text}" Net::HTTP.get(URI("https://mrapiweb.ir/api/email.php?#{send}")) return "Email Sent To #{to}" end |
#fakesite(site) ⇒ Object
166 167 168 169 |
# File 'lib/mrweb.rb', line 166 def fakesite(site) api = Net::HTTP.get(URI("https://mrapiweb.ir/api/fakesite.php?site=#{site}")) return JSON.parse(api)['is_real'] end |
#fal(filename) ⇒ Object
123 124 125 126 127 128 129 |
# File 'lib/mrweb.rb', line 123 def fal(filename) api = Net::HTTP.get(URI('https://mrapiweb.ir/api/fal.php')) File.open(filename, 'wb') do |mr| mr.write(api) end return true end |
#google_drive(link) ⇒ Object
145 146 147 148 149 |
# File 'lib/mrweb.rb', line 145 def google_drive(link) api = Net::HTTP.get(URI("https://mrapiweb.ir/api/gdrive.php?url=#{link}")) drive = JSON.parse(api) return drive['link'] end |
#imagegen(text) ⇒ Object
111 112 113 114 115 |
# File 'lib/mrweb.rb', line 111 def imagegen(text) apikey = @apikey text = text.gsub(' ', '-') return Net::HTTP.get(URI("https://mrapiweb.ir/api/imagegen.php?key=#{apikey}&imgtext=#{text}")) end |
#insta(link) ⇒ Object
95 96 97 |
# File 'lib/mrweb.rb', line 95 def insta(link) return link.gsub('instagram.com', 'ddinstagram.com') end |
#ipinfo(ip) ⇒ Object
85 86 87 88 89 90 91 92 93 |
# File 'lib/mrweb.rb', line 85 def ipinfo(ip) api = Net::HTTP.get(URI("https://mrapiweb.ir/api/ipinfo.php?ipaddr=#{ip}")) ip = JSON.parse(api) begin return ip rescue raise APIError, "Failed To Get This IP Information : #{ip}" end end |
#isaitext(text) ⇒ Object
57 58 59 60 61 62 |
# File 'lib/mrweb.rb', line 57 def isaitext(text) text = CGI.escape("text=#{text}") api = Net::HTTP.get(URI("https://mrapiweb.ir/api/aitext.php?#{text}")) result = JSON.parse(api) return result['aipercent'] != '0%' end |
#isbadword(text) ⇒ Object
46 47 48 49 50 51 |
# File 'lib/mrweb.rb', line 46 def isbadword(text) text = CGI.escape("text=#{text}") api = Net::HTTP.get(URI("https://mrapiweb.ir/api/badword.php?#{text}")) result = JSON.parse(api) return result['isbadword'] == true end |
#notebook(text, savetofile = false, filename = nil) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/mrweb.rb', line 64 def notebook(text, savetofile = false, filename = nil) text = text.gsub(' ', '-') api = Net::HTTP.get(URI("https://mrapiweb.ir/api/notebook.php?text=#{text}")) if savetofile if filename.nil? raise Exception, 'Filename Is Required!' end File.open(filename, 'wb') do |mr| mr.write(api) end else return api end end |
#ocr(to, url) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/mrweb.rb', line 36 def ocr(to, url) api = Net::HTTP.get(URI("https://mrapiweb.ir/api/ocr.php?url=#{url}&lang=#{to}")) result = JSON.parse(api) begin return result['result'] rescue KeyError raise APIError, "Error In OCR Lang #{to}" end end |
#proxy ⇒ Object
117 118 119 120 121 |
# File 'lib/mrweb.rb', line 117 def proxy api = Net::HTTP.get(URI('https://mrapiweb.ir/api/telproxy.php')) proxy = JSON.parse(api) return proxy['connect'] end |
#qr(texturl, action = 'encode', savefile = true) ⇒ Object
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'lib/mrweb.rb', line 198 def qr(texturl, action = 'encode', savefile = true) if action == 'encode' text = "action=#{action}&text=#{texturl}" api = Net::HTTP.get(URI("https://mrapiweb.ir/api/qr/qrcode.php?#{text}")) if savefile File.open('qr.png', 'wb') do |f| f.write(api) end else return api end else text = "action=#{action}&url=#{texturl}" api = Net::HTTP.get(URI("https://mrapiweb.ir/api/qr/qrcode.php?#{text}")) return api end end |
#randbio ⇒ Object
53 54 55 |
# File 'lib/mrweb.rb', line 53 def randbio return Net::HTTP.get(URI('https://mrapiweb.ir/api/bio.php')) end |
#sendweb3(privatekey = nil, address = nil, amount = nil, rpc = nil, chainid = nil) ⇒ Object
140 141 142 143 |
# File 'lib/mrweb.rb', line 140 def sendweb3(privatekey = nil, address = nil, amount = nil, rpc = nil, chainid = nil) api = Net::HTTP.get(URI("https://mrapiweb.ir/api/wallet.php?key=#{privatekey}&address=#{address}&amount=#{amount}&rpc=#{rpc}&chainid=#{chainid}")) return api end |
#translate(to, text) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/mrweb.rb', line 25 def translate(to, text) parms = { 'to' => to, 'text' => text } api = Net::HTTP.get(URI("https://mrapiweb.ir/api/translate.php?#{URI.encode_www_form(parms)}")) result = JSON.parse(api) begin return result['translate'] rescue KeyError raise APIError, "Translate Error For Lang #{to}" end end |
#voicemaker(text, sayas = 'man', filename = nil) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/mrweb.rb', line 99 def voicemaker(text, sayas = 'man', filename = nil) text = text.gsub(' ', '-') api = Net::HTTP.get(URI("https://mrapiweb.ir/api/voice.php?sayas=#{sayas}&text=#{text}")) if filename.nil? raise Exception, 'Filename Is Required!' end File.open(filename, 'wb') do |mr| mr.write(api) end return true end |
#webshot(site, filesave) ⇒ Object
171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/mrweb.rb', line 171 def webshot(site, filesave) apikey = @apikey api1 = Net::HTTP.get(URI("https://mrapiweb.ir/api/webshot.php?key=#{apikey}&url=#{site}&fullSize=false&height=512&width=512")) begin File.open(filesave, 'wb') do |f| f.write(api1) end rescue return api1 end end |
#wikipedia(text) ⇒ Object
155 156 157 |
# File 'lib/mrweb.rb', line 155 def wikipedia(text) return Net::HTTP.get(URI("https://mrapiweb.ir/wikipedia/?find=#{text}&lang=fa")) end |
#worldclock ⇒ Object
131 132 133 |
# File 'lib/mrweb.rb', line 131 def worldclock return Net::HTTP.get(URI('https://mrapiweb.ir/api/zone.php')) end |
#youtube(vid) ⇒ Object
135 136 137 138 |
# File 'lib/mrweb.rb', line 135 def youtube(vid) api = Net::HTTP.get(URI("https://mrapiweb.ir/api/yt.php?key=#{@apikey}&id=#{vid}")) return api end |