1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-10 22:43:13 +02:00

Convert watch code to use new sendnumeric(), getting rid of the temporary

sendnumeric_legacy() calls.

This also fixes some small format string bugs (eg: argument too much and
some time_t fun, like the previous commits elsewhere... nothing fancy).
This commit is contained in:
Bram Matthys
2021-09-12 16:28:04 +02:00
parent 4392468c3e
commit 6237bf5f5f
2 changed files with 71 additions and 34 deletions
+6 -6
View File
@@ -648,12 +648,12 @@
#define STR_ERR_WHOLIMEXCEED /* 523 */ ":Error, /who limit of %d exceeded. Please narrow your search down and try again"
#define STR_ERR_OPERSPVERIFY /* 524 */ ":Trying to join +s or +p channel as an oper. Please invite yourself first."
#define STR_ERR_CANTSENDTOUSER /* 531 */ "%s :%s"
#define STR_RPL_REAWAY /* 597 */ "%s %s %s %d :%s"
#define STR_RPL_GONEAWAY /* 598 */ "%s %s %s %d :%s"
#define STR_RPL_NOTAWAY /* 599 */ "%s %s %s %d :is no longer away"
#define STR_RPL_LOGON /* 600 */ "%s %s %s %d :logged online"
#define STR_RPL_LOGOFF /* 601 */ "%s %s %s %d :logged offline"
#define STR_RPL_WATCHOFF /* 602 */ "%s %s %s %d :stopped watching"
#define STR_RPL_REAWAY /* 597 */ "%s %s %s %lld :%s"
#define STR_RPL_GONEAWAY /* 598 */ "%s %s %s %lld :%s"
#define STR_RPL_NOTAWAY /* 599 */ "%s %s %s %lld :is no longer away"
#define STR_RPL_LOGON /* 600 */ "%s %s %s %lld :logged online"
#define STR_RPL_LOGOFF /* 601 */ "%s %s %s %lld :logged offline"
#define STR_RPL_WATCHOFF /* 602 */ "%s %s %s %lld :stopped watching"
#define STR_RPL_WATCHSTAT /* 603 */ ":You have %d and are on %d WATCH entries"
#define STR_RPL_NOWON /* 604 */ "%s %s %s %lld :is online"
#define STR_RPL_NOWOFF /* 605 */ "%s %s %s %lld :is offline"
+65 -28
View File
@@ -72,10 +72,8 @@ MOD_UNLOAD()
/*
* RPL_NOWON - Online at the moment (Successfully added to WATCH-list)
* RPL_NOWOFF - Offline at the moement (Successfully added to WATCH-list)
* RPL_WATCHOFF - Successfully removed from WATCH-list.
* ERR_TOOMANYWATCH - Take a guess :> Too many WATCH entries.
*/
static void show_watch(Client *client, char *name, int rpl1, int rpl2, int awaynotify)
static void show_watch(Client *client, char *name, int awaynotify)
{
Client *target;
@@ -85,19 +83,39 @@ static void show_watch(Client *client, char *name, int rpl1, int rpl2, int awayn
{
sendnumeric(client, RPL_NOWISAWAY,
target->name, target->user->username,
IsHidden(target) ? target->user->virthost : target->user->
realhost, (long long)target->user->away_since);
IsHidden(target) ? target->user->virthost : target->user->realhost,
(long long)target->user->away_since);
return;
}
sendnumeric_legacy(client, rpl1,
sendnumeric(client, RPL_NOWON,
target->name, target->user->username,
IsHidden(target) ? target->user->virthost : target->user->
realhost, target->lastnick);
IsHidden(target) ? target->user->virthost : target->user->realhost,
(long long)target->lastnick);
}
else
{
sendnumeric_legacy(client, rpl2, name, "*", "*", 0L);
sendnumeric(client, RPL_NOWOFF, name, "*", "*", 0LL);
}
}
/*
* RPL_WATCHOFF - Successfully removed from WATCH-list.
*/
static void show_watch_removed(Client *client, char *name)
{
Client *target;
if ((target = find_person(name, NULL)))
{
sendnumeric(client, RPL_WATCHOFF,
target->name, target->user->username,
IsHidden(target) ? target->user->virthost : target->user->realhost,
(long long)target->lastnick);
}
else
{
sendnumeric(client, RPL_WATCHOFF, name, "*", "*", 0LL);
}
}
@@ -172,7 +190,7 @@ CMD_FUNC(cmd_watch)
);
}
show_watch(client, s + 1, RPL_NOWON, RPL_NOWOFF, awaynotify);
show_watch(client, s + 1, awaynotify);
continue;
}
@@ -185,8 +203,7 @@ CMD_FUNC(cmd_watch)
if (!*(s+1))
continue;
watch_del(s + 1, client, WATCH_FLAG_TYPE_WATCH);
show_watch(client, s + 1, RPL_WATCHOFF, RPL_WATCHOFF, 0);
show_watch_removed(client, s + 1);
continue;
}
@@ -359,12 +376,20 @@ int watch_notification(Client *client, Watch *watch, Link *lp, int event)
if (!awaynotify)
{
sendnumeric_legacy(lp->value.client, (event == WATCH_EVENT_OFFLINE)?RPL_LOGOFF:RPL_LOGON,
client->name,
(IsUser(client) ? client->user->username : "<N/A>"),
(IsUser(client) ?
(IsHidden(client) ? client->user->virthost : client->
user->realhost) : "<N/A>"), watch->lasttime, client->info);
if (event == WATCH_EVENT_OFFLINE)
{
sendnumeric(lp->value.client, RPL_LOGOFF,
client->name,
(IsUser(client) ? client->user->username : "<N/A>"),
(IsUser(client) ? (IsHidden(client) ? client->user->virthost : client->user->realhost) : "<N/A>"),
(long long)watch->lasttime);
} else {
sendnumeric(lp->value.client, RPL_LOGON,
client->name,
(IsUser(client) ? client->user->username : "<N/A>"),
(IsUser(client) ? (IsHidden(client) ? client->user->virthost : client->user->realhost) : "<N/A>"),
(long long)watch->lasttime);
}
}
else
{
@@ -373,19 +398,31 @@ int watch_notification(Client *client, Watch *watch, Link *lp, int event)
return 0; /* skip away/unaway notification for users not interested in them */
if (event == WATCH_EVENT_NOTAWAY)
{
sendnumeric(lp->value.client, RPL_NOTAWAY,
client->name,
(IsUser(client) ? client->user->username : "<N/A>"),
(IsUser(client) ?
(IsHidden(client) ? client->user->virthost : client->user->realhost) : "<N/A>"),
(int)client->user->away_since);
else /* RPL_GONEAWAY / RPL_REAWAY */
sendnumeric_legacy(lp->value.client, (event == WATCH_EVENT_AWAY)?RPL_GONEAWAY:RPL_REAWAY,
client->name,
(IsUser(client) ? client->user->username : "<N/A>"),
(IsUser(client) ?
(IsHidden(client) ? client->user->virthost : client->
user->realhost) : "<N/A>"), client->user->away_since, client->user->away);
(IsUser(client) ? (IsHidden(client) ? client->user->virthost : client->user->realhost) : "<N/A>"),
(long long)client->user->away_since);
} else
if (event == RPL_GONEAWAY)
{
sendnumeric(lp->value.client, RPL_GONEAWAY,
client->name,
(IsUser(client) ? client->user->username : "<N/A>"),
(IsUser(client) ? (IsHidden(client) ? client->user->virthost : client->user->realhost) : "<N/A>"),
(long long)client->user->away_since,
client->user->away);
} else
if (event == RPL_REAWAY)
{
sendnumeric(lp->value.client, RPL_REAWAY,
client->name,
(IsUser(client) ? client->user->username : "<N/A>"),
(IsUser(client) ? (IsHidden(client) ? client->user->virthost : client->user->realhost) : "<N/A>"),
(long long)client->user->away_since,
client->user->away);
}
}
return 0;