- Timestamp:
- Dec 24, 2013, 5:52:56 PM (11 years ago)
- Branches:
- master
- Children:
- 9195a6a
- Parents:
- 4d92f03
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cmd.c
r4d92f03 rbf02a60 28 28 extern int creategroups; 29 29 30 void icb_cmd_beep(struct icb_session *, char *); 30 31 void icb_cmd_boot(struct icb_session *, char *); 31 32 void icb_cmd_change(struct icb_session *, char *); 32 33 void icb_cmd_name(struct icb_session *, char *); 34 void icb_cmd_nobeep(struct icb_session *, char *); 33 35 void icb_cmd_personal(struct icb_session *, char *); 34 36 void icb_cmd_pass(struct icb_session *, char *); … … 43 45 void (*handler)(struct icb_session *, char *); 44 46 } cmdtab[] = { 47 { "beep", icb_cmd_beep }, 45 48 { "boot", icb_cmd_boot }, 46 49 { "g", icb_cmd_change }, … … 48 51 { "msg", icb_cmd_personal }, 49 52 { "name", icb_cmd_name }, 53 { "nobeep", icb_cmd_nobeep }, 50 54 { "pass", icb_cmd_pass }, 51 55 { "topic", icb_cmd_topic }, … … 59 63 return (cmdtab[i].handler); 60 64 return (NULL); 65 } 66 67 void 68 icb_cmd_beep(struct icb_session *is, char *arg) 69 { 70 struct icb_group *ig = is->group; 71 struct icb_session *s; 72 73 if (strlen(arg) == 0) { 74 icb_error(is, "Invalid user"); 75 return; 76 } 77 78 LIST_FOREACH(s, &ig->sess, entry) { 79 if (strcmp(s->nick, arg) == 0) 80 break; 81 } 82 if (s == NULL) { 83 icb_status(is, STATUS_NOTIFY, "%s is not signed on", arg); 84 return; 85 } 86 87 if (ISSETF(s->flags, ICB_SF_NOBEEP | ICB_SF_NOBEEP2)) { 88 icb_error(is, "User has nobeep enabled"); 89 if (ISSETF(s->flags, ICB_SF_NOBEEP2)) 90 icb_status(s, STATUS_NOBEEP, 91 "%s attempted to beep you", is->nick); 92 return; 93 } 94 95 icb_sendfmt(s, "%c%s", ICB_M_BEEP, is->nick); 61 96 } 62 97 … … 186 221 "%s changed nickname to %s", is->nick, arg); 187 222 strlcpy(is->nick, arg, sizeof is->nick); 223 } 224 225 void 226 icb_cmd_nobeep(struct icb_session *is, char *arg) 227 { 228 if (strlen(arg) == 0) { 229 /* fail if we have verbose turned on */ 230 if (ISSETF(is->flags, ICB_SF_NOBEEP2)) { 231 icb_error(is, "Can't toggle your nobeep status"); 232 return; 233 } 234 /* otherwise toggle the status */ 235 if (ISSETF(is->flags, ICB_SF_NOBEEP)) 236 CLRF(is->flags, ICB_SF_NOBEEP); 237 else 238 SETF(is->flags, ICB_SF_NOBEEP); 239 icb_status(is, STATUS_NOBEEP, "No-Beep %s", 240 ISSETF(is->flags, ICB_SF_NOBEEP) ? "on" : "off"); 241 return; 242 } 243 244 if (strcmp(arg, "on") == 0) { 245 SETF(is->flags, ICB_SF_NOBEEP); 246 CLRF(is->flags, ICB_SF_NOBEEP2); /* can't be on and verbose */ 247 icb_status(is, STATUS_NOBEEP, "No-Beep on"); 248 } else if (strcmp(arg, "verbose") == 0) { 249 SETF(is->flags, ICB_SF_NOBEEP2); 250 CLRF(is->flags, ICB_SF_NOBEEP); /* can't be on and verbose */ 251 icb_status(is, STATUS_NOBEEP, "No-Beep on (verbose)"); 252 } else if (strcmp(arg, "off") == 0) { 253 CLRF(is->flags, ICB_SF_NOBEEP | ICB_SF_NOBEEP2); 254 icb_status(is, STATUS_NOBEEP, "No-Beep off"); 255 } else 256 icb_error(is, "Invalid nobeep mode"); 188 257 } 189 258
Note:
See TracChangeset
for help on using the changeset viewer.