Compare commits

21 Commits

Author SHA1 Message Date
Karolis2011
060d9e3785 Adds a check 2019-09-05 21:50:59 +03:00
Karolis2011
203811366b Updates things and adds debug options 2019-09-05 21:23:41 +03:00
Karolis2011
e9f59780ed Adds role specific channels.
Read ME update

Updating tile of role will update revelant channels and roles.

Added command examples.

Fixese leaks
2019-08-01 20:25:28 +03:00
Karolis2011
18657d7fab Help part 2 2019-08-01 20:25:28 +03:00
Karolis2011
b5702faa31 Better help part 1 2019-08-01 20:25:28 +03:00
Geeves
9ac6343406 Update EventBot/Modules/EventModule.cs 2019-08-01 20:25:28 +03:00
Geeves
c28ffe2ade Update EventBot/Modules/EventModule.cs 2019-08-01 20:25:28 +03:00
Geeves
92459fb4de Update EventBot/Modules/EventModule.cs 2019-08-01 20:25:28 +03:00
Geeves
32246855fa Update EventBot/Modules/EventModule.cs
Co-Authored-By: Karolis <Karolis2011@users.noreply.github.com>
2019-08-01 20:25:28 +03:00
Geeves
941716b19d Update EventBot/Modules/EventModule.cs
Co-Authored-By: Karolis <Karolis2011@users.noreply.github.com>
2019-08-01 20:25:28 +03:00
Geeves
9ede67c61b Update EventBot/Modules/EventModule.cs
Co-Authored-By: Karolis <Karolis2011@users.noreply.github.com>
2019-08-01 20:25:28 +03:00
Geeves
021c497288 Update EventBot/Modules/EventModule.cs
Co-Authored-By: Karolis <Karolis2011@users.noreply.github.com>
2019-08-01 20:25:27 +03:00
Geeves
5d32d3b611 Update EventBot/Modules/EventModule.cs
Co-Authored-By: Karolis <Karolis2011@users.noreply.github.com>
2019-08-01 20:25:27 +03:00
Geeves
17e08c6f01 Update EventBot/Modules/EventModule.cs
Co-Authored-By: Karolis <Karolis2011@users.noreply.github.com>
2019-08-01 20:25:27 +03:00
Geeves
6ce26b1d39 Update EventBot/Modules/EventModule.cs
Co-Authored-By: Karolis <Karolis2011@users.noreply.github.com>
2019-08-01 20:25:27 +03:00
Geeves
05143db059 Update EventBot/Misc/EventRoleTypeReader.cs
Co-Authored-By: Karolis <Karolis2011@users.noreply.github.com>
2019-08-01 20:25:27 +03:00
Geeves
0522482685 final commit 2019-08-01 20:25:27 +03:00
Karolis2011
e1f376f92c Travis you can do it. 2019-08-01 20:25:27 +03:00
Karolis2011
f73d84803e Addes travis and README 2019-08-01 20:25:27 +03:00
Geeves
2a80032cae spellfixes for commands 2019-08-01 20:25:27 +03:00
Geeves
cea06e205c spellfixes 2019-08-01 20:25:27 +03:00
7 changed files with 63 additions and 17 deletions

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace EventBot.Attributes
{
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
class ExampleAttribute : Attribute
{
public string Use { get; set; }
public ExampleAttribute(string use)
{
Use = use;
}
}
}

View File

@@ -9,15 +9,15 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Discord.Addons.Interactive" Version="1.0.1" /> <PackageReference Include="Discord.Addons.Interactive" Version="1.0.1" />
<PackageReference Include="Discord.Net" Version="2.1.1" /> <PackageReference Include="Discord.Net" Version="2.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.4" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.design" Version="2.2.4" /> <PackageReference Include="Microsoft.EntityFrameworkCore.design" Version="2.2.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="2.2.4" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="2.2.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.4" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.2.4"> <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.2.6">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.7.9" /> <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.9.5" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.2.0" /> <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.2.0" />
</ItemGroup> </ItemGroup>

View File

