minor changes
This commit is contained in:
		
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -4,3 +4,4 @@ console.lua | ||||
| *.json | ||||
| plugins/owm.lua | ||||
| plugins/liberblock.lua | ||||
| plugins/dgmp.lua | ||||
|   | ||||
							
								
								
									
										4
									
								
								bot.lua
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								bot.lua
									
									
									
									
									
								
							| @@ -15,7 +15,7 @@ function on_msg_receive(msg) | ||||
|  | ||||
| 	msg = process_msg(msg) | ||||
|  | ||||
| 	if msg.date < os.time() - 5 then return end -- don't react to old messages | ||||
| 	if msg.date < os.time() - 10 then return end -- don't react to old messages | ||||
| 	if not msg.text then return end -- don't react to media messages | ||||
| 	if msg.forward_from then return end -- don't react to forwarded messages | ||||
|  | ||||
| @@ -27,7 +27,7 @@ function on_msg_receive(msg) | ||||
| 				counter[msg.from.id] = counter[msg.from.id] + 1 | ||||
| 				print(msg.from.first_name, msg.from.id, counter[msg.from.id]) | ||||
| 				if v.typing then | ||||
| 					send_chat_action(msg.from.id, 'typing') | ||||
| 					send_chat_action(msg.chat.id, 'typing') | ||||
| 				end | ||||
| 				local a,b = pcall(function() -- Janky error handling | ||||
| 					v.action(msg) | ||||
|   | ||||
							
								
								
									
										92
									
								
								plugins/dgmp.lua
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										92
									
								
								plugins/dgmp.lua
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,92 @@ | ||||
| local triggers = { | ||||
| 	'^/index', | ||||
| 	'^/listgroups' | ||||
| } | ||||
|  | ||||
| local dgmp_index = function(msg) | ||||
|  | ||||
| 	local dgmp = load_data('dgmp.json') | ||||
|  | ||||
| 	local input = get_input(msg.text) | ||||
| 	if not input then return end | ||||
|  | ||||
| 	input = JSON.decode(input) | ||||
| 	if not input then return end | ||||
|  | ||||
| 	local id = tostring(input.chatid) | ||||
|  | ||||
| 	if not dgmp[id] then | ||||
| 		dgmp[id] = {} | ||||
| 	end | ||||
| 	group = dgmp[id] | ||||
|  | ||||
| 	group.chatname = input.chatname | ||||
| 	if input.usercount then | ||||
| 		group.usercount = input.usercount | ||||
| 	end | ||||
| 	if input.description then | ||||
| 		group.description = input.description | ||||
| 	end | ||||
| 	if input.joininstructions then | ||||
| 		group.joininstructions = input.joininstructions | ||||
| 	end | ||||
|  | ||||
| 	save_data('dgmp.json', dgmp) | ||||
|  | ||||
| end | ||||
|  | ||||
| local dgmp_list = function(msg) | ||||
|  | ||||
| 	local dgmp = load_data('dgmp.json') | ||||
|  | ||||
| 	local input = get_input(msg.text) | ||||
| 	if not input then | ||||
| 		input = '' | ||||
| 	else | ||||
| 		input = string.lower(input) | ||||
| 	end | ||||
|  | ||||
| 	local output = '' | ||||
| 	for k,v in pairs(dgmp) do | ||||
| 		if string.find(string.lower(v.chatname), input) then | ||||
| 			output = output .. v.chatname .. ' (' .. k .. ')\n' | ||||
| 			if v.description then | ||||
| 				output = output .. v.description .. '\n' | ||||
| 			end | ||||
| 			if v.usercount then | ||||
| 				output = output .. 'Users: ' .. v.usercount .. '\n' | ||||
| 			end | ||||
| 			if v.joininstructions then | ||||
| 				output = output .. 'How to join: ' .. v.joininstructions .. '\n' | ||||
| 			end | ||||
| 			output = output .. '\n' | ||||
| 		end | ||||
| 	end | ||||
|  | ||||
| 	if string.len(output) > 4000 then | ||||
| 		output = 'List is too long! Please use a (better) search query.' | ||||
| 	end | ||||
|  | ||||
| 	output = trim_string(output) | ||||
| 	if string.len(output) == 0 then | ||||
| 		output = 'No results found.' | ||||
| 	end | ||||
|  | ||||
| 	send_msg(msg, output) | ||||
|  | ||||
| end | ||||
|  | ||||
| local action = function(msg) | ||||
|  | ||||
| 	if string.match(msg.text, '^/index') then | ||||
| 		dgmp_index(msg) | ||||
| 	elseif string.match(msg.text, '^/listgroups') then | ||||
| 		dgmp_list(msg) | ||||
| 	end | ||||
|  | ||||
| end | ||||
|  | ||||
| return { | ||||
| 	triggers = triggers, | ||||
| 	action = action | ||||
| } | ||||
| @@ -21,7 +21,7 @@ function PLUGIN.action(msg) | ||||
| 		end | ||||
| 	end | ||||
|  | ||||
| 	local url = 'http://www.imdbapi.com/?t=' .. URL.escape(input) | ||||
| 	local url = 'http://www.omdbapi.com/?t=' .. URL.escape(input) | ||||
| 	local jstr, res = HTTP.request(url) | ||||
| 	local jdat = JSON.decode(jstr) | ||||
|  | ||||
|   | ||||
| @@ -7,7 +7,8 @@ PLUGIN.doc = [[ | ||||
| ]] | ||||
|  | ||||
| PLUGIN.triggers = { | ||||
| 	'^/pun' | ||||
| 	'^/pun$', | ||||
| 	'^/pun@' | ||||
| } | ||||
|  | ||||
| PLUGIN.puns = { | ||||
|   | ||||
| @@ -8,7 +8,8 @@ local triggers = { | ||||
| 	['( ͡° ͜ʖ ͡°)'] = '/lenny$', | ||||
| 	['(╯°□°)╯︵ ┻━┻'] = '/flip$', | ||||
| 	['┌(┌ ^o^)┐'] = '/homo$', | ||||
| 	['ಠ_ಠ'] = '/look$' | ||||
| 	['ಠ_ಠ'] = '/look$', | ||||
| 	['SHOTS FIRED'] = '/shot$' | ||||
| } | ||||
|  | ||||
| local action = function(msg) | ||||
|   | ||||
| @@ -45,7 +45,7 @@ function PLUGIN.getSlap(slapper, victim) | ||||
| 		victim .. " was fragged by " .. slapper .. ".", | ||||
| 		victim .. " was desynchronized.", | ||||
| 		victim .. " was wasted.", | ||||
| 		victim .. " was busted by " .. slapper .. ".", | ||||
| 		victim .. " was busted.", | ||||
| 		victim .. "'s bones are scraped clean by the desolate wind.", | ||||
| 		victim .. " has died of dysentery.", | ||||
| 		victim .. " fainted.", | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 topkecleon
					topkecleon