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
Version 1.8.2
Version 1.8.3
Part of the otouto project.
© 2016 topkecleon <drew@otou.to>
GNU General Public License, version 2
@ -26,6 +26,8 @@
1.8.2 - Will now attempt to unban users kicked from supergroups. Other small
changes.
1.8.3 - Migrated to new plugin standard. Added /ahelp command to /desc.
]]--
local JSON = require('dkjson')
@ -222,6 +224,7 @@ function administration:get_desc(chat_id)
if modstring ~= '' then
table.insert(t, '*Moderators:*\n' .. utilities.trim(modstring))
end
table.insert(t, 'Run /ahelp@' .. self.info.username .. ' for a list of commands.')
return table.concat(t, '\n\n')
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
end
bindings.command = 'lastfm'
bindings.doc = [[```
lastfm.command = 'lastfm'
lastfm.doc = [[```
/np [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
output = target.name .. '\'s nickname has been deleted.'
else
input = input:gsub('\n', ' ')
self.database.users[target.id_str].nickname = input
output = target.name .. '\'s nickname has been set to "' .. input .. '".'
end

View File

@ -1,7 +1,6 @@
local xkcd = {}
local HTTP = require('socket.http')
local HTTPS = require('ssl.https')
local URL = require('socket.url')
local JSON = require('dkjson')
local bindings = require('bindings')
@ -29,7 +28,10 @@ function xkcd:action(msg)
local input = utilities.input(msg.text)
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
strip_num = latest
else
@ -49,7 +51,7 @@ function xkcd:action(msg)
end
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)

View File

@ -88,7 +88,6 @@ end
-- Loads a JSON file as a table.
function utilities.load_data(filename)
local f = io.open(filename)
if not f then
return {}
@ -96,19 +95,15 @@ function utilities.load_data(filename)
local s = f:read('*all')
f:close()
local data = JSON.decode(s)
return data
end
-- Saves a table to a JSON file.
function utilities.save_data(filename, data)
local s = JSON.encode(data)
local f = io.open(filename, 'w')
f:write(s)
f:close()
end
-- 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 target = {}
if msg.reply_to_message then
print('reply')
target = msg.reply_to_message.from
elseif input and tonumber(input) then
target.id = tonumber(input)