Last active
June 21, 2023 14:49
-
-
Save izabera/345327710e70c10c4e45 to your computer and use it in GitHub Desktop.
a simple irc bot written in sed
This file contains 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
#!/bin/bash | |
owner=izabera nick=sedirc network=irc.freenode.net | |
echo " | |
# send bot data | |
1 { | |
s/.*/nick $nick/p | |
s/.*/user $nick $nick $nick :$nick/p | |
s/.*/cat factoids 2>\/dev\/null/e; H | |
b | |
} | |
# reply to pings | |
/^PING/ { s/I/O/p; b } | |
# !learn a b | |
/^:\([^!]*\)![^ ]* PRIVMSG \(#[^ ]*\) :!learn \([^ ][^ ]*\) *\(..*\)/ { | |
H | |
s//PRIVMSG \2 :Ok, \1/p | |
b | |
} | |
# reply to !a with b | |
/^:[^!]*![^ ]* PRIVMSG \(#[^ ]*\) :!\([^ ].*\)/ { | |
s//\1 \2/ | |
G | |
s/^\([^ ]*\) \([^\n]*\).*\n:[^!]*![^ ]* PRIVMSG \1 :!learn \2 \([^\n]*\).*/PRIVMSG \1 :\3/p | |
b | |
} | |
# owner can control the bot with these | |
/^\(:$owner![^ ]* PRIVMSG $nick :!\)\(.*\)/ s//\2/p | |
/^:$owner![^ ]* PRIVMSG $nick :save$/ { | |
# this is supposed to be used before killing the bot for whatever reason | |
g; w factoids.bak | |
s/.*/mv factoids.bak factoids/e | |
} | |
" > bot.sed | |
sed -unf bot.sed <> "/dev/tcp/$network/6667" >&0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
why