view lib/dcc @ 11967:4fc0813bfe9a draft

<oerjan> addquote <kspalaiologos> I have made a chess engine in Malbolge <kspalaiologos> in theory it\'s decent <kspalaiologos> but it has two drawbacks <kspalaiologos> a) It requires 31 and a half gigabytes of memory <kspalaiologos> b) it\'s quicker to count atoms in universe than to run it
author HackEso <hackeso@esolangs.org>
date Sun, 13 Oct 2019 01:41:26 +0000
parents 859f9b4339e6
children
line wrap: on
line source

#!/bin/bash

# Configuration:

# IP of the host, must be in the stupid long integer form
DCC_IP="1077849409"

# Port range
DCC_PORT_MIN="10000"
DCC_PORT_RANGE="100"

# Library:

# Get a DCC port
dcc_port() {
    echo $(( DCC_PORT_MIN + (RANDOM % DCC_PORT_RANGE) ))
}

# Start a DCC chat to $1
dcc_chat() {
    DCC_PORT=`dcc_port`
    (
        sleep 1
        echo -e 'PRIVMSG '$1' :\x01DCC CHAT chat '$DCC_IP' '$DCC_PORT'\x01' |
            socat STDIN UNIX-SENDTO:$IRC_SOCK
    ) &
    socat -T30 - TCP4-LISTEN:$DCC_PORT,crnl
}

# Start a DCC SEND of $2 to $1
dcc_send() {
    DCC_PORT=`dcc_port`
    (
        sleep 1
        echo -e 'PRIVMSG '$1' :\x01DCC SEND '$2' '$DCC_IP' '$DCC_PORT'\x01' |
            socat STDIN UNIX-SENDTO:$IRC_SOCK
    ) &
    socat -T30 - TCP4-LISTEN:$DCC_PORT
}