]>
jfr.im git - irc/quakenet/newserv.git/blob - helpmod2/huser.c
7 #include "../nick/nick.h"
16 huser
*huser_add(nick
*nck
)
20 assert(huser_get(nck
) == NULL
);
22 tmp
= malloc(sizeof(huser
));
24 tmp
->last_activity
= time(NULL
);
25 tmp
->flags
= H_USRFLAGS_DEFAULT
;
26 tmp
->state
= helpmod_base
;
27 tmp
->hchannels
= NULL
;
30 tmp
->account
= haccount_get_by_name(nck
->authname
);
34 tmp
->hchannels
= NULL
;
39 tmp
->last_line_repeats
= 0;
40 tmp
->last_line
[0] = '\0';
51 void huser_del(huser
*husr
)
53 huser
**ptr
= &husers
;
57 for (;*ptr
;ptr
= &(*ptr
)->next
)
60 huser
*tmp
= (*ptr
)->next
;
68 void huser_del_all(void)
70 huser
**ptr
= &husers
;
76 huser
*huser_get(nick
*nck
)
83 for (;tmp
;tmp
= tmp
->next
)
84 if (tmp
->real_user
== nck
)
89 void huser_activity(huser
*husr
, hchannel
*hchan
)
91 huser_channel
*huserchan
;
93 husr
->last_activity
= time(NULL
);
95 husr
->account
->last_activity
= time(NULL
);
97 if ((huserchan
= huser_on_channel(husr
, hchan
)) != NULL
)
98 huserchan
->last_activity
= time(NULL
);
101 huser_channel
*huser_add_channel(huser
*husr
, hchannel
*hchan
)
104 assert(huser_on_channel(husr
, hchan
) == NULL
);
106 tmp
= (huser_channel
*)malloc(sizeof(huser_channel
));
108 tmp
->next
= husr
->hchannels
;
110 tmp
->responsible_oper
= NULL
;
111 tmp
->last_activity
= time(NULL
);
114 husr
->hchannels
= tmp
;
116 assert(huser_on_channel(husr
, hchan
) != NULL
);
121 void huser_del_channel(huser
*husr
, hchannel
*hchan
)
123 huser_channel
**tmp
= &husr
->hchannels
;
124 assert(huser_on_channel(husr
, hchan
) != NULL
);
126 for (;*tmp
;tmp
= &(*tmp
)->next
)
127 if ((*tmp
)->hchan
== hchan
)
129 huser_channel
*ptr
= (*tmp
)->next
;
136 assert(huser_on_channel(husr
, hchan
) == NULL
);
139 huser_channel
*huser_on_channel(huser
*husr
, hchannel
*hchan
)
141 huser_channel
*tmp
= husr
->hchannels
;
143 for (;tmp
;tmp
= tmp
->next
)
144 if (tmp
->hchan
== hchan
)
149 void huser_clear_inactives(void)
151 huser
**ptr
= &husers
;
153 if (!(*ptr
)->hchannels
&& (time(NULL
) - (*ptr
)->last_activity
) > HELPMOD_USER_TIMEOUT
)
159 int huser_count(void)
164 for (;tmp
;tmp
= tmp
->next
)
170 void huser_reset_states(void)
174 for (;tmp
;tmp
= tmp
->next
)
175 tmp
->state
= helpmod_base
;
178 hlevel
huser_get_level(huser
*husr
)
180 if ((strlen(husr
->real_user
->nick
)) == 1 && isalpha(husr
->real_user
->nick
[0]))
181 return H_SERVICE
; /* network services, keeps them out of harms way */
183 if (husr
->account
!= NULL
)
185 if (IsOper(husr
->real_user
) && (husr
->account
->level
< H_STAFF
))
187 else if (!IsOper(husr
->real_user
) && (husr
->account
->level
>= H_OPER
))
190 return husr
->account
->level
;
194 if (IsOper(husr
->real_user
) || IsXOper(husr
->real_user
))
201 int on_queue(huser
*husr
, huser_channel
*huserchan
)
203 if (huserchan
== NULL
|| huser_get_level(husr
) > H_PEON
)
205 if (!(huserchan
->hchan
->flags
& H_QUEUE
))
207 if (huserchan
->flags
& (HCUMODE_OP
| HCUMODE_VOICE
))
209 if (huserchan
->flags
& HQUEUE_DONE
)
214 int on_desk(huser
* husr
, huser_channel
*huserchan
)
216 if (huserchan
== NULL
|| huser_get_level(husr
) > H_PEON
)
218 if (!(huserchan
->hchan
->flags
& H_QUEUE
))
220 if (!(huserchan
->flags
& (HCUMODE_OP
| HCUMODE_VOICE
)))
222 if (!(huserchan
->flags
& HQUEUE_DONE
))
227 int huser_get_account_flags(huser
*husr
)
229 if (husr
->account
!= NULL
)
230 return husr
->account
->flags
;
232 return H_ACCFLAGS_DEFAULT
;
235 int huser_valid(huser
* husr
)
238 for (;ptr
;ptr
= ptr
->next
)
244 int huser_is_trojan(huser
*husr
)
249 if (IsOper(husr
->real_user
))
252 if (!IsAccount(husr
->real_user
))
253 if (strisupper(husr
->real_user
->nick
) && (strnumcount(husr
->real_user
->nick
) >= 2))
255 sprintf(buffer
, "*%s*", husr
->real_user
->nick
);
256 if (hword_count(husr
->real_user
->realname
->name
->content
) == 1)
257 if (strregexp(husr
->real_user
->realname
->name
->content
, buffer
))
262 if (!IsAccount(husr
->real_user
) && (husr
->real_user
->ident
[0] == '~'))
263 if (strislower(husr
->real_user
->nick
) && strisalpha(husr
->real_user
->nick
))
264 if (strislower(husr
->real_user
->ident
) && strisalpha(husr
->real_user
->ident
))
265 if (strislower(husr
->real_user
->realname
->name
->content
) && strisalpha(husr
->real_user
->realname
->name
->content
))
266 if (hword_count(husr
->real_user
->realname
->name
->content
) == 1)
267 /*if (strregexp(husr->real_user->host->name->content, "8?.*") ||
268 strregexp(husr->real_user->host->name->content, "*.fr") ||
269 strregexp(husr->real_user->host->name->content, "*.de") ||
270 strregexp(husr->real_user->host->name->content, "*.be") ||
271 strregexp(husr->real_user->host->name->content, "*.net"))*/