Browse Source

Added logging of nick changes under the nick info and nicks.

Added banning of all hosts a nick has been (As well as unbanning).
tags/3.1.0
Teknikode 4 years ago
parent
commit
ebb8720f9c

+ 1
- 1
Combot/Combot.csproj View File

@@ -12,6 +12,7 @@
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<IsWebBootstrapper>false</IsWebBootstrapper>
<NuGetPackageImportStamp>deff0bcf</NuGetPackageImportStamp>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
@@ -26,7 +27,6 @@
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<NuGetPackageImportStamp>deff0bcf</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>

+ 1
- 1
IRCServices/Messaging/Messages.cs View File

@@ -312,7 +312,7 @@ namespace Combot.IRCServices.Messaging
case "NICK":
NickChangeInfo nickMsg = new NickChangeInfo();
nickMsg.OldNick = new Nick() { Nickname = senderNick, Realname = senderRealname, Host = senderHost };
nickMsg.NewNick = new Nick() { Nickname = recipient.TrimStart(':') };
nickMsg.NewNick = new Nick() { Nickname = recipient.TrimStart(':'), Realname = senderRealname, Host = senderHost};

await Task.Run(() =>
{

+ 9
- 0
Modules/Logging/Logging.cs View File

@@ -16,6 +16,7 @@ namespace Combot.Modules.Plugins
Bot.IRC.Message.PartChannelEvent += LogChannelPart;
Bot.IRC.Message.KickEvent += LogChannelKick;
Bot.IRC.Message.QuitEvent += LogQuit;
Bot.IRC.Message.NickChangeEvent += LogNickChange;
}

private void LogChannelMessage(object sender, ChannelMessage message)
@@ -113,5 +114,13 @@ namespace Combot.Modules.Plugins
Bot.Database.Execute(query, new object[] {Bot.ServerConfig.Name, Bot.ServerConfig.Name, info.Nick.Nickname, info.Message, info.TimeStamp});
}
}

private void LogNickChange(object sender, NickChangeInfo info)
{
if (!NickBlacklist.Contains(info.OldNick.Nickname) && !NickBlacklist.Contains(info.NewNick.Nickname))
{
AddNick(info.NewNick);
}
}
}
}

+ 35
- 19
Modules/Moderation/Moderation.cs View File

@@ -250,35 +250,51 @@ namespace Combot.Modules.Plugins
if (Bot.CheckChannelAccess(channel, command.Nick.Nickname, curCommand.AllowedAccess) && Bot.CheckNickAccess(channel, command.Nick.Nickname, command.Arguments["Nickname"]))
{
string banMask = command.Arguments["Nickname"];
Channel foundChannel = Bot.IRC.Channels.Find(chan => chan.Nicks.Exists(nick => nick.Nickname == banMask));
if (foundChannel != null)
if (!banMask.Contains("@") || !banMask.Contains("!"))
{
Nick foundNick = foundChannel.Nicks.Find(nick => nick.Nickname == banMask);
if (foundNick.Host != string.Empty && foundNick.Username != null)
{
banMask = string.Format("*!*{0}@{1}", foundNick.Username, foundNick.Host);
}
else if (foundNick.Host != string.Empty)
{
banMask = string.Format("*!*@{0}", foundNick.Host);
}
else if (foundNick.Username != string.Empty)
string search = "SELECT `nickinfo`.`username`, `nickinfo`.`host`, `nicks`.`nickname` FROM `nickinfo` " +
"INNER JOIN `nicks` " +
"ON `nickinfo`.`nick_id` = `nicks`.`id` " +
"INNER JOIN `servers` " +
"ON `nicks`.`server_id` = `servers`.`id` " +
"WHERE `servers`.`name` = {0} AND `nicks`.`nickname` = {1}";
List<Dictionary<string, object>> results = Bot.Database.Query(search, new object[] {Bot.ServerConfig.Name, banMask});

if (results.Any())
{
banMask = string.Format("{0}!*{1}@*", foundNick.Nickname, foundNick.Username);
foreach (Dictionary<string, object> result in results)
{
var nickname = result["nickname"].ToString();
var host = result["host"].ToString();
var username = result["username"].ToString();
if (!string.IsNullOrEmpty(host) && !string.IsNullOrEmpty(username))
{
banMask = string.Format("*!*{0}@{1}", username, host);
}
else if (!string.IsNullOrEmpty(host))
{
banMask = string.Format("*!*@{0}", host);
}
else if (!string.IsNullOrEmpty(username))
{
banMask = string.Format("{0}!*{1}@*", nickname, username);
}
else
{
banMask = string.Format("{0}!*@*", nickname);
}
SetMode(set, channel, ChannelMode.b, banMask);
}
}
else
{
banMask = string.Format("{0}!*@*", foundNick.Nickname);
SetMode(set, channel, ChannelMode.b, string.Format("{0}!*@*", banMask));
}
}
else
{
if (!banMask.Contains("@") || !banMask.Contains("!"))
{
banMask = string.Format("{0}!*@*", banMask);
}
SetMode(set, channel, ChannelMode.b, banMask);
}
SetMode(set, channel, ChannelMode.b, banMask);
}
else
{

Loading…
Cancel
Save