summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2018-12-02 23:08:49 -0500
committerJune McEnroe <june@causal.agency>2018-12-02 23:08:49 -0500
commit0e1297e068258baba6e26265d81b93bda71be8b2 (patch)
treed0e953245129e195fe59f14fe6d12f9a92365efc
parentSend automated messages to TagStatus with UICold (diff)
downloadcatgirl-0e1297e068258baba6e26265d81b93bda71be8b2.tar.gz
catgirl-0e1297e068258baba6e26265d81b93bda71be8b2.zip
Add -r option for realname
-rw-r--r--catgirl.17
-rw-r--r--chat.c25
-rw-r--r--chat.h3
-rw-r--r--irc.c2
4 files changed, 22 insertions, 15 deletions
diff --git a/catgirl.1 b/catgirl.1
index 3c17bc7..ef15890 100644
--- a/catgirl.1
+++ b/catgirl.1
@@ -15,6 +15,7 @@
 .Op Fl l Ar path
 .Op Fl n Ar nick
 .Op Fl p Ar port
+.Op Fl r Ar real
 .Op Fl u Ar user
 .Op Fl w Ar pass
 .
@@ -64,6 +65,12 @@ Connect to
 .Ar port .
 The default port is 6697.
 .
+.It Fl r Ar real
+Set realname to
+.Ar real .
+The default realname is
+the same as the nickname.
+.
 .It Fl u Ar user
 Set username to
 .Ar user .
diff --git a/chat.c b/chat.c
index 152bf84..1de145d 100644
--- a/chat.c
+++ b/chat.c
@@ -25,20 +25,17 @@
 
 #include "chat.h"
 
+static void freedup(char **field, const char *str) {
+	free(*field);
+	*field = strdup(str);
+	if (!*field) err(EX_OSERR, "strdup");
+}
+
 void selfNick(const char *nick) {
-	free(self.nick);
-	self.nick = strdup(nick);
-	if (!self.nick) err(EX_OSERR, "strdup");
+	freedup(&self.nick, nick);
 }
 void selfUser(const char *user) {
-	free(self.user);
-	self.user = strdup(user);
-	if (!self.user) err(EX_OSERR, "strdup");
-}
-void selfJoin(const char *join) {
-	free(self.join);
-	self.join = strdup(join);
-	if (!self.join) err(EX_OSERR, "strdup");
+	freedup(&self.user, user);
 }
 
 static char *prompt(const char *prompt) {
@@ -65,15 +62,16 @@ int main(int argc, char *argv[]) {
 	char *webirc = NULL;
 
 	int opt;
-	while (0 < (opt = getopt(argc, argv, "NW:h:j:l:n:p:u:vw:"))) {
+	while (0 < (opt = getopt(argc, argv, "NW:h:j:l:n:p:r:u:vw:"))) {
 		switch (opt) {
 			break; case 'N': self.notify = true;
 			break; case 'W': webirc = strdup(optarg);
 			break; case 'h': host = strdup(optarg);
-			break; case 'j': selfJoin(optarg);
+			break; case 'j': freedup(&self.join, optarg);
 			break; case 'l': logOpen(optarg);
 			break; case 'n': selfNick(optarg);
 			break; case 'p': port = strdup(optarg);
+			break; case 'r': freedup(&self.real, optarg);
 			break; case 'u': selfUser(optarg);
 			break; case 'v': self.verbose = true;
 			break; case 'w': pass = strdup(optarg);
@@ -85,6 +83,7 @@ int main(int argc, char *argv[]) {
 	if (!host) host = prompt("Host: ");
 	if (!self.nick) self.nick = prompt("Name: ");
 	if (!self.user) selfUser(self.nick);
+	if (!self.real) freedup(&self.real, self.nick);
 
 	inputTab();
 	uiInit();
diff --git a/chat.h b/chat.h
index abbb050..31b31a2 100644
--- a/chat.h
+++ b/chat.h
@@ -31,8 +31,10 @@
 #define errx(...) do { uiHide(); errx(__VA_ARGS__); } while (0)
 
 struct {
+	char *port;
 	char *nick;
 	char *user;
+	char *real;
 	char *join;
 	bool verbose;
 	bool notify;
@@ -40,7 +42,6 @@ struct {
 
 void selfNick(const char *nick);
 void selfUser(const char *user);
-void selfJoin(const char *join);
 
 void eventWait(const char *argv[static 2]);
 void eventPipe(const char *argv[static 2]);
diff --git a/irc.c b/irc.c
index f85bfc9..e4eefa3 100644
--- a/irc.c
+++ b/irc.c
@@ -109,7 +109,7 @@ int ircConnect(void) {
 
 	if (irc.pass) ircFmt("PASS :%s\r\n", irc.pass);
 	ircFmt("NICK %s\r\n", self.nick);
-	ircFmt("USER %s 0 * :%s\r\n", self.user, self.nick);
+	ircFmt("USER %s 0 * :%s\r\n", self.user, self.real);
 
 	return irc.sock;
 }
864a89e0a956e9d5d8909ccb3084df3c273e&follow=1'>Remove default faviconJune McEnroe I hate these things and also this one sucks. 2021-09-21Use Z_FILTERED strategyJune McEnroe 2021-09-21Recalculate various lengths only as neededJune McEnroe This actually speeds things up quite a bit, saving roughly a second on a big PNG screenshot. Almost all the remaining time is spent in deflate. 2021-09-21Rewrite pngo, add explicit optionsJune McEnroe Interesting to see how my code habits have changed. 2021-09-16Fix /* **/ comment matchingJune McEnroe 2021-09-15Remove typer, add downgrade to READMEJune McEnroe 2021-09-15Set bot mode on downgradeJune McEnroe 2021-09-15Enter capsicum in downgradeJune McEnroe 2021-09-15Factor out common parts of downgrade messagesJune McEnroe Also bump the message cap to 1024 because that is ostensibly useful for replying to older messages. 2021-09-14Add downgrade IRC botJune McEnroe 2021-09-14Sort by title if authors matchJune McEnroe There are probably better things to sort by but title definitely always exists. 2021-09-13Swap-remove tags as they're foundJune McEnroe This makes it even faster. From ~1s on a sqlite3.c amalgamation to ~0.85s. 2021-09-12Replace htagml regex with strncmpJune McEnroe Since ctags only ever produces regular expressions of the form /^re$/ or /^re/ with no other special characters, instead unescape the pattern and simply use strncmp. Running on a sqlite3.c amalgamation, the regex version takes ~37s while the strncmp version takes ~1s, producing identical output. Big win! 2021-09-11Also defer printing comment for lone close-parensJune McEnroe 2021-09-10Publish "git-comment"June McEnroe 2021-09-10Add git comment --pretty optionJune McEnroe 2021-09-08Defer printing comment if line is blank or closing braceJune McEnroe This fixes badly indented comments. 2021-09-08Up default min-repeat to 30 linesJune McEnroe 2021-09-08Handle dirty lines in git-commentJune McEnroe 2021-09-08Document and install git-commentJune McEnroe 2021-09-08Add repeat and all options to git-commentJune McEnroe 2021-09-08Add group threshold to git-commentJune McEnroe