diff options
| author | ubq323 <ubq323@ubq323.website> | 2025-02-25 23:43:41 +0000 |
|---|---|---|
| committer | ubq323 <ubq323@ubq323.website> | 2025-02-25 23:43:41 +0000 |
| commit | 4dec20e4ff11b61be57a6cfbdb289327d9e1eb7d (patch) | |
| tree | cc2ffe0357c1110236270ad46dc2006cdb01bf89 /rirc.lua | |
| parent | e03937bbe51f3dd8e0d8ecc732999f5c4578fa94 (diff) | |
the Restructuring
Diffstat (limited to 'rirc.lua')
| -rw-r--r-- | rirc.lua | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/rirc.lua b/rirc.lua deleted file mode 100644 index 0508351..0000000 --- a/rirc.lua +++ /dev/null @@ -1,61 +0,0 @@ -local irc = {} - -function irc.sendmsg(conn, ch, msg) - local m = msg:gsub("[\r\n]+"," ") - local l = 512-12-#ch - m = m:sub(1,l) - conn:send("PRIVMSG "..ch.." :"..m.."\r\n") -end - -function irc.send(sock, args) - local out = '' - if args.source then - out = ':' .. args.source .. ' ' - end - for i = 1, #args-1 do - local arg = tostring(args[i]) - out = out .. arg:gsub("[\r\n ]+","") .. ' ' - end - local last = tostring(args[#args]):gsub("[\r\n]+"," ") - out = out .. ':' .. last - sock:write(out..'\r\n') - return out -end - -function irc.parse(line) - local words = {} - local idx = 1 - while true do - local word,nidx = line:match("(%g+)%s*()",idx) - if not word then - break - elseif word:sub(1,1) == ":" and idx ~= 1 then - -- first word can start with : - local rest = line:sub(idx+1) - table.insert(words,rest) - break - else - table.insert(words,word) - idx = nidx - end - end - - local from = nil - if words[1] and words[1]:sub(1,1) == ":" then - -- we have a source - from = table.remove(words,1):sub(2) - end - - local op = words[1] - local args = {} - for i=2,#words do - args[i-1] = words[i] - end - return {source=from,op=op:upper(),args=args} -end - -function irc.parse_src(src) - return src:match"^(.*)!(.*)@(.*)$" -end - -return irc |
