parent
4e1501df41
commit
1a9ae050d6
4
chat.c
4
chat.c
|
@ -63,7 +63,7 @@ int main(int argc, char *argv[]) {
|
|||
switch (opt) {
|
||||
break; case 'W': webirc = optarg;
|
||||
break; case 'h': host = strdup(optarg);
|
||||
break; case 'j': chat.chan = strdup(optarg);
|
||||
break; case 'j': chat.join = strdup(optarg);
|
||||
break; case 'n': chat.nick = strdup(optarg);
|
||||
break; case 'p': port = optarg;
|
||||
break; case 'u': chat.user = strdup(optarg);
|
||||
|
@ -74,7 +74,7 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
if (!host) host = prompt("Host: ");
|
||||
if (!chat.chan) chat.chan = prompt("Join: ");
|
||||
if (!chat.join) chat.join = prompt("Join: ");
|
||||
if (!chat.nick) chat.nick = prompt("Name: ");
|
||||
if (!chat.user) chat.user = strdup(chat.nick);
|
||||
|
||||
|
|
20
chat.h
20
chat.h
|
@ -29,18 +29,9 @@ struct {
|
|||
bool verbose;
|
||||
char *nick;
|
||||
char *user;
|
||||
char *chan;
|
||||
char *join;
|
||||
} chat;
|
||||
|
||||
enum {
|
||||
IRC_BOLD = 002,
|
||||
IRC_COLOR = 003,
|
||||
IRC_REVERSE = 026,
|
||||
IRC_RESET = 017,
|
||||
IRC_ITALIC = 035,
|
||||
IRC_UNDERLINE = 037,
|
||||
};
|
||||
|
||||
int ircConnect(
|
||||
const char *host, const char *port, const char *pass, const char *webPass
|
||||
);
|
||||
|
@ -50,6 +41,15 @@ void ircWrite(const char *ptr, size_t len);
|
|||
__attribute__((format(printf, 1, 2)))
|
||||
void ircFmt(const char *format, ...);
|
||||
|
||||
enum {
|
||||
IRC_BOLD = 002,
|
||||
IRC_COLOR = 003,
|
||||
IRC_REVERSE = 026,
|
||||
IRC_RESET = 017,
|
||||
IRC_ITALIC = 035,
|
||||
IRC_UNDERLINE = 037,
|
||||
};
|
||||
|
||||
void uiInit(void);
|
||||
void uiHide(void);
|
||||
void uiExit(void);
|
||||
|
|
4
handle.c
4
handle.c
|
@ -99,7 +99,7 @@ static void handle001(char *prefix, char *params) {
|
|||
free(chat.nick);
|
||||
chat.nick = strdup(nick);
|
||||
}
|
||||
ircFmt("JOIN %s\r\n", chat.chan);
|
||||
ircFmt("JOIN %s\r\n", chat.join);
|
||||
}
|
||||
|
||||
static void handleJoin(char *prefix, char *params) {
|
||||
|
@ -272,7 +272,7 @@ static void handlePrivmsg(char *prefix, char *params) {
|
|||
static void handleNotice(char *prefix, char *params) {
|
||||
char *nick, *user, *chan, *mesg;
|
||||
shift(prefix, &nick, &user, NULL, params, 2, 0, &chan, &mesg);
|
||||
if (strcmp(chan, chat.chan)) return;
|
||||
if (strcmp(chan, chat.join)) return;
|
||||
uiFmt(
|
||||
"\3%d-%s-\3 %s",
|
||||
color(user), nick, mesg
|
||||
|
|
8
input.c
8
input.c
|
@ -28,7 +28,7 @@ static void privmsg(bool action, const char *mesg) {
|
|||
int send;
|
||||
asprintf(
|
||||
&line, ":%s!%s %nPRIVMSG %s :%s%s%s",
|
||||
chat.nick, chat.user, &send, chat.chan,
|
||||
chat.nick, chat.user, &send, chat.join,
|
||||
(action ? "\1ACTION " : ""), mesg, (action ? "\1" : "")
|
||||
);
|
||||
if (!line) err(EX_OSERR, "asprintf");
|
||||
|
@ -54,14 +54,14 @@ static void inputNick(char *params) {
|
|||
|
||||
static void inputWho(char *params) {
|
||||
(void)params;
|
||||
ircFmt("WHO %s\r\n", chat.chan);
|
||||
ircFmt("WHO %s\r\n", chat.join);
|
||||
}
|
||||
|
||||
static void inputTopic(char *params) {
|
||||
if (params) {
|
||||
ircFmt("TOPIC %s :%s\r\n", chat.chan, params);
|
||||
ircFmt("TOPIC %s :%s\r\n", chat.join, params);
|
||||
} else {
|
||||
ircFmt("TOPIC %s\r\n", chat.chan);
|
||||
ircFmt("TOPIC %s\r\n", chat.join);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue