Merge pull request #41 from bb010g/patch-3
Increase reliability of Wikipedia
This commit is contained in:
		@@ -43,10 +43,11 @@ local action = function(msg)
 | 
				
			|||||||
		return
 | 
							return
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
--
 | 
					--
 | 
				
			||||||
	local url = URL.unescape(jdat.responseData.results[1].url)
 | 
						local url = jdat.responseData.results[1].unescapedUrl
 | 
				
			||||||
	local title = jdat.responseData.results[1].titleNoFormatting:gsub(' %- Wikipedia, the free encyclopedia', '')
 | 
						local title = jdat.responseData.results[1].titleNoFormatting:gsub(' %- Wikipedia, the free encyclopedia', '')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	jstr, res = HTTPS.request(wurl .. URL.escape(title))
 | 
						-- 'https://en.wikipedia.org/wiki/':len ≡ 30
 | 
				
			||||||
 | 
						jstr, res = HTTPS.request(wurl .. url:sub(31))
 | 
				
			||||||
	if res ~= 200 then
 | 
						if res ~= 200 then
 | 
				
			||||||
		sendReply(msg, config.error.connection)
 | 
							sendReply(msg, config.error.connection)
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
@@ -71,7 +72,8 @@ local action = function(msg)
 | 
				
			|||||||
	title = title:gsub('%(.+%)', '')
 | 
						title = title:gsub('%(.+%)', '')
 | 
				
			||||||
	--local output = '[' .. title .. '](' .. url .. ')\n' .. text:gsub('%[.+]%','')
 | 
						--local output = '[' .. title .. '](' .. url .. ')\n' .. text:gsub('%[.+]%','')
 | 
				
			||||||
	--local output = '*' .. title .. '*\n' .. text:gsub('%[.+]%','') .. '\n[Read more.](' .. url .. ')'
 | 
						--local output = '*' .. title .. '*\n' .. text:gsub('%[.+]%','') .. '\n[Read more.](' .. url .. ')'
 | 
				
			||||||
	local output = text:gsub('%[.+%]',''):gsub(title, '*'..title..'*') .. '\n'
 | 
						local esctitle = title:gsub("[%^$()%%.%[%]*+%-?]","%%%1")
 | 
				
			||||||
 | 
						local output = text:gsub('%[.+%]',''):gsub(esctitle, '*%1*') .. '\n'
 | 
				
			||||||
	if url:find('%(') then
 | 
						if url:find('%(') then
 | 
				
			||||||
		output = output .. url:gsub('_', '\\_')
 | 
							output = output .. url:gsub('_', '\\_')
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user