Handle QUIT
This commit is contained in:
		
							parent
							
								
									7ebfeea330
								
							
						
					
					
						commit
						f14175ebed
					
				
							
								
								
									
										48
									
								
								handle.c
									
									
									
									
									
								
							
							
						
						
									
										48
									
								
								handle.c
									
									
									
									
									
								
							@ -226,6 +226,37 @@ static void handlePart(struct Message *msg) {
 | 
				
			|||||||
	);
 | 
						);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void handleNick(struct Message *msg) {
 | 
				
			||||||
 | 
						require(msg, true, 1);
 | 
				
			||||||
 | 
						if (self.nick && !strcmp(msg->nick, self.nick)) {
 | 
				
			||||||
 | 
							set(&self.nick, msg->params[0]);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						size_t id;
 | 
				
			||||||
 | 
						while (None != (id = completeID(msg->nick))) {
 | 
				
			||||||
 | 
							uiFormat(
 | 
				
			||||||
 | 
								id, Cold, tagTime(msg),
 | 
				
			||||||
 | 
								"\3%02d%s\3\tis now known as \3%02d%s\3",
 | 
				
			||||||
 | 
								hash(msg->user), msg->nick, hash(msg->user), msg->params[0]
 | 
				
			||||||
 | 
							);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						completeReplace(None, msg->nick, msg->params[0]);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void handleQuit(struct Message *msg) {
 | 
				
			||||||
 | 
						require(msg, true, 0);
 | 
				
			||||||
 | 
						size_t id;
 | 
				
			||||||
 | 
						while (None != (id = completeID(msg->nick))) {
 | 
				
			||||||
 | 
							uiFormat(
 | 
				
			||||||
 | 
								id, Cold, tagTime(msg),
 | 
				
			||||||
 | 
								"\3%02d%s\3\tleaves%s%s",
 | 
				
			||||||
 | 
								hash(msg->user), msg->nick,
 | 
				
			||||||
 | 
								(msg->params[0] ? ": " : ""),
 | 
				
			||||||
 | 
								(msg->params[0] ? msg->params[0] : "")
 | 
				
			||||||
 | 
							);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						completeRemove(None, msg->nick);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void handleReplyNames(struct Message *msg) {
 | 
					static void handleReplyNames(struct Message *msg) {
 | 
				
			||||||
	require(msg, false, 4);
 | 
						require(msg, false, 4);
 | 
				
			||||||
	size_t id = idFor(msg->params[2]);
 | 
						size_t id = idFor(msg->params[2]);
 | 
				
			||||||
@ -288,22 +319,6 @@ static void handleTopic(struct Message *msg) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void handleNick(struct Message *msg) {
 | 
					 | 
				
			||||||
	require(msg, true, 1);
 | 
					 | 
				
			||||||
	if (self.nick && !strcmp(msg->nick, self.nick)) {
 | 
					 | 
				
			||||||
		set(&self.nick, msg->params[0]);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	size_t id;
 | 
					 | 
				
			||||||
	completeReplace(None, msg->nick, msg->params[0]);
 | 
					 | 
				
			||||||
	while (None != (id = completeID(msg->params[0]))) {
 | 
					 | 
				
			||||||
		uiFormat(
 | 
					 | 
				
			||||||
			id, Cold, tagTime(msg),
 | 
					 | 
				
			||||||
			"\3%02d%s\3\tis now known as \3%02d%s\3",
 | 
					 | 
				
			||||||
			hash(msg->user), msg->nick, hash(msg->user), msg->params[0]
 | 
					 | 
				
			||||||
		);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static bool isAction(struct Message *msg) {
 | 
					static bool isAction(struct Message *msg) {
 | 
				
			||||||
	if (strncmp(msg->params[1], "\1ACTION ", 8)) return false;
 | 
						if (strncmp(msg->params[1], "\1ACTION ", 8)) return false;
 | 
				
			||||||
	msg->params[1] += 8;
 | 
						msg->params[1] += 8;
 | 
				
			||||||
@ -403,6 +418,7 @@ static const struct Handler {
 | 
				
			|||||||
	{ "PART", handlePart },
 | 
						{ "PART", handlePart },
 | 
				
			||||||
	{ "PING", handlePing },
 | 
						{ "PING", handlePing },
 | 
				
			||||||
	{ "PRIVMSG", handlePrivmsg },
 | 
						{ "PRIVMSG", handlePrivmsg },
 | 
				
			||||||
 | 
						{ "QUIT", handleQuit },
 | 
				
			||||||
	{ "TOPIC", handleTopic },
 | 
						{ "TOPIC", handleTopic },
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user