Skip to content

Commit

Permalink
🎱 Upgrade to .NET 8
Browse files Browse the repository at this point in the history
  • Loading branch information
database64128 committed Mar 20, 2024
1 parent 0862e02 commit faf4e23
Show file tree
Hide file tree
Showing 20 changed files with 53 additions and 59 deletions.
2 changes: 1 addition & 1 deletion CubicBot.Telegram.Tests/CubicBot.Telegram.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
Expand Down
4 changes: 2 additions & 2 deletions CubicBot.Telegram/Commands/Chinese.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace CubicBot.Telegram.Commands;
public static class Chinese
{
private static readonly string[] s_questions =
{
[
"你发这些什么目的?",
"谁指使你的?",
"你的动机是什么?",
Expand All @@ -33,7 +33,7 @@ public static class Chinese
"我劝你谨言慎行!",
"谁让你发的?",
"你要打倒谁?",
};
];

public static void AddCommands(List<CubicBotCommand> commands)
{
Expand Down
4 changes: 2 additions & 2 deletions CubicBot.Telegram/Commands/ChineseTasks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace CubicBot.Telegram.Commands;
public static class ChineseTasks
{
private static readonly string[] s_okAnswers =
{
[
"ok",
"okay",
"nice",
Expand Down Expand Up @@ -41,7 +41,7 @@ public static class ChineseTasks
"🉑",
"👌",
"🆗",
};
];

public static void AddCommands(List<CubicBotCommand> commands)
{
Expand Down
24 changes: 9 additions & 15 deletions CubicBot.Telegram/Commands/CommandContext.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
namespace CubicBot.Telegram.Commands;

public sealed class CommandContext : MessageContext
/// <summary>
/// Initializes a new instance of the <see cref="CommandContext"/> class.
/// </summary>
/// <param name="messageContext">The <see cref="MessageContext"/> instance.</param>
/// <param name="command">The command string.</param>
/// <param name="argument">The command argument string.</param>
public sealed class CommandContext(MessageContext messageContext, string command, string? argument) : MessageContext(messageContext)
{
/// <summary>
/// Gets the command string.
/// </summary>
public string Command { get; }
public string Command { get; } = command;

/// <summary>
/// Gets the command argument string.
/// </summary>
public string? Argument { get; }

/// <summary>
/// Initializes a new instance of the <see cref="CommandContext"/> class.
/// </summary>
/// <param name="messageContext">The <see cref="MessageContext"/> instance.</param>
/// <param name="command">The command string.</param>
/// <param name="argument">The command argument string.</param>
public CommandContext(MessageContext messageContext, string command, string? argument) : base(messageContext)
{
Command = command;
Argument = argument;
}
public string? Argument { get; } = argument;
}
4 changes: 2 additions & 2 deletions CubicBot.Telegram/Commands/Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ namespace CubicBot.Telegram.Commands;
public static class Common
{
private static readonly string[] s_beverages =
{
[
"🍼", "🥛", "☕️", "🫖", "🍵", "🍶", "🍾", "🍷", "🍸", "🍹",
"🍺", "🍻", "🥂", "🥃", "🧉", "🏺", "🚰", "🥤", "🧋", "🧃",
};
];

public static void AddCommands(List<CubicBotCommand> commands)
{
Expand Down
8 changes: 4 additions & 4 deletions CubicBot.Telegram/Commands/ConsentNotNeeded.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ namespace CubicBot.Telegram.Commands;
public static class ConsentNotNeeded
{
private static readonly string[] s_cooksAndFood =
{
[
"👩‍🍳", "🧑‍🍳", "👨‍🍳", "🍳", "🥘", "🍕",
};
];

private static readonly string[] s_forcedToDo =
{
[
"give up",
"eat 💩",
"surrender",
"strip naked",
};
];

public static void AddCommands(List<CubicBotCommand> commands)
{
Expand Down
12 changes: 6 additions & 6 deletions CubicBot.Telegram/Commands/LawEnforcement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@ namespace CubicBot.Telegram.Commands;
public static class LawEnforcement
{
private static readonly string[] s_policeOfficers =
{
[
"👮‍♀️", "👮🏻‍♀️", "👮🏼‍♀️", "👮🏽‍♀️", "👮🏾‍♀️", "👮🏿‍♀️",
"👮", "👮🏻", "👮🏼", "👮🏽", "👮🏾", "👮🏿",
"👮‍♂️", "👮🏻‍♂️", "👮🏼‍♂️", "👮🏽‍♂️", "👮🏾‍♂️", "👮🏿‍♂️",
};
];

private static readonly string[] s_policePresence =
{
[
"🚓", "🚔", "🚨",
};
];

private static readonly string[] s_reasonsForArrest =
{
[
"trespassing ⛔",
"shoplifting 🛍️",
"stealing a vibrator 📳",
"masturbating in public 💦",
"making too much noise during sex 💋",
};
];

public static void AddCommands(List<CubicBotCommand> commands)
{
Expand Down
4 changes: 2 additions & 2 deletions CubicBot.Telegram/Commands/NonVegan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace CubicBot.Telegram.Commands;
public static class NonVegan
{
private static readonly string[] s_food =
{
[
"🍇", "🍈", "🍉", "🍊", "🍋", "🍌", "🍍", "🥭", "🍎", "🍏",
"🍐", "🍑", "🍒", "🍓", "🫐", "🥝", "🍅", "🫒", "🥥", "🥑",
"🍆", "🥔", "🥕", "🌽", "🌶", "🫑", "🥒", "🥬", "🥦", "🧄",
Expand All @@ -22,7 +22,7 @@ public static class NonVegan
"🍤", "🍥", "🥮", "🍡", "🥟", "🥠", "🥡", "🦀", "🦞", "🦐",
"🦑", "🦪", "🍦", "🍧", "🍨", "🍩", "🍪", "🎂", "🍰", "🧁",
"🥧", "🍫", "🍬", "🍭", "🍮", "🍯", "🦴", "💩", "🤮", "🥵",
};
];

public static void AddCommands(List<CubicBotCommand> commands)
{
Expand Down
16 changes: 8 additions & 8 deletions CubicBot.Telegram/Commands/PublicServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,28 @@ namespace CubicBot.Telegram.Commands;
public static class PublicServices
{
private static readonly string[] s_medicalWorkers =
{
[
"👩‍⚕️", "👩🏻‍⚕️", "👩🏼‍⚕️", "👩🏽‍⚕️", "👩🏾‍⚕️", "👩🏿‍⚕️",
"🧑‍⚕️", "🧑🏻‍⚕️", "🧑🏼‍⚕️", "🧑🏽‍⚕️", "🧑🏾‍⚕️", "🧑🏿‍⚕️",
"👨‍⚕️", "👨🏻‍⚕️", "👨🏼‍⚕️", "👨🏽‍⚕️", "👨🏾‍⚕️", "👨🏿‍⚕️",
};
];

private static readonly string[] s_ambulances =
{
[
"🥼", "🩺", "😷", "🏥", "🚑", "🚨",
};
];

private static readonly string[] s_firefighters =
{
[
"👩‍🚒", "👩🏻‍🚒", "👩🏼‍🚒", "👩🏽‍🚒", "👩🏾‍🚒", "👩🏿‍🚒",
"🧑‍🚒", "🧑🏻‍🚒", "🧑🏼‍🚒", "🧑🏽‍🚒", "🧑🏾‍🚒", "🧑🏿‍🚒",
"👨‍🚒", "👨🏻‍🚒", "👨🏼‍🚒", "👨🏽‍🚒", "👨🏾‍🚒", "👨🏿‍🚒",
};
];

private static readonly string[] s_fireTrucks =
{
[
"🚒", "🧯", "🔥", "❤️‍🔥", "💥", "🚨", "⛑",
};
];

public static void AddCommands(List<CubicBotCommand> commands)
{
Expand Down
4 changes: 2 additions & 2 deletions CubicBot.Telegram/Commands/Systemd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ namespace CubicBot.Telegram.Commands;
public static class Systemd
{
private static readonly string[] s_states =
{
[
"[*** ]",
"[ *** ]",
"[ *** ]",
"[ ***]",
"[* **]",
"[** *]",
};
];

private const string WaitState = "[ WAIT ]";

Expand Down
6 changes: 3 additions & 3 deletions CubicBot.Telegram/CubicBot.Telegram.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<AssemblyName>cubic-bot-telegram</AssemblyName>
<Authors>database64128</Authors>
<Copyright2022 database64128</Copyright>
<Copyright2024 database64128</Copyright>
<Description>A stupid and annoying chatbot for your group chats.</Description>
<Nullable>enable</Nullable>
<OutputType>Exe</OutputType>
Expand All @@ -13,8 +13,8 @@
<Product>Cubic Telegram Bot</Product>
<RepositoryType>Public</RepositoryType>
<RepositoryUrl>https://github.com/database64128/CubicBot</RepositoryUrl>
<TargetFramework>net7.0</TargetFramework>
<Version>1.1.0</Version>
<TargetFramework>net8.0</TargetFramework>
<Version>1.2.0</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions CubicBot.Telegram/Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ public sealed class Data
/// Key is user ID.
/// Value is user stats object.
/// </summary>
public Dictionary<long, UserData> Users { get; set; } = new();
public Dictionary<long, UserData> Users { get; set; } = [];

/// <summary>
/// Gets or sets the dictionary that stores group stats.
/// Key is group ID.
/// Value is group stats object.
/// </summary>
public Dictionary<long, GroupData> Groups { get; set; } = new();
public Dictionary<long, GroupData> Groups { get; set; } = [];

/// <summary>
/// Gets the user's stats object.
Expand Down
2 changes: 1 addition & 1 deletion CubicBot.Telegram/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace CubicBot.Telegram;

internal class Program
{
private static Task Main(string[] args)
private static Task<int> Main(string[] args)
{
var botTokenOption = new CliOption<string?>("--bot-token")
{
Expand Down
4 changes: 2 additions & 2 deletions CubicBot.Telegram/Stats/Grass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ namespace CubicBot.Telegram.Stats;
public sealed class Grass : IStatsCollector
{
private static readonly string[] s_grassSeeds =
{
[
"cao", "艹", "草", "c奥", "c嗷",
};
];

private static bool IsGrowingGrass(string msg) => msg.Length > 0 && s_grassSeeds.Any(seed => msg.Contains(seed));

Expand Down
2 changes: 1 addition & 1 deletion CubicBot.Telegram/Stats/GroupData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace CubicBot.Telegram.Stats;

public sealed class GroupData : ChatData
{
public Dictionary<long, UserData> Members { get; set; } = new();
public Dictionary<long, UserData> Members { get; set; } = [];

/// <summary>
/// Gets the member's stats object.
Expand Down
2 changes: 1 addition & 1 deletion CubicBot.Telegram/Stats/ParenthesisEnclosure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace CubicBot.Telegram.Stats;

public sealed class ParenthesisEnclosure : IStatsCollector
{
private readonly List<char> _compensation = new();
private readonly List<char> _compensation = [];

private static readonly Dictionary<char, char> s_enclosureDict = new()
{
Expand Down
2 changes: 1 addition & 1 deletion CubicBot.Telegram/Stats/StatsDispatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace CubicBot.Telegram.Stats;

public sealed class StatsDispatch : IDispatch
{
private readonly List<IStatsCollector> _collectors = new();
private readonly List<IStatsCollector> _collectors = [];

public StatsDispatch(StatsConfig config)
{
Expand Down
2 changes: 1 addition & 1 deletion CubicBot.Telegram/Stats/UserData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace CubicBot.Telegram.Stats;
public sealed class UserData : ChatData
{
#region 0. Personal
public List<Pronouns> PronounList { get; set; } = new();
public List<Pronouns> PronounList { get; set; } = [];
public Pronouns? DefaultPronouns { get; set; }
public Pronouns? PreferredPronouns { get; set; }
#endregion
Expand Down
2 changes: 1 addition & 1 deletion CubicBot.Telegram/UpdateHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace CubicBot.Telegram;
public sealed class UpdateHandler
{
private readonly Data _data;
private readonly List<IDispatch> _dispatches = new();
private readonly List<IDispatch> _dispatches = [];
private readonly IReadOnlyList<CubicBotCommand> _commands;

public UpdateHandler(string botUsername, Config config, Data data)
Expand Down
4 changes: 2 additions & 2 deletions CubicBot.Telegram/Utils/ChatHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -363,12 +363,12 @@ public static (string? command, string? argument) ParseMessageIntoCommandAndArgu
if (spacePos == -1)
{
command = text;
argument = ReadOnlySpan<char>.Empty;
argument = [];
}
else if (spacePos == text.Length - 1)
{
command = text[..spacePos];
argument = ReadOnlySpan<char>.Empty;
argument = [];
}
else
{
Expand Down

0 comments on commit faf4e23

Please sign in to comment.