bug fixes

This commit is contained in:
mcneb10 2024-06-24 17:03:12 -05:00
parent 65d6da15b3
commit 9160bb808e
3 changed files with 41 additions and 7 deletions

View file

@ -14,7 +14,8 @@ config = {
]]-- ]]--
prefered_website_medium = "clearnet", prefered_website_medium = "clearnet",
-- Choose random frontend instead of fallback one, will force clearnet -- Choose random frontend instead of fallback one, will force clearnet
random_frontend = true, --random_frontend = true,
random_frontend = false,
-- Reply using XEP-0461 instead of just quoting -- Reply using XEP-0461 instead of just quoting
use_reply_xep = true, use_reply_xep = true,
-- List of desired frontends to extract from `services.json` -- List of desired frontends to extract from `services.json`
@ -29,9 +30,12 @@ config = {
["instagram[.]com"] = { ["instagram[.]com"] = {
frontends = { "proxigram" } frontends = { "proxigram" }
}, },
["github[.]com"] = { ["www[.]instagram[.]com"] = {
frontends = { "gothub" } frontends = { "proxigram" }
}, },
--[[["github[.]com"] = {
frontends = { "gothub" }
},]]--
["google[.]com"] = { ["google[.]com"] = {
frontends = { "searxng" } frontends = { "searxng" }
}, },

View file

@ -35,9 +35,22 @@ client:hook("ready", function()
room:hook("message", function(event) room:hook("message", function(event)
if event.stanza.attr.type == "groupchat" if event.stanza.attr.type == "groupchat"
and not string.find(event.stanza.attr.from, "/" .. config.name) and not string.find(event.stanza.attr.from, "/" .. config.name)
and not event.stanza:get_child("delay", "urn:xmpp:delay") then and not event.stanza:get_child("delay", "urn:xmpp:delay")
and not string.find(event.stanza.attr.from, "Bot") -- This is here because of the Thumbnail bot incident
then
local body = event.stanza:get_child_text("body") local body = event.stanza:get_child_text("body")
if body then if body then
if event.stanza:get_child("reply", 'urn:xmpp:reply:0') then
local fallback = event.stanza:get_child("fallback", 'urn:xmpp:fallback:0')
if fallback then
local fallback_body = fallback:child_with_name("body")
if fallback_body then
body = string.sub(body, fallback_body.attr["end"])
end
end
else
body = string.gsub(body, ">[^\n\r]-[\n\r]+", "")
end
for site, services in pairs(config.sites) do for site, services in pairs(config.sites) do
local instance = choose_instance(services) local instance = choose_instance(services)
for match in string.gmatch(body, string.format("%%s(%s/%%S+)", site)) do for match in string.gmatch(body, string.format("%%s(%s/%%S+)", site)) do

View file

@ -42,7 +42,8 @@ function read_all_text(file)
end end
function send_reply_link(room, match, site, instance, event) function send_reply_link(room, match, site, instance, event)
local msg = string.format("> %s\nPrivate frontend: %s", match, string.gsub(match, site, instance)) --local msg = string.format("> %s\nPrivate frontend: %s", match, string.gsub(match, site, instance))
local msg = string.format("Private frontend: %s", string.gsub(match, site, instance))
if config.use_reply_xep then if config.use_reply_xep then
room:send(verse.message() room:send(verse.message()
-- Set message text -- Set message text
@ -51,8 +52,24 @@ function send_reply_link(room, match, site, instance, event)
:tag("reply", { :tag("reply", {
xmlns = 'urn:xmpp:reply:0', xmlns = 'urn:xmpp:reply:0',
to = event.stanza.attr.from, to = event.stanza.attr.from,
id = event.stanza.attr.id, id = event.stanza:get_child("stanza-id", "urn:xmpp:sid:0").attr.id,
})) }):up()
--[[Add fallback
:tag("fallback", {
["xmlns"] = 'urn:xmpp:feature-fallback:0',
["for"] = 'urn:xmpp:reply:0',
})
:tag("body", {
["start"] = 0,
["end"] = string.len(match) + 2
}):up():up()
]]--
-- Idk what this does, but it's in gajim's replies
:tag("markable", {
xmlns = "urn:xmpp:chat-markers:0"
})
)
else else
room:send_message(msg) room:send_message(msg)
end end