-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathghoul.lua
More file actions
65 lines (49 loc) · 1.42 KB
/
ghoul.lua
File metadata and controls
65 lines (49 loc) · 1.42 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
--[[
Ghoul
Делает отсчет от 1000 до 7
by https://t.me/billy_fresko, https://t.me/wavecat
--]]
require "utils"
local preferences = inline:getDefaultSharedPreferences()
local context
local contextQuery
local speed
local counter
local result
function worker()
if counter > 7 then
result = result .. counter .. " - 7 = " .. (counter - 7) .. "\n"
contextQuery:answer(result)
counter = counter - 7
inline:getTimer():schedule(inline:timerTask(worker), speed)
end
end
local function watcher(input)
local text = input:getText()
if text ~= nil and text.toString ~= nil then
text = text:toString()
if text:sub(#text) == "." then
counter = 0
context:unregisterWatcher(watcher)
end
end
end
local function ghoul(_, query)
if query:getArgs() ~= "" then
preferences:edit():putInt("ghoul", tonumber(query:getArgs())):apply()
query:answer("Speed changed")
else
contextQuery = query
context:registerWatcher(watcher)
inline:toast "Counting started, to stop press «.»"
speed = preferences:getInt("ghoul", 100)
counter = 1000
result = ""
inline:getTimer():schedule(inline:timerTask(worker), speed)
end
end
return function(module)
module:setCategory "Ghoul"
module:registerCommand("ghoul", ghoul, "Starts the countdown")
context = module
end