5 static USERLIST_CALLBACK(neonserv_cmd_peek_userlist_lookup);
6 static void neonserv_cmd_peek_async1(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan);
8 struct neonserv_cmd_peek_cache {
9 struct ClientSocket *client, *textclient;
10 struct UserNode *user;
13 static CMD_BIND(neonserv_cmd_peek) {
14 struct neonserv_cmd_peek_cache *cache = malloc(sizeof(*cache));
16 perror("malloc() failed");
19 cache->client = client;
20 cache->textclient = getTextBot();
22 get_userlist_with_invisible(chan, neonserv_cmd_peek_userlist_lookup, cache);
25 static USERLIST_CALLBACK(neonserv_cmd_peek_userlist_lookup) {
26 struct neonserv_cmd_peek_cache *cache = data;
27 neonserv_cmd_peek_async1(cache->client, cache->textclient, cache->user, chan);
31 static void neonserv_cmd_peek_async1(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan) {
32 reply(textclient, user, "NS_PEEK_HEADER", chan->name);
33 reply(textclient, user, "NS_PEEK_TOPIC", chan->topic);
35 reply(textclient, user, "NS_PEEK_MODES", getModeString(chan->modes, tmpStr));
36 struct ChanUser *chanuser;
37 int op_count = 0, voice_count = 0, normal_count = 0, invi_count = 0;
38 for(chanuser = getChannelUsers(chan, NULL); chanuser; chanuser = getChannelUsers(chan, chanuser)) {
39 if(chanuser->flags & CHANUSERFLAG_OPPED)
41 else if(chanuser->flags & CHANUSERFLAG_VOICED)
43 else if(chanuser->flags & CHANUSERFLAG_VOICED)
48 reply(textclient, user, "NS_PEEK_USERS", op_count+voice_count+invi_count+normal_count, op_count, voice_count, normal_count, invi_count);
50 int headerlen = 10 + strlen(user->nick);
51 for(chanuser = getChannelUsers(chan, NULL); chanuser; chanuser = getChannelUsers(chan, chanuser)) {
52 if(chanuser->flags & CHANUSERFLAG_OPPED) {
53 if(tmpStrPos + headerlen + strlen(chanuser->user->nick) + 2 >= 512) {
55 reply(textclient, user, "%s", tmpStr);
58 tmpStrPos += sprintf(tmpStr + tmpStrPos, (tmpStrPos ? ", %s" : "%s"), chanuser->user->nick);
62 reply(textclient, user, "%s", tmpStr);