Swiftpack.co - NozeIO/swift-nio-irc-server as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by NozeIO.
NozeIO/swift-nio-irc-server 0.7.0
A Internet Relay Chat (IRC) server for SwiftNIO
⭐️ 34
πŸ•“ 5 years ago
linux macOS iOS
.package(url: "https://github.com/NozeIO/swift-nio-irc-server.git", from: "0.7.0")

SwiftNIO IRC Server

Swift4 Swift5 macOS tuxOS Travis

SwiftNIO IRC is a Internet Relay Chat protocol implementation for SwiftNIO, a basis for building your own IRC servers and clients, a sample IRC server, as well as some IRC bots written in the Swift programming language.

SwiftNIO IRC Server is a framework to build IRC servers on top of SwiftNIO IRC.

Want to build a customer-support chat system? And your customers happen to be Unix people from the 80s and early 90s? What a great match!

This Swift package contains the reusable IRCServer module, and the MiniIRCd, a small and working IRC sample server.

MiniIRCd also configures, embeds and runs:

What it looks like

On the surface it is a very simple chat webapp, with basic support for channels and direct messages:

Sometimes a live demo installation is running on http://irc.noze.io/.

Apart from the web frontend, MiniIRCd also embeds an actual IRC server, that is, you can connect to the server using native clients like Mutter, Irssi or Textual.

Overview

The IRCServer module which is part of this package, only links against the NIOIRC protocol module of SwiftNIO IRC.

The included MiniIRCd tool on the other hand, also spins up the IRC/WebSocket gateway, includes the webapp and starts up the ElizaBot.

                             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                             β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
               HTML          β”‚ β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚       β”‚    Eliza     β”‚ β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€JS───────────┼─┼──│ NIO HTTP Server β”‚  β”‚       β”‚     Bot      β”‚ β”‚
        β”‚                    β”‚ β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
        β”‚                    β”‚ β”‚           β”‚           β”‚               β”‚        β”‚
        β–Ό                    β”‚ β”‚       Upgrades        β”‚              IRC       β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”             β”‚ β”‚      Connection       β”‚               β”‚        β”‚
β”‚              β”‚             β”‚ β”‚           β”‚           β”‚               β–Ό        β”‚
β”‚  WebBrowser  β”‚             β”‚ β”‚           β–Ό           β”‚       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚              β”‚  WebSocket  β”‚ β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚       β”‚              β”‚ β”‚
β”‚  JavaScript  │◀────JSON────┼─┼─▢│  NIO WebSocket  │◀─┼─IRC──▢│  IRC Server  β”‚ β”‚
β”‚    WebApp    β”‚             β”‚ β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚       β”‚              β”‚ β”‚
β”‚              β”‚             β”‚ β”‚       WebServer       β”‚       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜             β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                        β”‚
                             β”‚                                                  β”‚
                             β”‚       All Services Run as Part of MiniIRCd       β”‚
                             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Running the Server

To get started, just checkout the repository and call swift run:

helge@ZeaPro swift-nio-irc-server (develop)*$ swift  run
Fetching https://github.com/apple/swift-nio.git
...
Compile Swift Module 'miniircd' (2 sources)
Linking ./.build/x86_64-apple-macosx10.10/debug/miniircd
 __  __ _       _ _____ _____   _____
 |  \/  (_)     (_)_   _|  __ \ / ____|   Swift IRCd
 | \  / |_ _ __  _  | | | |__) | |
 | |\/| | | '_ \| | | | |  _  /| |        Port: 6667
 | |  | | | | | | |_| |_| | \ \| |____    PID:  2343
 |_|  |_|_|_| |_|_|_____|_|  \_\\_____|

Ready to accept connections on: [IPv4]0.0.0.0:6667
IRCWebClientServer running on: [IPv4]0.0.0.0:1337
Eliza is ready and listening!

You can then connect via IRC on localhost:6667 or to the web frontend on http://localhost:1337/.

Importing the module using Swift Package Manager

An example Package.swift importing the necessary modules:

// swift-tools-version:5.0

import PackageDescription

let package = Package(
    name: "MyOwnIRCServer",
    dependencies: [
        .package(url: "https://github.com/NozeIO/swift-nio-irc-server.git",
                 from: "0.5.0")
    ],
    targets: [
        .target(name: "MyOwnIRCServer",
                dependencies: [ "IRCServer" ])
    ]
)

Who

Brought to you by ZeeZide. We like feedback, GitHub stars, cool contract work, presumably any form of praise you can think of.

NIOIRC is a SwiftNIO port of the Noze.io miniirc example from 2016.

GitHub

link
Stars: 34
Last commit: 5 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

Separate Setups
5 years ago

The IRC client lib was moved to a standalone package to not spam the protocol implementation. This server version uses just that protocol implementation over from SwiftNIOExtras.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics