Last active
September 27, 2022 02:12
-
-
Save xorgnak/7481117 to your computer and use it in GitHub Desktop.
A simple irc bot for suckless' ii irc client. Enjoy.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
#-------------------------------------------------------------------------------# | |
# FUNNELBOT!!! - a whole bunch of fun in a terminal. | |
#---------------------------------------+---------------------------------------# | |
############################################################# # | |
######################################### # | |
##################### # | |
########### # | |
##### (C)2013 [email protected] (cc) by E. Leonard # | |
#--------------------------------------------------------------[ ]--# | |
#-------------------+-----------------------------------------------------------# | |
#--[ ]--------------------------------------------------------------# | |
#-----------------------------------------------------------+-------------------# | |
#----------------------------------------------------------------------[ WHY ]--# | |
# Because I need to push multiple irc channels to a single display screen so | |
# everyone in out office can stay in the loop. It's also handy to keep an eye | |
# on multiple channels for app backend monitoring. Use it if you like. | |
#----------------------------------------------------------------------[ HOW ]--# | |
# Below, we configure a nick, server, and channels as sources and a file as a | |
# destination. We then tail the output of each channel and reformat it's | |
# output for out pool file. Tailing the pool locally is provided only for | |
# monitoring. The pool is supposed to be further processed by other tools | |
# (grep, sed, awk). | |
#--------------------------------------------------------------------[ USAGE ]--# | |
# 1. configure this file accordingly. | |
# 2. usage: ./ii.sh <nick> | |
# 3. watch. | |
# *4. maybe do something with the pool output later. | |
DIR=~/.irc | |
NICK=$1 | |
SERVER='chat.freenode.net' | |
CHANNELS='#h0mbr3 #news #weather-us-tn' | |
POOL=~/pool | |
MSG="I'm using a simple bot to compile traffic from a few freenode channels. If you'd like to try it, download my gist at https://gist.github.com/xorgnak/7481117 OH! and if you try my script, don't be a dick with it. :-)" | |
:> $DIR/$SERVER/out; | |
tail -f $DIR/$SERVER/out & | |
tail -f $POOL & | |
while true; do | |
ii -i $DIR -s $SERVER -n $NICK & | |
echo "##### connected to $SERVER." | |
iipid="$!" | |
sleep 5 | |
for c in $CHANNELS; do | |
echo "/j $c" > $DIR/$SERVER/in | |
:> $DIR/$SERVER/$c/out | |
tail -f $DIR/$SERVER/$c/out | while read -r date time nick mesg; do | |
nick="${nick#<}" | |
nick="${nick%>}" | |
echo "[ $date $time ] [ $c ] [ $nick ] $mesg" >> $POOL | |
done > /dev/null & | |
echo "$MSG" > $DIR/$SERVER/$c/in | |
echo "###### JOINED $c" | |
sleep 1 | |
done | |
wait "$iipid" | |
done & |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment