Skip to content

Commit

Permalink
Small fixes, fix error report message, fix blank renderer defer text
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyrth committed Apr 2, 2023
1 parent 30e9ac9 commit 29681c2
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 7 deletions.
36 changes: 31 additions & 5 deletions libs/ctlogins.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,49 @@ local CtLib = require 'CtLib'

local acs = {}
do
---@type string
local s = process.env.CtLogins
assert(s and #s > 0, "CtLogins env var not specified.")
local i = 0
for d, a, b in s:gmatch('(%S+)%s+(%S+)%s+(%S+)%s+') do
acs[i] = {a = a, b = b, d = d}
for d, a, b, u in s:gmatch('(%S+)[^\n%S]+(%S+)[^\n%S]+(%S+)[^\n%S]+(%S+)[^\n%S]-\n') do
acs[i] = {a = a, b = b, d = d, u = u}
i = i + 1
end
end

---@type CtLib[]
local logins = {}

local function setupAcc(n)
assert(acs[n], "n beyond number of available accounts.")
local acc = CtLib.login(acs[n].a, acs[n].b)
acc:updateDisplayName(acs[n].u)
acc:setPlayerAllData {
Setup = {
Custo = {},
ClassID = 'CL03',
IconID = 'PI011',
FanionID = 'FA004',
TitleId = 'PT064',
WallID = 'WP003',
}
}
return acc
end

---@return CtLib
function logins.getMain()
logins[0] = logins[0] or CtLib.login(acs[0].a, acs[0].b)
return logins[0]
function logins.getAcc(n)
if not n then n = 1 end
assert(type(n) == 'number' and n >= 0 and n % 1 == 0, "n must be a valid positive integer")
if not logins[n] then
logins[n] = setupAcc(n)
end
return logins[n]
end

---@return CtLib
function logins.getMain()
return logins.getAcc(0)
end

return logins
1 change: 1 addition & 0 deletions libs/renderer/defer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ function SvgTextGen:generate(outPath, maxWidth, maxHeight)
svgCache[self.name] = {tag = tag, stroke = att.stroke and {color = {col2Rgb(att.stroke)}, width = tonumber(att['stroke-width']) or 1}}
end

if self.text:match('^%s*$') then self.text = '-' end
local text = vips.Image.text(svgCache[self.name].tag..self.text..'</span>', {rgba = true, dpi = 75})

local fac = math.min(maxWidth and (maxWidth/text:width()) or 1, maxHeight and (maxHeight/text:height()) or 1, 1)
Expand Down
2 changes: 1 addition & 1 deletion libs/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ end

---@param client Client
function util.sendErrorToOwner(client, err)
client:getUser('368727799189733376'):send(("An error has occured! ```\n%s\n```"):format(err:sub(1900)))
client:getUser('368727799189733376'):send(("An error has occured! ```\n%s\n```"):format(err:sub(1, 1900)))
end

function util.patternEscape(str)
Expand Down
2 changes: 1 addition & 1 deletion package.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
return {
name = "Lyrth/StormraiserBot",
version = "1.4.0",
version = "1.4.1",
description = "Stormraiser bot for the official Century: Age of Ashes server.",
license = "GNU General Public License v3.0",
author = { name = "Lyrthras", email = "me[at]lyr.pw" },
Expand Down

0 comments on commit 29681c2

Please sign in to comment.