-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathmain.lua
35 lines (30 loc) · 1.03 KB
/
main.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
local Device = require("device")
local InputContainer = require("ui/widget/container/inputcontainer")
local NetworkMgr = require("ui/network/manager")
local _ = require("gettext")
local showChatGPTDialog = require("dialogs")
local UpdateChecker = require("update_checker")
local AskGPT = InputContainer:new {
name = "askgpt",
is_doc_only = true,
}
-- Flag to ensure the update message is shown only once per session
local updateMessageShown = false
function AskGPT:init()
self.ui.highlight:addToHighlightDialog("askgpt_ChatGPT", function(_reader_highlight_instance)
return {
text = _("Ask ChatGPT"),
enabled = Device:hasClipboard(),
callback = function()
NetworkMgr:runWhenOnline(function()
if not updateMessageShown then
UpdateChecker.checkForUpdates()
updateMessageShown = true -- Set flag to true so it won't show again
end
showChatGPTDialog(self.ui, _reader_highlight_instance.selected_text.text)
end)
end,
}
end)
end
return AskGPT