baines / insobot

C99 modular IRC bot with markov chains
MIT License
74 stars 5 forks source link

IPC peer discovery #7

Open baines opened 7 years ago

baines commented 7 years ago

The IPC system allows an ID to be specified in send_ipc (which is actually the corresponding insobot pid), but there is no easy way to discover which ID represents which IRC server.

For example, we might want to send an IPC message only to the insobot instance connected to twitch, but we cannot easily figure out which ID to use for that.

Some parts of the code are already using a INSOBOT_ID envvar — this should be loaded in ipc_init in insobot.c, and then broadcast to all peers using a specific "init" message, along with our pid.

Each insobot instance can then keep a mapping of textual ID to pid, and we can introduce an ipc_getid style function to IRCCoreCtx that returns the numeric ID given a textual ID like "twitch", for use in send_ipc.