@@ -88,7 +88,7 @@ namespace EventBot.Modules
.Aggregate(true, (a, r) => a && r)) .Aggregate(true, (a, r) => a && r))
.SelectMany(c => c.Aliases.Select(a => new { CI = c, MA = (c.Aliases[0] == a), A = a }).Reverse()) .SelectMany(c => c.Aliases.Select(a => new { CI = c, MA = (c.Aliases[0] == a), A = a }).Reverse())
.Select((e, i) => new { Command = e, Index = i }) .Select((e, i) => new { Command = e, Index = i })
.GroupBy(o => o.Index / 30) .GroupBy(o => o.Index / 15)
.Select(g => g.Select(o => o.Command)); .Select(g => g.Select(o => o.Command));
var pager = new PaginatedMessage() var pager = new PaginatedMessage()
@@ -130,6 +130,9 @@ namespace EventBot.Modules
embed.AddField("Parameters", embed.AddField("Parameters",
string.Join("\r\n", command.Parameters.Select(p => $"`{p.FormatParameter()}` *(Type: {p.FormatParameterType()})* - **{p.Summary}** {(p.IsRemainder ? "_No quotes are needed, when providing this parameter._" : "")}" )) string.Join("\r\n", command.Parameters.Select(p => $"`{p.FormatParameter()}` *(Type: {p.FormatParameterType()})* - **{p.Summary}** {(p.IsRemainder ? "_No quotes are needed, when providing this parameter._" : "")}" ))
); );
var examples = command.Attributes.Where(a => a is ExampleAttribute).Select(a => ((ExampleAttribute)a).Use).ToArray();
if (examples.Length != 0)
embed.AddField("Examples", $"```{string.Join("\r\n", examples)}```");
await ReplyAsync($"I got this information about command `{commandAlias}`:", embed: embed.Build()); await ReplyAsync($"I got this information about command `{commandAlias}`:", embed: embed.Build());
} }

View File

