Fix to v+t, finished typing articles?

This commit is contained in:
Kwoth 2016-09-01 03:12:08 +02:00
parent fdc6967bd0
commit 6d2c9970a7
57 changed files with 757 additions and 908 deletions

View File

@ -0,0 +1,432 @@
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using NadekoBot.Services.Database.Impl;
namespace NadekoBot.Migrations
{
[DbContext(typeof(NadekoSqliteContext))]
[Migration("20160901010812_second")]
partial class second
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
modelBuilder
.HasAnnotation("ProductVersion", "1.0.0-rtm-21431");
modelBuilder.Entity("NadekoBot.Services.Database.Models.BlacklistItem", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int?>("BotConfigId");
b.Property<ulong>("ItemId");
b.HasKey("Id");
b.HasIndex("BotConfigId");
b.ToTable("BlacklistItem");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.BotConfig", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<ulong>("BufferSize");
b.Property<string>("CurrencyName");
b.Property<string>("CurrencyPluralName");
b.Property<string>("CurrencySign");
b.Property<bool>("DontJoinServers");
b.Property<bool>("ForwardMessages");
b.Property<bool>("ForwardToAllOwners");
b.Property<string>("RemindMessageFormat");
b.Property<bool>("RotatingStatuses");
b.HasKey("Id");
b.ToTable("BotConfig");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.ClashCaller", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<bool>("BaseDestroyed");
b.Property<string>("CallUser");
b.Property<int>("ClashWarId");
b.Property<int>("Stars");
b.Property<DateTime>("TimeAdded");
b.HasKey("Id");
b.HasIndex("ClashWarId");
b.ToTable("ClashCallers");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.ClashWar", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<ulong>("ChannelId");
b.Property<string>("EnemyClan");
b.Property<ulong>("GuildId");
b.Property<int>("Size");
b.Property<DateTime>("StartedAt");
b.Property<int>("WarState");
b.HasKey("Id");
b.ToTable("ClashOfClans");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.Currency", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<long>("Amount");
b.Property<ulong>("UserId");
b.HasKey("Id");
b.HasIndex("UserId")
.IsUnique();
b.ToTable("Currency");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.Donator", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("Amount");
b.Property<string>("Name");
b.Property<ulong>("UserId");
b.HasKey("Id");
b.HasIndex("UserId")
.IsUnique();
b.ToTable("Donators");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.EightBallResponse", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int?>("BotConfigId");
b.Property<string>("Text");
b.HasKey("Id");
b.HasIndex("BotConfigId");
b.ToTable("EightBallResponse");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.FollowedStream", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<ulong>("ChannelId");
b.Property<int?>("GuildConfigId");
b.Property<ulong>("GuildId");
b.Property<bool>("LastStatus");
b.Property<int>("Type");
b.Property<string>("Username");
b.HasKey("Id");
b.HasIndex("GuildConfigId");
b.ToTable("FollowedStream");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.GuildConfig", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<ulong>("AutoAssignRoleId");
b.Property<bool>("AutoDeleteByeMessages");
b.Property<bool>("AutoDeleteGreetMessages");
b.Property<int>("AutoDeleteGreetMessagesTimer");
b.Property<bool>("AutoDeleteSelfAssignedRoleMessages");
b.Property<ulong>("ByeMessageChannelId");
b.Property<string>("ChannelByeMessageText");
b.Property<string>("ChannelGreetMessageText");
b.Property<float>("DefaultMusicVolume");
b.Property<bool>("DeleteMessageOnCommand");
b.Property<string>("DmGreetMessageText");
b.Property<bool>("ExclusiveSelfAssignedRoles");
b.Property<ulong>("GreetMessageChannelId");
b.Property<ulong>("GuildId");
b.Property<bool>("SendChannelByeMessage");
b.Property<bool>("SendChannelGreetMessage");
b.Property<bool>("SendDmGreetMessage");
b.Property<bool>("VoicePlusTextEnabled");
b.HasKey("Id");
b.HasIndex("GuildId")
.IsUnique();
b.ToTable("GuildConfigs");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.ModulePrefix", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int?>("BotConfigId");
b.Property<string>("ModuleName");
b.Property<string>("Prefix");
b.HasKey("Id");
b.HasIndex("BotConfigId");
b.ToTable("ModulePrefix");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.PlayingStatus", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int?>("BotConfigId");
b.Property<string>("Status");
b.HasKey("Id");
b.HasIndex("BotConfigId");
b.ToTable("PlayingStatus");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.Quote", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<ulong>("AuthorId");
b.Property<string>("AuthorName")
.IsRequired();
b.Property<ulong>("GuildId");
b.Property<string>("Keyword")
.IsRequired();
b.Property<string>("Text")
.IsRequired();
b.HasKey("Id");
b.ToTable("Quotes");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.RaceAnimal", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int?>("BotConfigId");
b.Property<string>("Icon");
b.Property<string>("Name");
b.HasKey("Id");
b.HasIndex("BotConfigId");
b.ToTable("RaceAnimal");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.Reminder", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<ulong>("ChannelId");
b.Property<bool>("IsPrivate");
b.Property<string>("Message");
b.Property<ulong>("ServerId");
b.Property<ulong>("UserId");
b.Property<DateTime>("When");
b.HasKey("Id");
b.ToTable("Reminders");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.Repeater", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<ulong>("ChannelId");
b.Property<ulong>("GuildId");
b.Property<TimeSpan>("Interval");
b.Property<string>("Message");
b.HasKey("Id");
b.HasIndex("ChannelId")
.IsUnique();
b.ToTable("Repeaters");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.SelfAssignedRole", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<ulong>("GuildId");
b.Property<ulong>("RoleId");
b.HasKey("Id");
b.HasIndex("GuildId", "RoleId")
.IsUnique();
b.ToTable("SelfAssignableRoles");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.TypingArticle", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Author");
b.Property<string>("Text");
b.HasKey("Id");
b.ToTable("TypingArticles");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.BlacklistItem", b =>
{
b.HasOne("NadekoBot.Services.Database.Models.BotConfig")
.WithMany("Blacklist")
.HasForeignKey("BotConfigId");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.ClashCaller", b =>
{
b.HasOne("NadekoBot.Services.Database.Models.ClashWar", "ClashWar")
.WithMany("Bases")
.HasForeignKey("ClashWarId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.EightBallResponse", b =>
{
b.HasOne("NadekoBot.Services.Database.Models.BotConfig")
.WithMany("EightBallResponses")
.HasForeignKey("BotConfigId");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.FollowedStream", b =>
{
b.HasOne("NadekoBot.Services.Database.Models.GuildConfig")
.WithMany("FollowedStreams")
.HasForeignKey("GuildConfigId");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.ModulePrefix", b =>
{
b.HasOne("NadekoBot.Services.Database.Models.BotConfig")
.WithMany("ModulePrefixes")
.HasForeignKey("BotConfigId");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.PlayingStatus", b =>
{
b.HasOne("NadekoBot.Services.Database.Models.BotConfig")
.WithMany("RotatingStatusMessages")
.HasForeignKey("BotConfigId");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.RaceAnimal", b =>
{
b.HasOne("NadekoBot.Services.Database.Models.BotConfig")
.WithMany("RaceAnimals")
.HasForeignKey("BotConfigId");
});
}
}
}

View File

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore.Migrations;
namespace NadekoBot.Migrations
{
public partial class second : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "TypingArticles",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Autoincrement", true),
Author = table.Column<string>(nullable: true),
Text = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_TypingArticles", x => x.Id);
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "TypingArticles");
}
}
}

View File

@ -363,6 +363,20 @@ namespace NadekoBot.Migrations
b.ToTable("SelfAssignableRoles");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.TypingArticle", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Author");
b.Property<string>("Text");
b.HasKey("Id");
b.ToTable("TypingArticles");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.BlacklistItem", b =>
{
b.HasOne("NadekoBot.Services.Database.Models.BotConfig")

View File

@ -13,7 +13,7 @@
////todo Add flags for every event
//namespace NadekoBot.Modules.Administration
//{
// internal class LogCommand : DiscordCommand
// public class LogCommand : DiscordCommand
// {
// private string prettyCurrentTime => $"【{DateTime.Now:HH:mm:ss}】";
@ -373,7 +373,7 @@
// catch { }
// }
// internal override void Init(CommandGroupBuilder cgb)
// public override void Init(CommandGroupBuilder cgb)
// {
// cgb.CreateCommand(Module.Prefix + "spmom")

View File

@ -23,6 +23,7 @@ namespace NadekoBot.Modules.Administration
public VoicePlusTextCommands()
{
NadekoBot.Client.UserUpdated += UserUpdatedEventHandler;
voicePlusTextCache = new ConcurrentDictionary<ulong, bool>();
}
private Task UserUpdatedEventHandler(IGuildUser before, IGuildUser after)

View File

@ -60,7 +60,7 @@ namespace NadekoBot.Modules.Gambling
private ConcurrentQueue<string> animals { get; }
public bool Fail { get; internal set; }
public bool Fail { get; set; }
public List<Participant> participants = new List<Participant>();
private ulong serverId;

View File

@ -17,14 +17,14 @@ namespace NadekoBot.Modules.Gambling
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
[RequireContext(ContextType.Guild)]
public Task Roll(IUserMessage umsg, [Remainder] string arg = null) =>
InternalRoll(umsg, arg, true);
publicRoll(umsg, arg, true);
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
[RequireContext(ContextType.Guild)]
public Task Rolluo(IUserMessage umsg, [Remainder] string arg = null) =>
InternalRoll(umsg, arg, false);
publicRoll(umsg, arg, false);
//todo drawing
private async Task InternalRoll(IUserMessage umsg, string arg, bool ordered)
private async Task publicRoll(IUserMessage umsg, string arg, bool ordered)
{
var channel = (ITextChannel)umsg.Channel;
var r = new Random();

View File

@ -11,11 +11,11 @@
////todo drawing
//namespace NadekoBot.Modules.Gambling
//{
// internal class DrawCommand : DiscordCommand
// public class DrawCommand : DiscordCommand
// {
// public DrawCommand(DiscordModule module) : base(module) { }
// internal override void Init(CommandGroupBuilder cgb)
// public override void Init(CommandGroupBuilder cgb)
// {
// cgb.CreateCommand(Module.Prefix + "draw")
// .Description($"Draws a card from the deck.If you supply number [x], she draws up to 5 cards from the deck. | `{Prefix}draw [x]`")

View File

@ -63,7 +63,7 @@
// private SemaphoreSlim locker = new SemaphoreSlim(1,1);
// internal override void Init(CommandGroupBuilder cgb)
// public override void Init(CommandGroupBuilder cgb)
// {
// cgb.CreateCommand(Module.Prefix + "pick")
// .Description($"Picks a flower planted in this channel. | `{Prefix}pick`")

View File

@ -1,196 +1,190 @@
//using Discord;
//using Discord.Commands;
//using NadekoBot.Classes;
//using NadekoBot.DataModels;
//using NadekoBot.Extensions;
//using System;
//using System.Collections.Concurrent;
//using System.Collections.Generic;
//using System.Diagnostics;
//using System.Linq;
//using System.Threading.Tasks;
using Discord;
using Discord.Commands;
using Discord.WebSocket;
using NadekoBot.Attributes;
using NadekoBot.Extensions;
using NadekoBot.Services;
using NadekoBot.Services.Database;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
////todo DB
////todo Rewrite?
//namespace NadekoBot.Modules.Games
//{
// public static class SentencesProvider
// {
// internal static string GetRandomSentence()
// {
// var data = DbHandler.Instance.GetAllRows<TypingArticle>();
// try
// {
// return data.ToList()[new Random().Next(0, data.Count())].Text;
// }
// catch
// {
// return "Failed retrieving data from parse. Owner didn't add any articles to type using `typeadd`.";
// }
// }
// }
namespace NadekoBot.Modules.Games
{
public class TypingGame
{
public const float WORD_VALUE = 4.5f;
private readonly ITextChannel channel;
public string CurrentSentence;
public bool IsActive;
private readonly Stopwatch sw;
private readonly List<ulong> finishedUserIds;
// public class TypingGame
// {
// public const float WORD_VALUE = 4.5f;
// private readonly Channel channel;
// public string CurrentSentence;
// public bool IsActive;
// private readonly Stopwatch sw;
// private readonly List<ulong> finishedUserIds;
public TypingGame(ITextChannel channel)
{
this.channel = channel;
IsActive = false;
sw = new Stopwatch();
finishedUserIds = new List<ulong>();
}
// public TypingGame(Channel channel)
// {
// this.channel = channel;
// IsActive = false;
// sw = new Stopwatch();
// finishedUserIds = new List<ulong>();
// }
public ITextChannel Channel { get; set; }
// public Channel Channell { get; internal set; }
public async Task<bool> Stop()
{
if (!IsActive) return false;
NadekoBot.Client.MessageReceived -= AnswerReceived;
finishedUserIds.Clear();
IsActive = false;
sw.Stop();
sw.Reset();
await channel.SendMessageAsync("Typing contest stopped").ConfigureAwait(false);
return true;
}
// internal async Task<bool> Stop()
// {
// if (!IsActive) return false;
// NadekoBot.Client.MessageReceived -= AnswerReceived;
// finishedUserIds.Clear();
// IsActive = false;
// sw.Stop();
// sw.Reset();
// await channel.Send("Typing contest stopped").ConfigureAwait(false);
// return true;
// }
// internal async Task Start()
// {
// while (true)
// {
// if (IsActive) return; // can't start running game
// IsActive = true;
// CurrentSentence = SentencesProvider.GetRandomSentence();
// var i = (int)(CurrentSentence.Length / WORD_VALUE * 1.7f);
// await channel.SendMessageAsync($":clock2: Next contest will last for {i} seconds. Type the bolded text as fast as you can.").ConfigureAwait(false);
public async Task Start()
{
while (true)
{
if (IsActive) return; // can't start running game
IsActive = true;
CurrentSentence = GetRandomSentence();
var i = (int)(CurrentSentence.Length / WORD_VALUE * 1.7f);
await channel.SendMessageAsync($":clock2: Next contest will last for {i} seconds. Type the bolded text as fast as you can.").ConfigureAwait(false);
// var msg = await channel.SendMessageAsync("Starting new typing contest in **3**...").ConfigureAwait(false);
// await Task.Delay(1000).ConfigureAwait(false);
// await msg.Edit("Starting new typing contest in **2**...").ConfigureAwait(false);
// await Task.Delay(1000).ConfigureAwait(false);
// await msg.Edit("Starting new typing contest in **1**...").ConfigureAwait(false);
// await Task.Delay(1000).ConfigureAwait(false);
// await msg.Edit($":book:**{CurrentSentence.Replace(" ", " \x200B")}**:book:").ConfigureAwait(false);
// sw.Start();
// HandleAnswers();
var msg = await channel.SendMessageAsync("Starting new typing contest in **3**...").ConfigureAwait(false);
await Task.Delay(1000).ConfigureAwait(false);
await msg.ModifyAsync(m => m.Content = "Starting new typing contest in **2**...").ConfigureAwait(false);
await Task.Delay(1000).ConfigureAwait(false);
await msg.ModifyAsync(m => m.Content = "Starting new typing contest in **1**...").ConfigureAwait(false);
await Task.Delay(1000).ConfigureAwait(false);
await msg.ModifyAsync(m => m.Content = $":book:**{CurrentSentence.Replace(" ", " \x200B")}**:book:").ConfigureAwait(false);
sw.Start();
HandleAnswers();
// while (i > 0)
// {
// await Task.Delay(1000).ConfigureAwait(false);
// i--;
// if (!IsActive)
// return;
// }
while (i > 0)
{
await Task.Delay(1000).ConfigureAwait(false);
i--;
if (!IsActive)
return;
}
// await Stop().ConfigureAwait(false);
// }
// }
await Stop().ConfigureAwait(false);
}
}
// private void HandleAnswers()
// {
// NadekoBot.Client.MessageReceived += AnswerReceived;
// }
public string GetRandomSentence()
{
using (var uow = DbHandler.UnitOfWork())
{
return uow.TypingArticles.GetRandom()?.Text ?? "No typing articles found. Use `>typeadd` command to add a new article for typing.";
}
// private async void AnswerReceived(object sender, MessageEventArgs e)
// {
// try
// {
// if (e.Channel == null || e.Channel.Id != channel.Id || umsg.Author.Id == NadekoBot.Client.CurrentUser.Id) return;
}
// var guess = e.Message.RawText;
private void HandleAnswers()
{
NadekoBot.Client.MessageReceived += AnswerReceived;
}
// var distance = CurrentSentence.LevenshteinDistance(guess);
// var decision = Judge(distance, guess.Length);
// if (decision && !finishedUserIds.Contains(umsg.Author.Id))
// {
// finishedUserIds.Add(umsg.Author.Id);
// await channel.Send($"{umsg.Author.Mention} finished in **{sw.Elapsed.Seconds}** seconds with { distance } errors, **{ CurrentSentence.Length / WORD_VALUE / sw.Elapsed.Seconds * 60 }** WPM!").ConfigureAwait(false);
// if (finishedUserIds.Count % 2 == 0)
// {
// await channel.SendMessageAsync($":exclamation: `A lot of people finished, here is the text for those still typing:`\n\n:book:**{CurrentSentence}**:book:").ConfigureAwait(false);
// }
// }
// }
// catch { }
// }
private async Task AnswerReceived(IMessage imsg)
{
var msg = imsg as IUserMessage;
if (msg == null)
return;
try
{
if (channel== null || channel.Id != channel.Id || msg.Author.Id == NadekoBot.Client.GetCurrentUser().Id) return;
// private bool Judge(int errors, int textLength) => errors <= textLength / 25;
var guess = msg.Content;
// }
var distance = CurrentSentence.LevenshteinDistance(guess);
var decision = Judge(distance, guess.Length);
if (decision && !finishedUserIds.Contains(msg.Author.Id))
{
finishedUserIds.Add(msg.Author.Id);
await channel.SendMessageAsync($"{msg.Author.Mention} finished in **{sw.Elapsed.Seconds}** seconds with { distance } errors, **{ CurrentSentence.Length / WORD_VALUE / sw.Elapsed.Seconds * 60 }** WPM!").ConfigureAwait(false);
if (finishedUserIds.Count % 2 == 0)
{
await channel.SendMessageAsync($":exclamation: `A lot of people finished, here is the text for those still typing:`\n\n:book:**{CurrentSentence}**:book:").ConfigureAwait(false);
}
}
}
catch { }
}
// internal class SpeedTyping : DiscordCommand
// {
private bool Judge(int errors, int textLength) => errors <= textLength / 25;
// public static ConcurrentDictionary<ulong, TypingGame> RunningContests;
}
// public SpeedTyping(DiscordModule module) : base(module)
// {
// RunningContests = new ConcurrentDictionary<ulong, TypingGame>();
// }
[Group]
public class SpeedTypingCommands
{
// public Func<CommandEventArgs, Task> DoFunc() =>
// async e =>
// {
// var game = RunningContests.GetOrAdd(umsg.Author.Server.Id, id => new TypingGame(e.Channel));
public static ConcurrentDictionary<ulong, TypingGame> RunningContests;
// if (game.IsActive)
// {
// await channel.SendMessageAsync(
// $"Contest already running in " +
// $"{game.Channell.Mention} channel.")
// .ConfigureAwait(false);
// }
// else
// {
// await game.Start().ConfigureAwait(false);
// }
// };
public SpeedTypingCommands()
{
RunningContests = new ConcurrentDictionary<ulong, TypingGame>();
}
// private Func<CommandEventArgs, Task> QuitFunc() =>
// async e =>
// {
// TypingGame game;
// if (RunningContests.TryRemove(umsg.Author.Server.Id, out game))
// {
// await game.Stop().ConfigureAwait(false);
// return;
// }
// await channel.SendMessageAsync("No contest to stop on this channel.").ConfigureAwait(false);
// };
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
[RequireContext(ContextType.Guild)]
public async Task TypeStart(IUserMessage msg)
{
var channel = (ITextChannel)msg.Channel;
// internal override void Init(CommandGroupBuilder cgb)
// {
// cgb.CreateCommand(Module.Prefix + "typestart")
// .Description($"Starts a typing contest. | `{Prefix}typestart`")
// .Do(DoFunc());
var game = RunningContests.GetOrAdd(channel.Guild.Id, id => new TypingGame(channel));
// cgb.CreateCommand(Module.Prefix + "typestop")
// .Description($"Stops a typing contest on the current channel. | `{Prefix}typestop`")
// .Do(QuitFunc());
if (game.IsActive)
{
await channel.SendMessageAsync(
$"Contest already running in " +
$"{game.Channel.Mention} channel.")
.ConfigureAwait(false);
}
else
{
await game.Start().ConfigureAwait(false);
}
}
// cgb.CreateCommand(Module.Prefix + "typeadd")
// .Description($"Adds a new article to the typing contest. Owner only. | `{Prefix}typeadd wordswords`")
// .Parameter("text", ParameterType.Unparsed)
// .Do(async e =>
// {
// if (!NadekoBot.IsOwner(umsg.Author.Id) || string.IsNullOrWhiteSpace(text)) return;
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
[RequireContext(ContextType.Guild)]
public async Task TypeStop(IUserMessage imsg)
{
var channel = (ITextChannel)imsg.Channel;
TypingGame game;
if (RunningContests.TryRemove(channel.Guild.Id, out game))
{
await game.Stop().ConfigureAwait(false);
return;
}
await channel.SendMessageAsync("No contest to stop on this channel.").ConfigureAwait(false);
}
// DbHandler.Instance.Connection.Insert(new TypingArticle
// {
// Text = text,
// DateAdded = DateTime.Now
// });
////todo owner only
//[LocalizedCommand, LocalizedDescription, LocalizedSummary]
//[RequireContext(ContextType.Guild)]
//public async Task Typeadd(IUserMessage imsg, [Remainder] string text)
//{
// var channel = (ITextChannel)imsg.Channel;
// await channel.SendMessageAsync("Added new article for typing game.").ConfigureAwait(false);
// });
// }
// }
//}
// using (var uow = DbHandler.UnitOfWork())
// {
// uow.TypingArticles.Add(new Services.Database.Models.TypingArticle
// {
// Author = imsg.Author.Username,
// Text = text
// });
// }
// await channel.SendMessageAsync("Added new article for typing game.").ConfigureAwait(false);
//}
}
}

View File

@ -27,7 +27,7 @@ namespace NadekoBot.Modules.Games.Trivia
return list[rand];
}
internal void Reload()
public void Reload()
{
var arr = JArray.Parse(File.ReadAllText("data/triviaquestions.json"));

View File

@ -234,7 +234,7 @@ namespace NadekoBot.Modules.Music.Classes
});
}
internal void ClearQueue()
public void ClearQueue()
{
actionQueue.Enqueue(() =>
{
@ -256,7 +256,7 @@ namespace NadekoBot.Modules.Music.Classes
});
}
internal Task MoveToVoiceChannel(IVoiceChannel voiceChannel)
public Task MoveToVoiceChannel(IVoiceChannel voiceChannel)
{
if (audioClient?.ConnectionState != ConnectionState.Connected)
throw new InvalidOperationException("Can't move while bot is not connected to voice channel.");
@ -264,13 +264,13 @@ namespace NadekoBot.Modules.Music.Classes
return PlaybackVoiceChannel.ConnectAsync();
}
internal bool ToggleRepeatSong() => this.RepeatSong = !this.RepeatSong;
public bool ToggleRepeatSong() => this.RepeatSong = !this.RepeatSong;
internal bool ToggleRepeatPlaylist() => this.RepeatPlaylist = !this.RepeatPlaylist;
public bool ToggleRepeatPlaylist() => this.RepeatPlaylist = !this.RepeatPlaylist;
internal bool ToggleAutoplay() => this.Autoplay = !this.Autoplay;
public bool ToggleAutoplay() => this.Autoplay = !this.Autoplay;
internal void ThrowIfQueueFull()
public void ThrowIfQueueFull()
{
if (MaxQueueSize == 0)
return;

View File

@ -16,18 +16,18 @@ namespace NadekoBot.Modules.Music.Classes
{
public class SongInfo
{
public string Provider { get; internal set; }
public MusicType ProviderType { get; internal set; }
public string Provider { get; set; }
public MusicType ProviderType { get; set; }
/// <summary>
/// Will be set only if the providertype is normal
/// </summary>
public string Query { get; internal set; }
public string Title { get; internal set; }
public string Uri { get; internal set; }
public string Query { get; set; }
public string Title { get; set; }
public string Uri { get; set; }
}
public class Song
{
public StreamState State { get; internal set; }
public StreamState State { get; set; }
public string PrettyName =>
$"**【 {SongInfo.Title.TrimTo(55)} 】**`{(SongInfo.Provider ?? "-")}` `by {QueuerName}`";
public SongInfo SongInfo { get; }
@ -80,7 +80,7 @@ namespace NadekoBot.Modules.Music.Classes
return this;
}
internal async Task Play(IAudioClient voiceClient, CancellationToken cancelToken)
public async Task Play(IAudioClient voiceClient, CancellationToken cancelToken)
{
var filename = Path.Combine(Music.MusicDataPath, DateTime.Now.UnixTimestamp().ToString());

View File

@ -40,7 +40,7 @@ namespace NadekoBot.Modules.Music.Classes
public bool IsSoundCloudLink(string url) =>
System.Text.RegularExpressions.Regex.IsMatch(url, "(.*)(soundcloud.com|snd.sc)(.*)");
internal async Task<SoundCloudVideo> GetVideoByQueryAsync(string query)
public async Task<SoundCloudVideo> GetVideoByQueryAsync(string query)
{
if (string.IsNullOrWhiteSpace(query))
throw new ArgumentNullException(nameof(query));

View File

@ -204,7 +204,7 @@ namespace NadekoBot.Modules.NSFW
}
internal static async Task<string> GetE621ImageLink(string tags)
public static async Task<string> GetE621ImageLink(string tags)
{
try
{

View File

@ -30,7 +30,7 @@
// }
// internal override void Init(CommandGroupBuilder cgb)
// public override void Init(CommandGroupBuilder cgb)
// {
// cgb.CreateCommand(Module.Prefix + "convert")
// .Description($"Convert quantities from>to. | `{Prefix}convert m>km 1000`")

View File

@ -113,7 +113,7 @@ namespace NadekoBot.Modules.Searches
// public float StatScore { get; set; }
// }
// internal override void Init(CommandGroupBuilder cgb)
// public override void Init(CommandGroupBuilder cgb)
// {
// cgb.CreateCommand(Module.Prefix + "lolchamp")
// .Description($"Shows League Of Legends champion statistics. If there are spaces/apostrophes or in the name - omit them. Optional second parameter is a role. |`{Prefix}lolchamp Riven` or `{Prefix}lolchamp Annie sup`")

View File

@ -11,7 +11,7 @@
////todo rewrite
//namespace NadekoBot.Modules.Trello
//{
// internal class Trello : DiscordModule
// public class Trello : DiscordModule
// {
// private readonly Timer t = new Timer { Interval = 2000 };
// public override string Prefix { get; } = NadekoBot.Config.CommandPrefixes.Trello;

View File

@ -28,7 +28,7 @@ namespace NadekoBot.Resources {
private static global::System.Globalization.CultureInfo resourceCulture;
internal CommandStrings() {
public CommandStrings() {
}
/// <summary>

View File

@ -28,7 +28,7 @@ namespace NadekoBot.Resources {
private static global::System.Globalization.CultureInfo resourceCulture;
internal ResponseStrings() {
public ResponseStrings() {
}
/// <summary>

View File

@ -29,7 +29,7 @@ namespace NadekoBot.Services.Database.Models
public ulong ChannelId { get; set; }
[NotMapped]
public ITextChannel Channel { get; internal set; }
public ITextChannel Channel { get; set; }
public List<ClashCaller> Bases { get; set; }
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NadekoBot.Services.Database.Models
{
public class TypingArticle : DbEntity
{
public string Author { get; set; }
public string Text { get; set; }
}
}

View File

@ -20,6 +20,7 @@ namespace NadekoBot.Services.Database
public DbSet<BotConfig> BotConfig { get; set; }
public DbSet<Repeater> Repeaters { get; set; }
public DbSet<Currency> Currency { get; set; }
public DbSet<TypingArticle> TypingArticles { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{

View File

@ -0,0 +1,14 @@
using NadekoBot.Services.Database.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NadekoBot.Services.Database.Repositories
{
public interface ITypingArticlesRepository : IRepository <TypingArticle>
{
TypingArticle GetRandom();
}
}

View File

@ -0,0 +1,25 @@
using NadekoBot.Services.Database.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
namespace NadekoBot.Services.Database.Repositories.Impl
{
public class TypingArticlesRepository : Repository<TypingArticle>, ITypingArticlesRepository
{
private Random _rand = null;
private Random rand => _rand ?? (_rand = new Random());
public TypingArticlesRepository(DbContext context) : base(context)
{
}
public TypingArticle GetRandom()
{
var skip = (int)(rand.NextDouble() * _set.Count());
return _set.Skip(skip).FirstOrDefault();
}
}
}

View File

@ -39,6 +39,9 @@ namespace NadekoBot.Services.Database
private ICurrencyRepository _currency;
public ICurrencyRepository Currency => _currency ?? (_currency = new CurrencyRepository(_context));
private ITypingArticlesRepository _typingArticles;
public ITypingArticlesRepository TypingArticles => _typingArticles ?? (_typingArticles = new TypingArticlesRepository(_context));
public UnitOfWork(NadekoContext context)
{
_context = context;

View File

@ -11,7 +11,7 @@ using System.Threading.Tasks;
namespace NadekoBot.Classes
{
internal class SpecificConfigurations
public class SpecificConfigurations
{
public static SpecificConfigurations Default { get; } = new SpecificConfigurations();
public static bool Instantiated { get; private set; }
@ -73,7 +73,7 @@ namespace NadekoBot.Classes
}
}
internal class ServerSpecificConfig : INotifyPropertyChanged
public class ServerSpecificConfig : INotifyPropertyChanged
{
[JsonProperty("VoicePlusTextEnabled")]
private bool voicePlusTextEnabled;

View File

@ -1,20 +0,0 @@
using Newtonsoft.Json;
namespace NadekoBot.DataModels
{
internal class Announcement : IDataModel
{
public long ServerId { get; set; } = 0;
public bool Greet { get; set; } = false;
public bool GreetPM { get; set; } = false;
[JsonProperty("greetChannel")]
public long GreetChannelId { get; set; } = 0;
public string GreetText { get; set; } = "Welcome %user%!";
public bool Bye { get; set; } = false;
public bool ByePM { get; set; } = false;
[JsonProperty("byeChannel")]
public long ByeChannelId { get; set; } = 0;
public string ByeText { get; set; } = "%user% has left the server.";
public bool DeleteGreetMessages { get; set; } = true;
}
}

View File

@ -1,11 +0,0 @@
namespace NadekoBot.DataModels {
internal class Command : IDataModel {
public long UserId { get; set; }
public string UserName { get; set; }
public long ServerId { get; set; }
public string ServerName { get; set; }
public long ChannelId { get; set; }
public string ChannelName { get; set; }
public string CommandName { get; set; }
}
}

View File

@ -1,7 +0,0 @@
namespace NadekoBot.DataModels {
internal class CurrencyState : IDataModel {
public long Value { get; set; }
[SQLite.Unique]
public long UserId { get; set; }
}
}

View File

@ -1,7 +0,0 @@
namespace NadekoBot.DataModels {
internal class CurrencyTransaction : IDataModel {
public string Reason { get; set; }
public int Value { get; set; }
public long UserId { get; set; }
}
}

View File

@ -1,7 +0,0 @@
namespace NadekoBot.DataModels {
internal class Donator : IDataModel {
public long UserId { get; set; }
public string UserName { get; set; }
public int Amount { get; set; }
}
}

View File

@ -1,14 +0,0 @@
using SQLite;
using System;
namespace NadekoBot.DataModels
{
internal abstract class IDataModel
{
[PrimaryKey, AutoIncrement]
public int? Id { get; set; }
[Newtonsoft.Json.JsonProperty("createdAt")]
public DateTime DateAdded { get; set; } = DateTime.Now;
public IDataModel() { }
}
}

View File

@ -1,10 +0,0 @@
namespace NadekoBot.DataModels
{
class Incident : IDataModel
{
public long ServerId { get; set; }
public long ChannelId { get; set; }
public string Text { get; set; }
public bool Read { get; set; } = false;
}
}

View File

@ -1,9 +0,0 @@
namespace NadekoBot.DataModels
{
internal class MusicPlaylist : IDataModel
{
public string Name { get; set; }
public long CreatorId { get; set; }
public string CreatorName { get; set; }
}
}

View File

@ -1,8 +0,0 @@
namespace NadekoBot.DataModels
{
internal class PlaylistSongInfo : IDataModel
{
public int PlaylistId { get; set; }
public int SongInfoId { get; set; }
}
}

View File

@ -1,14 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NadekoBot.DataModels
{
class UserPokeTypes : IDataModel
{
public long UserId { get; set; }
public string type { get; set; }
}
}

View File

@ -1,10 +0,0 @@
namespace NadekoBot.DataModels {
internal class Request : IDataModel {
public string UserName { get; set; }
public long UserId { get; set; }
public string ServerName { get; set; }
public long ServerId { get; set; }
[Newtonsoft.Json.JsonProperty("Request")]
public string RequestText { get; set; }
}
}

View File

@ -1,14 +0,0 @@
using SQLite;
namespace NadekoBot.DataModels
{
internal class SongInfo : IDataModel
{
public string Provider { get; internal set; }
public int ProviderType { get; internal set; }
public string Title { get; internal set; }
public string Uri { get; internal set; }
[Unique]
public string Query { get; internal set; }
}
}

View File

@ -1,10 +0,0 @@
using System;
namespace NadekoBot.DataModels {
internal class Stats : IDataModel {
public int ConnectedServers { get; set; }
public int OnlineUsers { get; set; }
public TimeSpan Uptime { get; set; }
public int RealOnlineUsers { get; set; }
}
}

View File

@ -1,8 +0,0 @@
namespace NadekoBot.DataModels
{
internal class TestDataModel : IDataModel
{
public long TestNumber { get; set; }
public string TestString { get; set; }
}
}

View File

@ -1,5 +0,0 @@
namespace NadekoBot.DataModels {
internal class TypingArticle : IDataModel {
public string Text { get; set; }
}
}

View File

@ -1,7 +0,0 @@
namespace NadekoBot.DataModels {
internal class UserQuote : IDataModel {
public string UserName { get; set; }
public string Keyword { get; set; }
public string Text { get; set; }
}
}

View File

@ -1,20 +0,0 @@
namespace NadekoBot.Classes.JSONModels
{
public class AnimeResult
{
public int id;
public string airing_status;
public string title_english;
public int total_episodes;
public string description;
public string image_url_lge;
public override string ToString() =>
"`Title:` **" + title_english +
"**\n`Status:` " + airing_status +
"\n`Episodes:` " + total_episodes +
"\n`Link:` http://anilist.co/anime/" + id +
"\n`Synopsis:` " + description.Substring(0, description.Length > 500 ? 500 : description.Length) + "..." +
"\n`img:` " + image_url_lge;
}
}

View File

@ -1,246 +0,0 @@
using Discord;
using NadekoBot.Extensions;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Serialization;
using System.Threading;
using System.Threading.Tasks;
namespace NadekoBot.Classes.JSONModels
{
public class Configuration
{
[JsonIgnore]
public static readonly Dictionary<string, List<string>> DefaultCustomReactions = new Dictionary<string, List<string>>
{
{@"\o\", new List<string>()
{ "/o/" } },
{"/o/", new List<string>()
{ @"\o\" } },
{"moveto", new List<string>() {
@"(👉 ͡° ͜ʖ ͡°)👉 %target%" } },
{"comeatmebro", new List<string>() {
"%target% (ง’̀-‘́)ง" } },
{"e", new List<string>() {
"%user% did it 😒 🔫",
"%target% did it 😒 🔫" } },
{"%mention% insult", new List<string>() {
"%target% You are a poop.",
"%target% You're a jerk.",
"%target% I will eat you when I get my powers back."
} },
{"%mention% praise", new List<string>()
{
"%target% You are cool.",
"%target% You are nice!",
"%target% You did a good job.",
"%target% You did something nice.",
"%target% is awesome!",
"%target% Wow."
} },
{"%mention% pat", new List<string>() {
"http://i.imgur.com/IiQwK12.gif",
"http://i.imgur.com/JCXj8yD.gif",
"http://i.imgur.com/qqBl2bm.gif",
"http://i.imgur.com/eOJlnwP.gif",
"https://45.media.tumblr.com/229ec0458891c4dcd847545c81e760a5/tumblr_mpfy232F4j1rxrpjzo1_r2_500.gif",
"https://media.giphy.com/media/KZQlfylo73AMU/giphy.gif",
"https://media.giphy.com/media/12hvLuZ7uzvCvK/giphy.gif",
"http://gallery1.anivide.com/_full/65030_1382582341.gif",
"https://49.media.tumblr.com/8e8a099c4eba22abd3ec0f70fd087cce/tumblr_nxovj9oY861ur1mffo1_500.gif ",
} },
{"%mention% cry", new List<string>()
{
"http://i.imgur.com/Xg3i1Qy.gif",
"http://i.imgur.com/3K8DRrU.gif",
"http://i.imgur.com/k58BcAv.gif",
"http://i.imgur.com/I2fLXwo.gif"
} },
{"%mention% are you real?", new List<string>()
{
"%user%, I will be soon."
} },
{"%mention% are you there?", new List<string>()
{
"Yes. :)"
} },
{"%mention% draw", new List<string>() {
"Sorry, I don't gamble, type $draw for that function."
} },
{"%mention% bb", new List<string>()
{
"Bye %target%"
} },
{"%mention% call", new List<string>() {
"Calling %target%"
} },
{"%mention% disguise", new List<string>() {
"https://cdn.discordapp.com/attachments/140007341880901632/156721710458994690/Cc5mixjUYAADgBs.jpg",
"https://cdn.discordapp.com/attachments/140007341880901632/156721715831898113/hqdefault.jpg",
"https://cdn.discordapp.com/attachments/140007341880901632/156721724430352385/okawari_01_haruka_weird_mask.jpg",
"https://cdn.discordapp.com/attachments/140007341880901632/156721728763068417/mustache-best-girl.png"
} },
{"%mention% inv", new List<string>() {
"To invite your bot, click on this link -> <https://discordapp.com/oauth2/authorize?client_id=%target%&scope=bot&permissions=66186303>"
} },
{ "%mention% threaten", new List<string>() {
"You wanna die, %target%?"
} },
{ "%mention% archer", new List<string>() {
"http://i.imgur.com/Bha9NhL.jpg"
} }
};
public bool DontJoinServers { get; set; } = false;
public bool ForwardMessages { get; set; } = true;
public bool ForwardToAllOwners { get; set; } = false;
public bool IsRotatingStatus { get; set; } = false;
public int BufferSize { get; set; } = 4.MiB();
public string[] RaceAnimals { get; internal set; } = {
"🐼",
"🐻",
"🐧",
"🐨",
"🐬",
"🐞",
"🦀",
"🦄" };
[JsonIgnore]
public List<Quote> Quotes { get; set; } = new List<Quote>();
[JsonIgnore]
public List<PokemonType> PokemonTypes { get; set; } = new List<PokemonType>();
public string RemindMessageFormat { get; set; } = "❗⏰**I've been told to remind you to '%message%' now by %user%.**⏰❗";
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public Dictionary<string, List<string>> CustomReactions { get; set; }
public List<string> RotatingStatuses { get; set; } = new List<string>();
public CommandPrefixesModel CommandPrefixes { get; set; } = new CommandPrefixesModel();
public HashSet<ulong> ServerBlacklist { get; set; } = new HashSet<ulong>();
public HashSet<ulong> ChannelBlacklist { get; set; } = new HashSet<ulong>();
public HashSet<ulong> UserBlacklist { get; set; } = new HashSet<ulong>() {
105309315895693312,
119174277298782216,
143515953525817344
};
[OnDeserialized]
internal void OnDeserialized(StreamingContext context)
{
if (CustomReactions == null)
{
CustomReactions = DefaultCustomReactions;
}
}
[OnSerializing]
internal void OnSerializing(StreamingContext context)
{
if (CustomReactions == null)
{
CustomReactions = DefaultCustomReactions;
}
}
public string[] _8BallResponses { get; set; } =
{
"Most definitely yes",
"For sure",
"As I see it, yes",
"My sources say yes",
"Yes",
"Most likely",
"Perhaps",
"Maybe",
"Not sure",
"It is uncertain",
"Ask me again later",
"Don't count on it",
"Probably not",
"Very doubtful",
"Most likely no",
"Nope",
"No",
"My sources say no",
"Dont even think about it",
"Definitely no",
"NO - It may cause disease contraction"
};
public string CurrencySign { get; set; } = "🌸";
public string CurrencyName { get; set; } = "NadekoFlower";
public string DMHelpString { get; set; } = "Type `-h` for help.";
public string HelpString { get; set; } = @"You can use `{0}modules` command to see a list of all modules.
You can use `{0}commands ModuleName`
(for example `{0}commands Administration`) to see a list of all of the commands in that module.
For a specific command help, use `{0}h ""Command name""` (for example `-h ""!m q""`)
**LIST OF COMMANDS CAN BE FOUND ON THIS LINK**
<https://github.com/Kwoth/NadekoBot/blob/master/commandlist.md>
Nadeko Support Server: <https://discord.gg/0ehQwTK2RBjAxzEY>";
}
public class CommandPrefixesModel
{
public string Administration { get; set; } = ".";
public string Searches { get; set; } = "~";
public string NSFW { get; set; } = "~";
public string Conversations { get; set; } = "<@{0}>";
public string ClashOfClans { get; set; } = ",";
public string Help { get; set; } = "-";
public string Music { get; set; } = "!!";
public string Trello { get; set; } = "trello ";
public string Games { get; set; } = ">";
public string Gambling { get; set; } = "$";
public string Permissions { get; set; } = ";";
public string Programming { get; set; } = "%";
public string Pokemon { get; set; } = ">";
public string Utility { get; set; } = ".";
}
public static class ConfigHandler
{
private static readonly SemaphoreSlim configLock = new SemaphoreSlim(1, 1);
public static async Task SaveConfig()
{
await configLock.WaitAsync();
try
{
File.WriteAllText("data/config.json", JsonConvert.SerializeObject(NadekoBot.Config, Formatting.Indented));
}
finally
{
configLock.Release();
}
}
public static bool IsBlackListed(MessageEventArgs evArgs) => IsUserBlacklisted(evArgs.User.Id) ||
(!evArgs.Channel.IsPrivate &&
(IsChannelBlacklisted(evArgs.Channel.Id) || IsServerBlacklisted(evArgs.Server.Id)));
public static bool IsServerBlacklisted(ulong id) => NadekoBot.Config.ServerBlacklist.Contains(id);
public static bool IsChannelBlacklisted(ulong id) => NadekoBot.Config.ChannelBlacklist.Contains(id);
public static bool IsUserBlacklisted(ulong id) => NadekoBot.Config.UserBlacklist.Contains(id);
}
public class Quote
{
public string Author { get; set; }
public string Text { get; set; }
public override string ToString() =>
$"{Text}\n\t*-{Author}*";
}
}

View File

@ -1,50 +0,0 @@
using System.IO;
namespace NadekoBot.Classes.JSONModels {
public class LocalizedStrings {
public string[] Insults { get; set; } = {
" You are a poop.", " You're a jerk.",
" I will eat you when I get my powers back."
};
public string[] Praises { get; set; } = {
" You are cool.",
" You are nice!",
" You did a good job.",
" You did something nice.",
" is awesome!",
" Wow."
};
public static string[] GetAvailableLocales() {
Directory.CreateDirectory("data/locales");
return Directory.GetFiles("data/locales");
}
//public static void HandleLocalization() {
// var locales = LocalizedStrings.GetAvailableLocales();
// Console.WriteLine("Pick a language:\n" +
// "1. English");
// for (var i = 0; i < locales.Length; i++) {
// Console.WriteLine((i + 2) + ". " + Path.GetFileNameWithoutExtension(locales[i]));
// }
// File.WriteAllText("data/locales/english.json", JsonConvert.SerializeObject(new LocalizedStrings(), Formatting.Indented));
// try {
// Console.WriteLine($"Type in a number from {1} to {locales.Length + 1}\n");
// var input = Console.ReadLine();
// if (input != "1")
// Locale = LocalizedStrings.LoadLocale(locales[int.Parse(input) - 2]);
// } catch (Exception ex) {
// Console.ForegroundColor = ConsoleColor.Red;
// Console.WriteLine(ex);
// Console.ReadKey();
// return;
// }
//}
public static LocalizedStrings LoadLocale(string localeFile) =>
Newtonsoft.Json.JsonConvert.DeserializeObject<LocalizedStrings>(File.ReadAllText(localeFile));
}
}

View File

@ -1,16 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NadekoBot.Classes.JSONModels
{
class MagicItem
{
public string Name { get; set; }
public string Description { get; set; }
public override string ToString() =>
$"✨`{Name}`\n\t*{Description}*";
}
}

View File

@ -1,33 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NadekoBot.Classes.JSONModels
{
public class PokemonType
{
public PokemonType(string n, string i, string[] m, List<PokemonMultiplier> multi)
{
Name = n;
Icon = i;
Moves = m;
Multipliers = multi;
}
public string Name { get; set; }
public List<PokemonMultiplier> Multipliers { get; set; }
public string Icon { get; set; }
public string[] Moves { get; set; }
}
public class PokemonMultiplier
{
public PokemonMultiplier(string t, double m)
{
Type = t;
Multiplication = m;
}
public string Type { get; set; }
public double Multiplication { get; set; }
}
}

View File

@ -1,155 +0,0 @@
// ReSharper disable InconsistentNaming
using System.Diagnostics;
namespace NadekoBot.Classes.JSONModels
{
public class Credentials
{
public string Token { get; set; } = "";
public string ClientId { get; set; } = "170254782546575360";
public ulong BotId { get; set; } = 1231231231231;
public ulong[] OwnerIds { get; set; } = { 123123123123, 5675675679845 };
public string GoogleAPIKey { get; set; } = "";
public string SoundCloudClientID { get; set; } = "";
public string MashapeKey { get; set; } = "";
public string LOLAPIKey { get; set; } = "";
public string TrelloAppKey { get; set; } = "";
public string CarbonKey { get; set; } = "";
public string OsuAPIKey { get; set; } = "";
}
[DebuggerDisplay("{items[0].id.playlistId}")]
public class YoutubePlaylistSearch
{
public YtPlaylistItem[] items { get; set; }
}
public class YtPlaylistItem
{
public YtPlaylistId id { get; set; }
}
public class YtPlaylistId
{
public string kind { get; set; }
public string playlistId { get; set; }
}
[DebuggerDisplay("{items[0].id.videoId}")]
public class YoutubeVideoSearch
{
public YtVideoItem[] items { get; set; }
}
public class YtVideoItem
{
public YtVideoId id { get; set; }
}
public class YtVideoId
{
public string kind { get; set; }
public string videoId { get; set; }
}
public class PlaylistItemsSearch
{
public string nextPageToken { get; set; }
public PlaylistItem[] items { get; set; }
}
public class PlaylistItem
{
public YtVideoId contentDetails { get; set; }
}
#region wikpedia example
// {
// "batchcomplete": true,
// "query": {
// "normalized": [
// {
// "from": "u3fn92fb32f9yb329f32",
// "to": "U3fn92fb32f9yb329f32"
// }
// ],
// "pages": [
// {
// "ns": 0,
// "title": "U3fn92fb32f9yb329f32",
// "missing": true,
// "contentmodel": "wikitext",
// "pagelanguage": "en",
// "pagelanguagehtmlcode": "en",
// "pagelanguagedir": "ltr",
// "fullurl": "https://en.wikipedia.org/wiki/U3fn92fb32f9yb329f32",
// "editurl": "https://en.wikipedia.org/w/index.php?title=U3fn92fb32f9yb329f32&action=edit",
// "canonicalurl": "https://en.wikipedia.org/wiki/U3fn92fb32f9yb329f32"
// }
// ]
// }
//}
#endregion
public class WikipediaApiModel
{
public WikipediaQuery Query { get; set; }
}
public class WikipediaQuery
{
public WikipediaPage[] Pages { get; set; }
}
public class WikipediaPage
{
public bool Missing { get; set; } = false;
public string FullUrl { get; set; }
}
public class WoWJoke
{
public string Question { get; set; }
public string Answer { get; set; }
public override string ToString() => $"`{Question}`\n\n**{Answer}**";
}
}
//{
// "kind": "youtube#searchListResponse",
// "etag": "\"kiOs9cZLH2FUp6r6KJ8eyq_LIOk/hCJTmyH_v57mh_MvnUFSTHfjzBs\"",
// "nextPageToken": "CAEQAA",
// "regionCode": "RS",
// "pageInfo": {
// "totalResults": 4603,
// "resultsPerPage": 1
// },
// "items": [
// {
// "kind": "youtube#searchResult",
// "etag": "\"kiOs9cZLH2FUp6r6KJ8eyq_LIOk/iD1S35mk0xOfwTB_8lpPZ9u-Vzc\"",
// "id": {
// "kind": "youtube#playlist",
// "playlistId": "PLs_KC2CCxJVMfOBnIyW5Kbu_GciNiYNAI"
// },
// "snippet": {
// "publishedAt": "2016-04-14T11:35:29.000Z",
// "channelId": "UCMLwm18Qa20L2L-HGpgC3jQ",
// "title": "Popular Videos - Otorimonogatari & mousou express",
// "description": "",
// "thumbnails": {
// "default": {
// "url": "https://i.ytimg.com/vi/2FeptLky2mU/default.jpg",
// "width": 120,
// "height": 90
// },
// "medium": {
// "url": "https://i.ytimg.com/vi/2FeptLky2mU/mqdefault.jpg",
// "width": 320,
// "height": 180
// },
// "high": {
// "url": "https://i.ytimg.com/vi/2FeptLky2mU/hqdefault.jpg",
// "width": 480,
// "height": 360
// }
// },
// "channelTitle": "Otorimonogatari - Topic",
// "liveBroadcastContent": "none"
// }
// }
// ]
//}

View File

@ -9,7 +9,7 @@ using System.Text.RegularExpressions;
namespace NadekoBot.Modules.CustomReactions
{
internal class CustomReactionsModule : DiscordModule
public class CustomReactionsModule : DiscordModule
{
public override string Prefix { get; } = "";

View File

@ -34,6 +34,6 @@ namespace NadekoBot.Classes
/// <summary>
/// Initializes the CommandBuilder with values using CommandGroupBuilder
/// </summary>
internal abstract void Init(CommandGroupBuilder cgb);
public abstract void Init(CommandGroupBuilder cgb);
}
}

View File

@ -10,7 +10,7 @@ using System.Threading.Tasks;
namespace NadekoBot.Modules.Permissions.Classes
{
internal class PermissionChecker : IPermissionChecker
public class PermissionChecker : IPermissionChecker
{
public static PermissionChecker Instance { get; } = new PermissionChecker();

View File

@ -6,7 +6,7 @@ using System.Linq;
namespace NadekoBot.Modules.Permissions.Classes
{
internal static class PermissionHelper
public static class PermissionHelper
{
public static bool ValidateBool(string passedArg)
{
@ -37,7 +37,7 @@ namespace NadekoBot.Modules.Permissions.Classes
}
}
internal static string ValidateModule(string mod)
public static string ValidateModule(string mod)
{
if (string.IsNullOrWhiteSpace(mod))
throw new ArgumentNullException(nameof(mod));
@ -50,7 +50,7 @@ namespace NadekoBot.Modules.Permissions.Classes
throw new ArgumentException("That module does not exist.");
}
internal static string ValidateCommand(string commandText)
public static string ValidateCommand(string commandText)
{
if (string.IsNullOrWhiteSpace(commandText))
throw new ArgumentNullException(nameof(commandText));
@ -65,7 +65,7 @@ namespace NadekoBot.Modules.Permissions.Classes
throw new NullReferenceException("That command does not exist.");
}
internal static Role ValidateRole(Server server, string roleName)
public static Role ValidateRole(Server server, string roleName)
{
if (string.IsNullOrWhiteSpace(roleName))
throw new ArgumentNullException(nameof(roleName));
@ -78,7 +78,7 @@ namespace NadekoBot.Modules.Permissions.Classes
return role;
}
internal static Channel ValidateChannel(Server server, string channelName)
public static Channel ValidateChannel(Server server, string channelName)
{
if (string.IsNullOrWhiteSpace(channelName))
throw new ArgumentNullException(nameof(channelName));
@ -88,7 +88,7 @@ namespace NadekoBot.Modules.Permissions.Classes
return channel;
}
internal static User ValidateUser(Server server, string userName)
public static User ValidateUser(Server server, string userName)
{
if (string.IsNullOrWhiteSpace(userName))
throw new ArgumentNullException(nameof(userName));

View File

@ -41,7 +41,7 @@ namespace NadekoBot.Modules.Permissions.Classes
Console.WriteLine("Permission initialization complete.");
}
internal static Permissions GetRolePermissionsById(Server server, ulong id)
public static Permissions GetRolePermissionsById(Server server, ulong id)
{
ServerPermissions serverPerms;
if (!PermissionsDict.TryGetValue(server.Id, out serverPerms))
@ -52,7 +52,7 @@ namespace NadekoBot.Modules.Permissions.Classes
return toReturn;
}
internal static Permissions GetUserPermissionsById(Server server, ulong id)
public static Permissions GetUserPermissionsById(Server server, ulong id)
{
ServerPermissions serverPerms;
if (!PermissionsDict.TryGetValue(server.Id, out serverPerms))
@ -63,7 +63,7 @@ namespace NadekoBot.Modules.Permissions.Classes
return toReturn;
}
internal static Permissions GetChannelPermissionsById(Server server, ulong id)
public static Permissions GetChannelPermissionsById(Server server, ulong id)
{
ServerPermissions serverPerms;
if (!PermissionsDict.TryGetValue(server.Id, out serverPerms))
@ -74,13 +74,13 @@ namespace NadekoBot.Modules.Permissions.Classes
return toReturn;
}
internal static Permissions GetServerPermissions(Server server)
public static Permissions GetServerPermissions(Server server)
{
ServerPermissions serverPerms;
return !PermissionsDict.TryGetValue(server.Id, out serverPerms) ? null : serverPerms.Permissions;
}
internal static PermissionBanType GetPermissionBanType(Command command, User user, Channel channel)
public static PermissionBanType GetPermissionBanType(Command command, User user, Channel channel)
{
var server = user.Server;
ServerPermissions serverPerms = PermissionsDict.GetOrAdd(server.Id, id => new ServerPermissions(id, server.Name));
@ -174,7 +174,7 @@ namespace NadekoBot.Modules.Permissions.Classes
return serverPerms.PermissionsControllerRole;
}
internal static async Task SetPermissionsRole(Server server, string roleName)
public static async Task SetPermissionsRole(Server server, string roleName)
{
var serverPerms = PermissionsDict.GetOrAdd(server.Id,
new ServerPermissions(server.Id, server.Name));
@ -183,7 +183,7 @@ namespace NadekoBot.Modules.Permissions.Classes
await WriteServerToJson(serverPerms).ConfigureAwait(false);
}
internal static async Task SetVerbosity(Server server, bool val)
public static async Task SetVerbosity(Server server, bool val)
{
var serverPerms = PermissionsDict.GetOrAdd(server.Id,
new ServerPermissions(server.Id, server.Name));
@ -192,7 +192,7 @@ namespace NadekoBot.Modules.Permissions.Classes
await WriteServerToJson(serverPerms).ConfigureAwait(false);
}
internal static async Task CopyRolePermissions(Role fromRole, Role toRole)
public static async Task CopyRolePermissions(Role fromRole, Role toRole)
{
var server = fromRole.Server;
var serverPerms = PermissionsDict.GetOrAdd(server.Id,
@ -210,7 +210,7 @@ namespace NadekoBot.Modules.Permissions.Classes
await WriteServerToJson(serverPerms).ConfigureAwait(false);
}
internal static async Task CopyChannelPermissions(Channel fromChannel, Channel toChannel)
public static async Task CopyChannelPermissions(Channel fromChannel, Channel toChannel)
{
var server = fromChannel.Server;
var serverPerms = PermissionsDict.GetOrAdd(server.Id,
@ -228,7 +228,7 @@ namespace NadekoBot.Modules.Permissions.Classes
await WriteServerToJson(serverPerms).ConfigureAwait(false);
}
internal static async Task CopyUserPermissions(User fromUser, User toUser)
public static async Task CopyUserPermissions(User fromUser, User toUser)
{
var server = fromUser.Server;
var serverPerms = PermissionsDict.GetOrAdd(server.Id,

View File

@ -7,7 +7,7 @@ using System.Text.RegularExpressions;
namespace NadekoBot.Modules.Permissions
{
internal class FilterInvitesCommand : DiscordCommand
public class FilterInvitesCommand : DiscordCommand
{
private readonly Regex filterRegex = new Regex(@"(?:discord(?:\.gg|app\.com\/invite)\/(?<id>([\w]{16}|(?:[\w]+-?){3})))");
@ -49,7 +49,7 @@ namespace NadekoBot.Modules.Permissions
return serverPerms.ChannelPermissions.TryGetValue(channel.Id, out perms) && perms.FilterInvites;
}
internal override void Init(CommandGroupBuilder cgb)
public override void Init(CommandGroupBuilder cgb)
{
cgb.CreateCommand(Module.Prefix + "chnlfilterinv")
.Alias(Module.Prefix + "cfi")

View File

@ -7,7 +7,7 @@ using System.Linq;
namespace NadekoBot.Modules.Permissions
{
internal class FilterWords : DiscordCommand
public class FilterWords : DiscordCommand
{
public FilterWords(DiscordModule module) : base(module)
{
@ -47,7 +47,7 @@ namespace NadekoBot.Modules.Permissions
return serverPerms.ChannelPermissions.TryGetValue(channel.Id, out perms) && perms.FilterWords;
}
internal override void Init(CommandGroupBuilder cgb)
public override void Init(CommandGroupBuilder cgb)
{
cgb.CreateCommand(Module.Prefix + "chnlfilterwords")
.Alias(Module.Prefix + "cfw")

View File

@ -12,7 +12,7 @@ using System.Threading.Tasks;
namespace NadekoBot.Modules.Permissions
{
internal class PermissionModule : DiscordModule
public class PermissionModule : DiscordModule
{
public override string Prefix { get; } = NadekoBot.Config.CommandPrefixes.Permissions;