From 6db8e620b1cb72c7d93818901df95e1253e75c53 Mon Sep 17 00:00:00 2001 From: Aaron Blakely Date: Fri, 16 Feb 2024 17:32:54 -0600 Subject: [PATCH] remove \r from irc in on windows --- lib/channel.h | 2 ++ src/channel.c | 27 +++++++++++++++++++++++++++ src/main.c | 2 ++ 3 files changed, 31 insertions(+) diff --git a/lib/channel.h b/lib/channel.h index 175b2ed..b3cfcdf 100755 --- a/lib/channel.h +++ b/lib/channel.h @@ -61,6 +61,7 @@ MY_API BOOL is_halfop(char *chan, char *nick); MY_API BOOL is_voice(char *chan, char *nick); MY_API BOOL channel_exists(char *chan); MY_API BOOL user_exists(char *chan, char *nick); +MY_API BOOL is_on_channel(char *nick, char *chan); #else MY_API bool is_op(char *chan, char *nick); MY_API bool is_halfop(char *chan, char *nick); @@ -69,6 +70,7 @@ MY_API bool is_owner(char *chan, char *nick); MY_API bool is_admin(char *chan, char *nick); MY_API bool channel_exists(char *chan); MY_API bool user_exists(char *chan, char *nick); +MY_API bool is_on_channel(char *nick, char *chan); #endif #endif diff --git a/src/channel.c b/src/channel.c index a3d818f..aae0ff4 100755 --- a/src/channel.c +++ b/src/channel.c @@ -401,3 +401,30 @@ MY_API bool user_exists(char *chan, char *nick) return 0; } +#ifdef _WIN32 +MY_API BOOL is_on_channel(char *nick, char *chan) +#else +MY_API bool is_on_channel(char *nick, char *chan) +#endif +{ + int i; + + for (i = 0; i < chan_count; i++) + { + if (!strcmp(channels[i]->name, chan)) + { + int j; + + for (j = 0; j < channels[i]->user_count; j++) + { + if (!strcmp(channels[i]->users[j].nick, nick)) + { + return 1; + } + } + } + } + + return 0; +} + diff --git a/src/main.c b/src/main.c index ebe6ed7..82c3cf5 100755 --- a/src/main.c +++ b/src/main.c @@ -121,6 +121,8 @@ int main() while (1) { + // remove \r + p = strchr(bot.in, '\r'); p = strchr(bot.in, '\n'); if (p == NULL) break;