@@ -9,6 +9,7 @@ using System.Linq;
using EventBot.Entities; using EventBot.Entities;
using Discord.WebSocket; using Discord.WebSocket;
using Discord.Addons.Interactive; using Discord.Addons.Interactive;
using EventBot.Attributes;
namespace EventBot.Modules namespace EventBot.Modules
{ {
@@ -28,6 +29,9 @@ namespace EventBot.Modules
[Alias("j")] [Alias("j")]
[Name("Join event")] [Name("Join event")]
[Summary("Joins latest or specified event with specified event role.")] [Summary("Joins latest or specified event with specified event role.")]
[Example("join :slight_smile:")]
[Example("join 5 \"John Smith\"")]
[Example("join :gun: \"Tpr. James\" 2")]
public async Task JoinEvent( public async Task JoinEvent(
[Summary("Role emote or role ID to join the most recent event.")] string emoteOrId, [Summary("Role emote or role ID to join the most recent event.")] string emoteOrId,
[Summary("Extra information that might be needed by organizers.")] string extraInformation = null, [Summary("Extra information that might be needed by organizers.")] string extraInformation = null,
@@ -129,6 +133,8 @@ namespace EventBot.Modules
[Alias("add", "create")] [Alias("add", "create")]
[Name("Create event")] [Name("Create event")]
[Summary("Creates a new event.")] [Summary("Creates a new event.")]
[Example("event new \"The event\" \"This is going to be a very hard event to organize.\"")]
[Example("event new \"Departmental chaos\" \"This event is about departmental workers rising against heads. Please provide your character name during registration.\" Detailed")]
public async Task CreateEvent( public async Task CreateEvent(
[Summary("Title for the event.")] string title, [Summary("Title for the event.")] string title,
[Summary("Description for the event.")] string description, [Summary("Description for the event.")] string description,
@@ -194,6 +200,8 @@ namespace EventBot.Modules
[Command("update type")] [Command("update type")]
[Name("Update event's type")] [Name("Update event's type")]
[Summary("Updates the event type.")] [Summary("Updates the event type.")]
[Example("event update type Quick")]
[Example("event update type Detailed 3")]
public async Task UpdateEventType( public async Task UpdateEventType(
[Summary("Type of event registration.")] Event.EventParticipactionType type, [Summary("Type of event registration.")] Event.EventParticipactionType type,
[Summary("Event to update, if not specified, updates latest event.")] Event @event = null) [Summary("Event to update, if not specified, updates latest event.")] Event @event = null)
@@ -220,6 +228,9 @@ namespace EventBot.Modules
[Alias("role add", "role create")] [Alias("role add", "role create")]
[Name("Add role")] [Name("Add role")]
[Summary("Adds a new role to the event.")] [Summary("Adds a new role to the event.")]
[Example("event role new \"ERT\" \"Emergency response team that recovers the artifact.\" :gun:")]
[Example("event role new \"Ninja\" \"To sneak around various corners of the station.\" :fire: 1")]
[Example("event role new \"Mercenaries\" \"To go on the station and do stuff.\" :fingers_crossed: 6 2")]
public async Task NewEventRole( public async Task NewEventRole(
[Summary("Title of the role.")] string title, [Summary("Title of the role.")] string title,
[Summary("Description of the role.")] string description, [Summary("Description of the role.")] string description,
@@ -277,6 +288,10 @@ namespace EventBot.Modules
throw new Exception("This event is finalized. Please make a new event."); throw new Exception("This event is finalized. Please make a new event.");
eventRole.Title = title; eventRole.Title = title;
var s = _database.SaveChangesAsync(); var s = _database.SaveChangesAsync();
if (eventRole.ChannelId != 0)
await Context.Guild.GetTextChannel(eventRole.ChannelId).ModifyAsync(p => p.Name = eventRole.ChannelName);
if (eventRole.RoleId != 0)
await Context.Guild.GetRole(eventRole.RoleId).ModifyAsync(p => p.Name = eventRole.Title);
await ReplyAsync($"Updated event role `{eventRole.Id}`'s title to `{eventRole.Title}`"); await ReplyAsync($"Updated event role `{eventRole.Id}`'s title to `{eventRole.Title}`");
await s; await s;
await _events.UpdateEventMessage(eventRole.Event); await _events.UpdateEventMessage(eventRole.Event);
@@ -566,7 +581,10 @@ namespace EventBot.Modules
[Priority(2)] [Priority(2)]
[Command("participant add")] [Command("participant add")]
[Name("Add participant")] [Name("Add participant")]
[Summary("Add user to event role. Acts like join command.")] [Summary("Add user to event role. Acts like join command. Works even if registration is closed.")]
[Example("participant add \"Mini Moose#6944\" :slight_smile:")]
[Example("participant add Arrow768#3092 5 \"John Smith\"")]
[Example("participant add 183658981019877376 :gun: \"Tpr. James\" 2")]
public async Task EventParticipantAdd( public async Task EventParticipantAdd(
[Summary("User ID or discord mention.")] IUser user, [Summary("User ID or discord mention.")] IUser user,
[Summary("Role emote or role ID to join.")] string emoteOrId, [Summary("Role emote or role ID to join.")] string emoteOrId,

View File

@@ -49,12 +49,7 @@ namespace EventBot
private ServiceProvider ConfigureServices() private ServiceProvider ConfigureServices()
{ {
return new ServiceCollection() return new ServiceCollection()
.AddSingleton(s => new DiscordSocketClient(new DiscordSocketConfig() { .AddSingleton(s => new DiscordSocketClient(getDiscordSocketConfig()))
#if DEBUG
LogLevel = LogSeverity.Debug,
#endif
MessageCacheSize = 1500
}))
.AddSingleton<CommandService>() .AddSingleton<CommandService>()
.AddSingleton<CommandHandlingService>() .AddSingleton<CommandHandlingService>()
.AddSingleton<EventManagementService>() .AddSingleton<EventManagementService>()
@@ -69,5 +64,19 @@ namespace EventBot
//.AddSingleton<PictureService>() //.AddSingleton<PictureService>()
.BuildServiceProvider(); .BuildServiceProvider();
} }
private DiscordSocketConfig getDiscordSocketConfig()
{
var config = new DiscordSocketConfig()
{
MessageCacheSize = 1500
};
#if DEBUG
config.LogLevel = LogSeverity.Debug;
#endif
if(Environment.GetEnvironmentVariable("DEBUG") != null)
config.LogLevel = LogSeverity.Debug;
return config;
}
} }
} }

View File

@@ -3,8 +3,8 @@
"EventBot": { "EventBot": {
"commandName": "Project", "commandName": "Project",
"environmentVariables": { "environmentVariables": {
"dbconnection": "Server=localhost;Database=eventbot;User=root;Password=tux;", "dbconnection": "Server=server;Database=eventbot;User=eventbot;Password=password;",
"token": "<insert Token here>" "token": "token here"
} }
}, },
"Docker": { "Docker": {

View File

@@ -58,7 +58,7 @@ namespace EventBot.Services
var context = new SocketCommandContext(_discord, message); var context = new SocketCommandContext(_discord, message);
GuildConfig guildConfig = context.Guild != null ? _database.GuildConfigs.FirstOrDefault(g => g.GuildId == context.Guild.Id) : null; GuildConfig guildConfig = context.Guild != null ? _database.GuildConfigs.FirstOrDefault(g => g.GuildId == context.Guild.Id) : null;
if (!message.HasMentionPrefix(_discord.CurrentUser, ref argPos)) if (!message.HasMentionPrefix(_discord.CurrentUser, ref argPos))
if (guildConfig != null) if (guildConfig != null && string.IsNullOrEmpty(guildConfig.Prefix))
{ {
if (!message.HasStringPrefix(guildConfig.Prefix, ref argPos)) if (!message.HasStringPrefix(guildConfig.Prefix, ref argPos))
return; return;