This program enables you to make servers useful like IRL web servers.
Client Minimum requirements
relay
network card
internet card
apu
Server Minimum Requirements;
Wireless network card
Configured serverside program
Put your paste code in the server program or else it will say Hello.
I did this cause nobody else had and I thought it would be useful
Server paste code: B7b27pc2
Browser paste code: vkL422Sz
I am new to OC and this is my first program
There was no IRC library for OpenComputers, so I've made one. Here's a demo bot that uses it:
local com = require("component")
local event = require("event")
local thread = require("thread")
local gpu = com.gpu
local irc = require("irc")
local events = irc.events
local env = setmetatable({
irc = irc,
events = events,
}, {__index = _G})
local client = irc.builder()
:connection {
host = "irc.esper.net:6667",
throttling = {
maxDelay = 2,
maxThroughput = 5,
},
}
:auth {
nickname = "oc-finger-irc",
username = "fingercomp",
realname = "OpenComputers IRC client library",
}
:bot {
channels = {"#oc-finger-irc"},
tracking = {
users = true,
modes = true,
account = true,
userInfo = true,
},
}
:execution {
threaded = true,
reconnect = true,
catchErrors = true,
}
:subscribe(events.irc.command, events.priority.high, function(self, client, evt)
gpu.setForeground(0x00ff00)
print("→ " .. evt.rawLine)
gpu.setForeground(0xffffff)
end)
:subscribe(events.irc.write, events.priority.normal, function(self, client, evt)
gpu.setForeground(0x00dbff)
print("← " .. evt.line:gsub("[\r\n]*$", ""))
gpu.setForeground(0xffffff)
end)
:subscribe(events.irc.message, irc.events.priority.normal, function(self, client, evt)
if evt.source.nickname == "fingercomp" then
if evt.message == "::quit" then
evt:reply("Quitting.")
evt.client:stop(("%s told me to quit."):format(evt.source.nickname))
elseif evt.message == "::spam" then
evt:reply("1")
evt:reply("2")
evt:reply("3")
evt:reply("4")
evt:reply("5")
elseif evt.message == "::longmsg" then
local msg = {}
for i = 1, 256 do
if i == 128 then
table.insert(msg, tostring(i) .. " ")
else
table.insert(msg, tostring(i))
end
end
evt:reply(table.concat(msg))
elseif evt.message == "::error" then
(nil).test()
elseif evt.message:sub(1, #"::exec ") == "::exec " then
local code = evt.message:sub(#"::exec " + 1)
local chunk, reason = load("return " .. code, "=irc", "t", env)
if not chunk then
chunk, reason = load(code, "=irc", "t", env)
end
if not chunk then
evt:reply(("\x0304Error:\x0f %s"):format(reason))
else
local result = table.pack(xpcall(chunk, debug.traceback))
local success = table.remove(result, 1)
result.n = result.n - 1
for i = 1, result.n, 1 do
if type(result) ~= "string" and type(result) ~= "number" and
type(result) ~= "boolean" and type(result) ~= "nil" then
result[i] = tostring(result[i])
else
result[i] = ("%q"):format(result[i]):gsub("\\\n", "\n")
end
end
if not success then
evt:reply(("\x0304Error:\x0f %s"):format(result[1]:match("^[^\n]*")))
io.stderr:write(("%s\r\n"):format(result[1]))
elseif result.n > 0 then
evt:reply(table.concat(result, " ", i, result.n))
else
evt:reply("\x0309Success")
end
end
end
end
end)
:subscribe(events.irc.ctcpRequest, irc.events.priority.normal, function(self, client, evt)
if evt.ctcpCommand == "TIME" then
evt:reply(os.date("%F %T"))
end
end)
:subscribe(events.client.error, irc.events.priority.top, function(self, client, evt)
print("Caught: " .. evt.traceback)
evt:cancel()
end)
:build()
local t = thread.create(function()
repeat
local evt = event.pull("interrupted")
until evt
end)
env.client = client
client:run()
thread.waitForAny({t, client.thread})
client:stop("Quitting.")
os.exit()
I don't want to brag about it too much, but I think the code is pretty.
Features
Threaded execution.
A nice API.
IRCv3.2 capability negotiation.
Throttling to prevent the bot from triggering anti-flood mechanisms.
Tracks channel members, modes, nick changes, account names, etc.
Automatically reconnects if it's disconnected from the IRC server.
Splits long messages over multiple lines.
The event bus can use coroutines as message handlers.
Links
The GitLab repository: https://gitlab.com/cc-ru/irc-oc
Documentation: https://gitlab.com/cc-ru/irc-oc/-/wikis/home
Demo programs: https://gitlab.com/cc-ru/irc-oc/snippets
MineOS is a GUI based operating system for the OpenComputers Minecraft mod. It has extensive customisation abilities as well as an app market to publish your creations among the OS community. For developers there is wonderful illustrated wiki with lots of code examples. List of main features:
Multitasking
Double buffered graphical user interface
Language packs and software localization
Multiple user profiles with password authentication
Own EEPROM firmware with boot volume choose/format/rename features and Internet Recovery mode
File sharing over the local network via modems
Client connections to real FTP servers
An internal IDE with syntax highlighting and debugger
Integrated application and library App Market with the ability to publish your own scripts and programs for every MineOS user
Error reporting system with the possibility to send information to developers
Animations, wallpapers, screensavers, color schemes and huge customization possibilities
Open source system API and detailed documentation
How to install?
The easiest way is to use default OpenOS wget script. Insert an OpenOS floppy disk to computer, insert an Internet Card, turn computer on and type the following command to install MineOS. You can use middle mouse button or insert key to paste it from cliboard:
wget -f https://raw.githubusercontent.com/IgorTimofeev/MineOS/master/Installer/BIOS.lua /tmp/bios.lua && flash -q /tmp/bios.lua && reboot
System requirements:
OpenOS installed on Tier 3 HDD
Internet Card
Tier 3 GPU
2x Tier 3 RAM
Tier 3 CPU
Wiki:
https://github.com/IgorTimofeev/MineOS/wiki