-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.lua
More file actions
39 lines (30 loc) · 994 Bytes
/
bot.lua
File metadata and controls
39 lines (30 loc) · 994 Bytes
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
local socket = require("socket")
local config = require("config")
local commands = require("commands")
local secrets = require("secrets") -- Loads the sensitive table
local client = socket.tcp()
client:settimeout(0.5)
local ok, err = client:connect(config.server, config.port)
if not ok then
print("Failed to connect: " .. err)
os.exit()
end
-- Login
client:send("PASS " .. secrets.pass .. "\r\n")
client:send("NICK " .. config.nick .. "\r\n")
client:send("CAP REQ :twitch.tv/tags\r\n")
client:send("JOIN " .. config.chan .. "\r\n")
print("Bot is live on CachyOS! Dynamic modules loaded.")
while true do
local line, err = client:receive()
-- 1. Pulse the timer check every loop (roughly every 0.5s)
commands.check_timers(client, config)
if not line then
if err == "timeout" then goto continue end
break
end
-- 2. Process chat messages normally
if line:match("^PING") then client:send("PONG :tmi.twitch.tv\r\n") end
commands.handle(line, client, config)
::continue::
end