xkcd.lua: Removed needless require.

administration.lua: Easier for users to get command list.
nick.lua: Swap newlines for spaces.
lastfm.lua: Someone was tired writing this.
utilities.lua: Remove needless console output.
This commit is contained in:
topkecleon 2016-05-10 15:49:05 -04:00
parent c8e8be144f
commit 24892a9537
5 changed files with 12 additions and 12 deletions

View File

@ -1,6 +1,6 @@
--[[ --[[
administration.lua administration.lua
Version 1.8.2 Version 1.8.3
Part of the otouto project. Part of the otouto project.
© 2016 topkecleon <drew@otou.to> © 2016 topkecleon <drew@otou.to>
GNU General Public License, version 2 GNU General Public License, version 2
@ -26,6 +26,8 @@
1.8.2 - Will now attempt to unban users kicked from supergroups. Other small 1.8.2 - Will now attempt to unban users kicked from supergroups. Other small
changes. changes.
1.8.3 - Migrated to new plugin standard. Added /ahelp command to /desc.
]]-- ]]--
local JSON = require('dkjson') local JSON = require('dkjson')
@ -222,6 +224,7 @@ function administration:get_desc(chat_id)
if modstring ~= '' then if modstring ~= '' then
table.insert(t, '*Moderators:*\n' .. utilities.trim(modstring)) table.insert(t, '*Moderators:*\n' .. utilities.trim(modstring))
end end
table.insert(t, 'Run /ahelp@' .. self.info.username .. ' for a list of commands.')
return table.concat(t, '\n\n') return table.concat(t, '\n\n')
end end

View File

@ -16,8 +16,8 @@ function lastfm:init()
lastfm.triggers = utilities.triggers(self.info.username):t('lastfm', true):t('np', true):t('fmset', true).table lastfm.triggers = utilities.triggers(self.info.username):t('lastfm', true):t('np', true):t('fmset', true).table
end end
bindings.command = 'lastfm' lastfm.command = 'lastfm'
bindings.doc = [[``` lastfm.doc = [[```
/np [username] /np [username]
Returns what you are or were last listening to. If you specify a username, info will be returned for that username. Returns what you are or were last listening to. If you specify a username, info will be returned for that username.

View File

@ -40,6 +40,7 @@ function nick:action(msg)
self.database.users[target.id_str].nickname = nil self.database.users[target.id_str].nickname = nil
output = target.name .. '\'s nickname has been deleted.' output = target.name .. '\'s nickname has been deleted.'
else else
input = input:gsub('\n', ' ')
self.database.users[target.id_str].nickname = input self.database.users[target.id_str].nickname = input
output = target.name .. '\'s nickname has been set to "' .. input .. '".' output = target.name .. '\'s nickname has been set to "' .. input .. '".'
end end

View File

@ -1,7 +1,6 @@
local xkcd = {} local xkcd = {}
local HTTP = require('socket.http') local HTTP = require('socket.http')
local HTTPS = require('ssl.https')
local URL = require('socket.url') local URL = require('socket.url')
local JSON = require('dkjson') local JSON = require('dkjson')
local bindings = require('bindings') local bindings = require('bindings')
@ -29,7 +28,10 @@ function xkcd:action(msg)
local input = utilities.input(msg.text) local input = utilities.input(msg.text)
if input then if input then
if tonumber(input) then if input == '404' then
bindings.sendMessage(self, msg.chat.id, '*404*\nNot found.', false, nil, true)
return
elseif tonumber(input) then
if tonumber(input) > latest then if tonumber(input) > latest then
strip_num = latest strip_num = latest
else else
@ -49,7 +51,7 @@ function xkcd:action(msg)
end end
local jdat = JSON.decode(jstr) local jdat = JSON.decode(jstr)
local output = '[' .. jdat.num .. '](' .. jdat.img .. ')\n' .. jdat.alt local output = '*' .. jdat.safe_title .. '* ([' .. jdat.num .. '](' .. jdat.img .. '))\n' .. jdat.alt
bindings.sendMessage(self, msg.chat.id, output, false, nil, true) bindings.sendMessage(self, msg.chat.id, output, false, nil, true)

View File

@ -88,7 +88,6 @@ end
-- Loads a JSON file as a table. -- Loads a JSON file as a table.
function utilities.load_data(filename) function utilities.load_data(filename)
local f = io.open(filename) local f = io.open(filename)
if not f then if not f then
return {} return {}
@ -96,19 +95,15 @@ function utilities.load_data(filename)
local s = f:read('*all') local s = f:read('*all')
f:close() f:close()
local data = JSON.decode(s) local data = JSON.decode(s)
return data return data
end end
-- Saves a table to a JSON file. -- Saves a table to a JSON file.
function utilities.save_data(filename, data) function utilities.save_data(filename, data)
local s = JSON.encode(data) local s = JSON.encode(data)
local f = io.open(filename, 'w') local f = io.open(filename, 'w')
f:write(s) f:write(s)
f:close() f:close()
end end
-- Gets coordinates for a location. Used by gMaps.lua, time.lua, weather.lua. -- Gets coordinates for a location. Used by gMaps.lua, time.lua, weather.lua.
@ -169,7 +164,6 @@ function utilities:user_from_message(msg)
local input = utilities.input(msg.text_lower) local input = utilities.input(msg.text_lower)
local target = {} local target = {}
if msg.reply_to_message then if msg.reply_to_message then
print('reply')
target = msg.reply_to_message.from target = msg.reply_to_message.from
elseif input and tonumber(input) then elseif input and tonumber(input) then
target.id = tonumber(input) target.id = tonumber(input)