.gvc added
This commit is contained in:
parent
57e9c62b11
commit
a89d00ff31
1520
src/NadekoBot/Migrations/20170408162851_game-voice-channel.Designer.cs
generated
Normal file
1520
src/NadekoBot/Migrations/20170408162851_game-voice-channel.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
namespace NadekoBot.Migrations
|
||||||
|
{
|
||||||
|
public partial class gamevoicechannel : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<ulong>(
|
||||||
|
name: "GameVoiceChannel",
|
||||||
|
table: "GuildConfigs",
|
||||||
|
nullable: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "GameVoiceChannel",
|
||||||
|
table: "GuildConfigs");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -533,6 +533,8 @@ namespace NadekoBot.Migrations
|
|||||||
|
|
||||||
b.Property<bool>("FilterWords");
|
b.Property<bool>("FilterWords");
|
||||||
|
|
||||||
|
b.Property<ulong?>("GameVoiceChannel");
|
||||||
|
|
||||||
b.Property<ulong>("GreetMessageChannelId");
|
b.Property<ulong>("GreetMessageChannelId");
|
||||||
|
|
||||||
b.Property<ulong>("GuildId");
|
b.Property<ulong>("GuildId");
|
||||||
|
@ -0,0 +1,131 @@
|
|||||||
|
using Discord;
|
||||||
|
using Discord.Commands;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using NadekoBot.Attributes;
|
||||||
|
using NadekoBot.Services;
|
||||||
|
using NadekoBot.Services.Database;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Discord.WebSocket;
|
||||||
|
using NLog;
|
||||||
|
using NadekoBot.Extensions;
|
||||||
|
|
||||||
|
namespace NadekoBot.Modules.Administration
|
||||||
|
{
|
||||||
|
public partial class Administration
|
||||||
|
{
|
||||||
|
[Group]
|
||||||
|
public class GameChannelCommands : NadekoSubmodule
|
||||||
|
{
|
||||||
|
private static readonly Timer _t;
|
||||||
|
|
||||||
|
private static readonly ConcurrentHashSet<ulong> gameVoiceChannels = new ConcurrentHashSet<ulong>();
|
||||||
|
|
||||||
|
private static new readonly Logger _log;
|
||||||
|
|
||||||
|
static GameChannelCommands()
|
||||||
|
{
|
||||||
|
//_t = new Timer(_ => {
|
||||||
|
|
||||||
|
//}, null, );
|
||||||
|
|
||||||
|
_log = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
|
gameVoiceChannels = new ConcurrentHashSet<ulong>(
|
||||||
|
NadekoBot.AllGuildConfigs.Where(gc => gc.GameVoiceChannel != null)
|
||||||
|
.Select(gc => gc.GameVoiceChannel.Value));
|
||||||
|
|
||||||
|
NadekoBot.Client.UserVoiceStateUpdated += Client_UserVoiceStateUpdated;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Task Client_UserVoiceStateUpdated(SocketUser usr, SocketVoiceState oldState, SocketVoiceState newState)
|
||||||
|
{
|
||||||
|
var _ = Task.Run(async () =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var gUser = usr as SocketGuildUser;
|
||||||
|
if (gUser == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var game = gUser.Game?.Name.TrimTo(50).ToLowerInvariant();
|
||||||
|
|
||||||
|
if (oldState.VoiceChannel == newState.VoiceChannel ||
|
||||||
|
newState.VoiceChannel == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!gameVoiceChannels.Contains(newState.VoiceChannel.Id) ||
|
||||||
|
string.IsNullOrWhiteSpace(game))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var vch = gUser.Guild.VoiceChannels
|
||||||
|
.FirstOrDefault(x => x.Name.ToLowerInvariant() == game);
|
||||||
|
|
||||||
|
if (vch == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
await Task.Delay(1000).ConfigureAwait(false);
|
||||||
|
await gUser.ModifyAsync(gu => gu.Channel = vch).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_log.Warn(ex);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
|
[RequireContext(ContextType.Guild)]
|
||||||
|
[RequireUserPermission(GuildPermission.Administrator)]
|
||||||
|
[RequireBotPermission(GuildPermission.MoveMembers)]
|
||||||
|
public async Task GameVoiceChannel()
|
||||||
|
{
|
||||||
|
var vch = ((IGuildUser)Context.User).VoiceChannel;
|
||||||
|
|
||||||
|
if (vch == null)
|
||||||
|
{
|
||||||
|
await ReplyErrorLocalized("not_in_voice").ConfigureAwait(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ulong? id;
|
||||||
|
using (var uow = DbHandler.UnitOfWork())
|
||||||
|
{
|
||||||
|
var gc = uow.GuildConfigs.For(Context.Guild.Id, set => set);
|
||||||
|
|
||||||
|
if (gc.GameVoiceChannel == vch.Id)
|
||||||
|
{
|
||||||
|
gameVoiceChannels.TryRemove(vch.Id);
|
||||||
|
id = gc.GameVoiceChannel = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(gc.GameVoiceChannel != null)
|
||||||
|
gameVoiceChannels.TryRemove(gc.GameVoiceChannel.Value);
|
||||||
|
gameVoiceChannels.Add(vch.Id);
|
||||||
|
id = gc.GameVoiceChannel = vch.Id;
|
||||||
|
}
|
||||||
|
|
||||||
|
uow.Complete();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (id == null)
|
||||||
|
{
|
||||||
|
await ReplyConfirmLocalized("gvc_disabled").ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gameVoiceChannels.Add(vch.Id);
|
||||||
|
await ReplyConfirmLocalized("gvc_enabled", Format.Bold(vch.Name)).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -140,7 +140,6 @@ namespace NadekoBot.Modules.Gambling
|
|||||||
|
|
||||||
removed = uow.Complete();
|
removed = uow.Complete();
|
||||||
}
|
}
|
||||||
_log.Warn($"Removed {removed} items");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await (await Context.User.CreateDMChannelAsync())
|
await (await Context.User.CreateDMChannelAsync())
|
||||||
|
@ -20,7 +20,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
{
|
{
|
||||||
[NadekoModule("Music", "!!")]
|
[NadekoModule("Music", "!!")]
|
||||||
[DontAutoLoad]
|
[DontAutoLoad]
|
||||||
public class Music : NadekoTopLevelModule
|
public class Music : NadekoTopLevelModule
|
||||||
{
|
{
|
||||||
public static ConcurrentDictionary<ulong, MusicPlayer> MusicPlayers { get; } = new ConcurrentDictionary<ulong, MusicPlayer>();
|
public static ConcurrentDictionary<ulong, MusicPlayer> MusicPlayers { get; } = new ConcurrentDictionary<ulong, MusicPlayer>();
|
||||||
|
|
||||||
|
29
src/NadekoBot/Resources/CommandStrings.Designer.cs
generated
29
src/NadekoBot/Resources/CommandStrings.Designer.cs
generated
@ -3002,6 +3002,33 @@ namespace NadekoBot.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to gvc.
|
||||||
|
/// </summary>
|
||||||
|
public static string gamevoicechannel_cmd {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("gamevoicechannel_cmd", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Toggles game voice channel feature in the voice channel you're currently in. Users who join the game voice channel will get automatically redirected to the voice channel with the name of their current game if it exists. Can't move users to channels that the bot has no connect permission for. One per server..
|
||||||
|
/// </summary>
|
||||||
|
public static string gamevoicechannel_desc {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("gamevoicechannel_desc", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to `{0}gvc`.
|
||||||
|
/// </summary>
|
||||||
|
public static string gamevoicechannel_usage {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("gamevoicechannel_usage", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to gelbooru.
|
/// Looks up a localized string similar to gelbooru.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -7629,7 +7656,7 @@ namespace NadekoBot.Resources {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Adds an item to the list of items for sale in the shop entry given the index..
|
/// Looks up a localized string similar to Adds an item to the list of items for sale in the shop entry given the index. You usually want to run this command in the secret channel, so that the unique items are not leaked..
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string shoplistadd_desc {
|
public static string shoplistadd_desc {
|
||||||
get {
|
get {
|
||||||
|
@ -3417,11 +3417,20 @@
|
|||||||
<data name="buy_usage" xml:space="preserve">
|
<data name="buy_usage" xml:space="preserve">
|
||||||
<value>`{0}buy 2`</value>
|
<value>`{0}buy 2`</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="gamevoicechannel_cmd" xml:space="preserve">
|
||||||
|
<value>gvc</value>
|
||||||
|
</data>
|
||||||
|
<data name="gamevoicechannel_desc" xml:space="preserve">
|
||||||
|
<value>Toggles game voice channel feature in the voice channel you're currently in. Users who join the game voice channel will get automatically redirected to the voice channel with the name of their current game if it exists. Can't move users to channels that the bot has no connect permission for. One per server.</value>
|
||||||
|
</data>
|
||||||
|
<data name="gamevoicechannel_usage" xml:space="preserve">
|
||||||
|
<value>`{0}gvc`</value>
|
||||||
|
</data>
|
||||||
<data name="shoplistadd_cmd" xml:space="preserve">
|
<data name="shoplistadd_cmd" xml:space="preserve">
|
||||||
<value>shoplistadd</value>
|
<value>shoplistadd</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="shoplistadd_desc" xml:space="preserve">
|
<data name="shoplistadd_desc" xml:space="preserve">
|
||||||
<value>Adds an item to the list of items for sale in the shop entry given the index.</value>
|
<value>Adds an item to the list of items for sale in the shop entry given the index. You usually want to run this command in the secret channel, so that the unique items are not leaked.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="shoplistadd_usage" xml:space="preserve">
|
<data name="shoplistadd_usage" xml:space="preserve">
|
||||||
<value>`{0}shoplistadd 1 Uni-que-Steam-Key`</value>
|
<value>`{0}shoplistadd 1 Uni-que-Steam-Key`</value>
|
||||||
|
27
src/NadekoBot/Resources/ResponseStrings.Designer.cs
generated
27
src/NadekoBot/Resources/ResponseStrings.Designer.cs
generated
@ -519,6 +519,24 @@ namespace NadekoBot.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Game Voice Channel feature has been disabled on this server..
|
||||||
|
/// </summary>
|
||||||
|
public static string administration_gvc_disabled {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("administration_gvc_disabled", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to {0} is a Game Voice Channel now..
|
||||||
|
/// </summary>
|
||||||
|
public static string administration_gvc_enabled {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("administration_gvc_enabled", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to You can't use this command on users with a role higher or equal to yours in the role hierarchy..
|
/// Looks up a localized string similar to You can't use this command on users with a role higher or equal to yours in the role hierarchy..
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -916,6 +934,15 @@ namespace NadekoBot.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to You are not in voice channel on this server..
|
||||||
|
/// </summary>
|
||||||
|
public static string administration_not_in_voice {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("administration_not_in_voice", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Old message.
|
/// Looks up a localized string similar to Old message.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -2431,6 +2431,15 @@ Owner ID: {2}</value>
|
|||||||
<value>Next update in {0}</value>
|
<value>Next update in {0}</value>
|
||||||
<comment>Next update in 05:30</comment>
|
<comment>Next update in 05:30</comment>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="administration_gvc_disabled" xml:space="preserve">
|
||||||
|
<value>Game Voice Channel feature has been disabled on this server.</value>
|
||||||
|
</data>
|
||||||
|
<data name="administration_gvc_enabled" xml:space="preserve">
|
||||||
|
<value>{0} is a Game Voice Channel now.</value>
|
||||||
|
</data>
|
||||||
|
<data name="administration_not_in_voice" xml:space="preserve">
|
||||||
|
<value>You are not in voice channel on this server.</value>
|
||||||
|
</data>
|
||||||
<data name="gambling_item" xml:space="preserve">
|
<data name="gambling_item" xml:space="preserve">
|
||||||
<value>Item</value>
|
<value>Item</value>
|
||||||
</data>
|
</data>
|
||||||
|
@ -77,6 +77,7 @@ namespace NadekoBot.Services.Database.Models
|
|||||||
public HashSet<SlowmodeIgnoredRole> SlowmodeIgnoredRoles { get; set; }
|
public HashSet<SlowmodeIgnoredRole> SlowmodeIgnoredRoles { get; set; }
|
||||||
|
|
||||||
public List<ShopEntry> ShopEntries { get; set; }
|
public List<ShopEntry> ShopEntries { get; set; }
|
||||||
|
public ulong? GameVoiceChannel { get; set; } = null;
|
||||||
|
|
||||||
//public List<ProtectionIgnoredChannel> ProtectionIgnoredChannels { get; set; } = new List<ProtectionIgnoredChannel>();
|
//public List<ProtectionIgnoredChannel> ProtectionIgnoredChannels { get; set; } = new List<ProtectionIgnoredChannel>();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user