+ /* first of all strip the message (filter out invisible content) */
+ char *stripped_message = MyMalloc(BUFSIZE + 1);
+ strcpy(stripped_message, msg);
+ char p = stripped_message[0];
+ int p_pos = 0;
+ int is_visible = 1, is_ccode = 0, i = 0, j = 0;
+ char codes[5];
+ for(i = 0; p != '\n'; p = stripped_message[++i]) {
+ if(p == 3) {
+ j = 0;
+ is_ccode = 1;
+ } else if(is_ccode) {
+ if((p >= 48 && p <= 57) || p == 44) {
+ if(is_ccode == 1) {
+ if(p == 44) {
+ is_ccode = 2;
+ codes[j++] = 0;
+ j = 0;
+ } else
+ codes[j++] = p;
+ } else {
+ //compare
+ if(p != codes[j++]) {
+ is_ccode = 3;
+ }
+ }
+ } else {
+ //END of color code...
+ is_ccode = 0;
+ if(is_ccode != 1 && codes[j] != 0) is_ccode = 3;
+ if(is_ccode == 1) {
+ codes[j] = 0;
+ int k;
+ for(k = 0; k < j-1; k++) {
+ if(codes[k] != 48) {
+ is_visible = 1;
+ goto normalchar;
+ }
+ }
+ is_visible = 0;
+ } else if(is_ccode == 2) {
+ is_visible = 0;
+ } else if(is_ccode == 3) {
+ is_visible = 1;
+ goto normalchar;
+ }
+ }
+ } else {
+ normalchar:
+ if(is_visible)
+ stripped_message[p_pos++] = p;
+ }
+ }
+ stripped_message[p_pos++] = 0;