summary refs log tree commit diff
path: root/bin
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-04-28 21:12:31 -0400
committerJune McEnroe <june@causal.agency>2021-04-28 21:12:31 -0400
commit20879400dd0c6652269e6b135064e12c55cf79d9 (patch)
tree68d394d2a8f71c444707f6c491cdf0179320481b /bin
parentRemove hnel (diff)
downloadsrc-20879400dd0c6652269e6b135064e12c55cf79d9.tar.gz
src-20879400dd0c6652269e6b135064e12c55cf79d9.zip
Add copy mode to typer
Diffstat (limited to '')
-rw-r--r--bin/man1/typer.18
-rw-r--r--bin/typer.c10
2 files changed, 14 insertions, 4 deletions
diff --git a/bin/man1/typer.1 b/bin/man1/typer.1
index a3b0eb90..dd1108d1 100644
--- a/bin/man1/typer.1
+++ b/bin/man1/typer.1
@@ -1,4 +1,4 @@
-.Dd April 18, 2021
+.Dd April 28, 2021
 .Dt TYPER 1
 .Os
 .
@@ -8,7 +8,7 @@
 .
 .Sh SYNOPSIS
 .Nm
-.Op Fl PRv
+.Op Fl CPRv
 .Op Fl c Ar cert
 .Op Fl n Ar nick
 .Op Fl p Ar port
@@ -22,6 +22,10 @@ is an IRC bot
 that types all day long.
 The arguments are as follows:
 .Bl -tag -width Ds
+.It Fl C
+Copy
+.Nm .
+Type whenever anyone else is typing.
 .It Fl P
 Request the
 .Sy causal.agency/passive
diff --git a/bin/typer.c b/bin/typer.c
index 0218ee24..186f8214 100644
--- a/bin/typer.c
+++ b/bin/typer.c
@@ -64,6 +64,7 @@ static void format(const char *format, ...) {
 
 static bool joined;
 static bool reverse;
+static bool copy;
 
 static void handle(char *line) {
 	char *tags = NULL;
@@ -84,6 +85,10 @@ static void handle(char *line) {
 		joined = true;
 	} else if (!strcmp(cmd, "PING")) {
 		format("PONG %s\r\n", line);
+	} else if (copy && !strcmp(cmd, "TAGMSG") && tags) {
+		if (strstr(tags, "typing=")) {
+			format("@%s TAGMSG %s\r\n", tags, chan);
+		}
 	} else if (reverse && !strcmp(cmd, "TAGMSG") && tags && origin) {
 		char *nick = strsep(&origin, "!");
 		if (strstr(tags, "typing=active")) {
@@ -114,8 +119,9 @@ int main(int argc, char *argv[]) {
 	const char *user = "typer";
 	bool passive = false;
 
-	for (int opt; 0 < (opt = getopt(argc, argv, "PRc:n:p:u:v"));) {
+	for (int opt; 0 < (opt = getopt(argc, argv, "CPRc:n:p:u:v"));) {
 		switch (opt) {
+			break; case 'C': copy = true;
 			break; case 'P': passive = true;
 			break; case 'R': reverse = true;
 			break; case 'c': cert = optarg;
@@ -156,7 +162,7 @@ int main(int argc, char *argv[]) {
 		nick, user
 	);
 
-	if (!reverse) {
+	if (!copy && !reverse) {
 		signal(SIGALRM, timer);
 		struct itimerval itimer = {
 			.it_interval.tv_sec = 5,
gmsg'> This seems a bit out of character for me, but this is basically free: ctags(1) is part of FreeBSD and Darwin, and vim automatically uses tags. Also the format of tags files is cute. 2018-02-06Replace gfxx SCALE macro with interp functionJune McEnroe Short-circuits for b = 8. 2018-02-05Rename gfxx space indexed and add palette samplingJune McEnroe 2018-02-05Take scale into account for when to stop drawing in gfxxJune McEnroe 2018-02-05Always skip most significant bits in gfxxJune McEnroe This works for CARDS.DLL but might not for other things. We'll see. 2018-02-05Set title in gfcocoaJune McEnroe 2018-02-05Double-buffer gfb frontendJune McEnroe Still not vsync (seems like a newer DRM-fbdev implementation handles FBIO_WAITFORVSYNC but my kernel doesn't), but avoids flicker from clearing to black for each frame. 2018-02-05Rewrite gfxx bit handlingJune McEnroe Specifies how many bits for each of "alpha" (ignored), red, green, blue. Separates byte-order and bit-order. Much more flexible, but now won't render CARDS.DLL graphics properly due to the skip bit being not where it expects. Also mmaps the file instead of reading it all in. And the default palette and sampling got removed again for now, since it's too awkward to use. 2018-02-05Add flip option to gfxxJune McEnroe This handles upside-down graphics much better than reverse did. 2018-02-05Remove gfxx reverse optionJune McEnroe 2018-02-04Fix gfxx draw stop conditionJune McEnroe Would not draw the last partially visible column when mirrored. 2018-02-04Reuse CGColorSpace and CGDataProvider in gfcocoaJune McEnroe 2018-02-04Mark mac target phonyJune McEnroe 2018-02-04Set up Makefile for gfxx-cocoa or gfxx-fbJune McEnroe 2018-02-04Avoid doing excessive work in gfxxJune McEnroe By stopping when the next column would be off the edge of the buffer. 2018-02-04Handle window resizing in gfcocoaJune McEnroe 2018-02-04Set cinoptionsJune McEnroe 2018-02-04Tweak colorscheme moreJune McEnroe 2018-02-04Color MatchParen DarkYellowJune McEnroe White is not obvious enough. 2018-02-04Add palette sampling to gfxxJune McEnroe 2018-02-04Add 4-bit RGB to gfxxJune McEnroe Replace default palette with alternating black and white. 2018-02-04Add Quit menu item to gfcocoaJune McEnroe 2018-02-04Switch back to sane Objective-C styleJune McEnroe 2018-02-04Quit gfcocoa when window closesJune McEnroe 2018-02-03Apparently this is how people write Objective-CJune McEnroe