Example code that shows how to use libtwirc
A simple bot that connects to Twitch IRC and joins a channel. The source is well-commented, check it out.
A simple client that connectes to Twitch IRC and outputs all incoming messages on the console. Reads user input and sends it to the IRC server.
A simple program that connects to a channel specified with -c #channel
and dumps all chat messages to stdout
. Optionally, a timestamp can be added with -t FORMAT
, for example -t "[%H:%M:%S]"
- Clone
twircclient
andlibtwirc
:
git clone https://github.com/domsson/twircclient
git clone https://github.com/domsson/libtwirc
- Build
libtwirc
with the providedbuild-shared
script. It will output the.so
and.h
file into thelib
subdirectory:
cd libtwirc
chmod +x build-shared
./build-shared
- Install
libtwirc
. This will vary depending on your distro and machine, as the include paths aren't the same for all. You'll have to look up where your distro wants shared library and header files. In any case, after copying the files to their appropriate directories, you should callldconfig
so that your system learns about the new library. For my amd64 Debian install, this does the trick (requires super user permissions):
cp lib/libtwirc.so /usr/lib/x86_64-linux-gnu/
cp lib/libtwirc.h /usr/include/
ldconfig -v -n /usr/lib
- Go over to the
twircclient
directory, create a token file and place your Twitch oauth token in there:
cd ../twircclient
touch token
echo "oauth:YOUR-TOKEN-HERE" > token
- Open
src/bot.c
orsrc/client.c
(depending on which one you want to run) and edit the#define
s to meet your needs:
#define NICK "your-twitch-username-here"
#define CHAN "#your-channel-here"
- Compile the bot and/or client and/or dumper:
chmod +x build-bot
chmod +x build-client
chmod +x build-dump
./build-bot
./build-client
./build-dump
- Run the bot and/or client and/or dumper:
./bin/bot
./bin/client
./bin/dump