struct searchNode *timestamp_parse(searchCtx *ctx, int type, int argc, char **argv) {
struct searchNode *thenode;
- if (type != SEARCHTYPE_NICK) {
- parseError = "timestamp: this function is only valid for nick searches.";
+ if ((type != SEARCHTYPE_NICK) && (type != SEARCHTYPE_CHANNEL)){
+ parseError = "timestamp: this function is only valid for nick or channel searches.";
return NULL;
}
}
thenode->returntype = RETURNTYPE_INT;
- thenode->localdata = NULL;
+ thenode->localdata = (void *)type;
thenode->exe = timestamp_exe;
thenode->free = timestamp_free;
void *timestamp_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
nick *np = (nick *)theinput;
-
- return (void *)np->timestamp;
+ chanindex *cip = (chanindex *)theinput;
+
+ if ((int)thenode->localdata == SEARCHTYPE_NICK) {
+ return (void *)np->timestamp;
+ } else {
+ if (cip->channel)
+ return (void *)cip->channel->timestamp;
+ else
+ return 0;
+ }
}
void timestamp_free(searchCtx *ctx, struct searchNode *thenode) {