Refactor done
This commit is contained in:
parent
b0ceb84a41
commit
067db1b81c
@ -1,4 +1,4 @@
|
||||
using NadekoBot._DataModels;
|
||||
using NadekoBot.DataModels;
|
||||
using SQLite;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -10,7 +10,7 @@ namespace NadekoBot.Classes
|
||||
return;
|
||||
await Task.Run(() =>
|
||||
{
|
||||
DbHandler.Instance.InsertData(new _DataModels.CurrencyTransaction
|
||||
DbHandler.Instance.InsertData(new DataModels.CurrencyTransaction
|
||||
{
|
||||
Reason = reason,
|
||||
UserId = (long)u.Id,
|
||||
@ -34,12 +34,12 @@ namespace NadekoBot.Classes
|
||||
if (amount <= 0)
|
||||
return false;
|
||||
var uid = (long)u.Id;
|
||||
var state = DbHandler.Instance.FindOne<_DataModels.CurrencyState>(cs => cs.UserId == uid);
|
||||
var state = DbHandler.Instance.FindOne<DataModels.CurrencyState>(cs => cs.UserId == uid);
|
||||
|
||||
if (state.Value < amount)
|
||||
return false;
|
||||
|
||||
DbHandler.Instance.InsertData(new _DataModels.CurrencyTransaction
|
||||
DbHandler.Instance.InsertData(new DataModels.CurrencyTransaction
|
||||
{
|
||||
Reason = reason,
|
||||
UserId = (long)u.Id,
|
||||
|
@ -182,7 +182,7 @@ namespace NadekoBot
|
||||
.Sum(x => x.Users.Count(u => u.Status == UserStatus.Online)));
|
||||
var connectedServers = NadekoBot.Client.Servers.Count();
|
||||
|
||||
Classes.DbHandler.Instance.InsertData(new _DataModels.Stats
|
||||
Classes.DbHandler.Instance.InsertData(new DataModels.Stats
|
||||
{
|
||||
OnlineUsers = onlineUsers,
|
||||
RealOnlineUsers = realOnlineUsers,
|
||||
@ -207,7 +207,7 @@ namespace NadekoBot
|
||||
try
|
||||
{
|
||||
commandsRan++;
|
||||
Classes.DbHandler.Instance.InsertData(new _DataModels.Command
|
||||
Classes.DbHandler.Instance.InsertData(new DataModels.Command
|
||||
{
|
||||
ServerId = (long)e.Server.Id,
|
||||
ServerName = e.Server.Name,
|
||||
|
@ -1,7 +1,7 @@
|
||||
using Discord;
|
||||
using Discord.Commands;
|
||||
using Discord.Modules;
|
||||
using NadekoBot._DataModels;
|
||||
using NadekoBot.DataModels;
|
||||
using NadekoBot.Classes;
|
||||
using NadekoBot.Extensions;
|
||||
using NadekoBot.Modules.Administration.Commands;
|
||||
@ -727,7 +727,7 @@ namespace NadekoBot.Modules.Administration
|
||||
await Task.Run(() =>
|
||||
{
|
||||
SaveParseToDb<Announcement>("data/parsedata/Announcements.json");
|
||||
SaveParseToDb<_DataModels.Command>("data/parsedata/CommandsRan.json");
|
||||
SaveParseToDb<DataModels.Command>("data/parsedata/CommandsRan.json");
|
||||
SaveParseToDb<Request>("data/parsedata/Requests.json");
|
||||
SaveParseToDb<Stats>("data/parsedata/Stats.json");
|
||||
SaveParseToDb<TypingArticle>("data/parsedata/TypingArticles.json");
|
||||
|
@ -1,7 +1,7 @@
|
||||
using Discord;
|
||||
using Discord.Commands;
|
||||
using NadekoBot._DataModels;
|
||||
using NadekoBot.Classes;
|
||||
using NadekoBot.DataModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -34,7 +34,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
NadekoBot.Client.UserJoined += UserJoined;
|
||||
NadekoBot.Client.UserLeft += UserLeft;
|
||||
|
||||
var data = Classes.DbHandler.Instance.GetAllRows<_DataModels.Announcement>();
|
||||
var data = Classes.DbHandler.Instance.GetAllRows<DataModels.Announcement>();
|
||||
|
||||
if (!data.Any()) return;
|
||||
foreach (var obj in data)
|
||||
@ -114,7 +114,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
|
||||
public class AnnounceControls
|
||||
{
|
||||
private _DataModels.Announcement _model { get; }
|
||||
private DataModels.Announcement _model { get; }
|
||||
|
||||
public bool Greet {
|
||||
get { return _model.Greet; }
|
||||
@ -160,14 +160,14 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
set { _model.ServerId = (long)value; }
|
||||
}
|
||||
|
||||
public AnnounceControls(_DataModels.Announcement model)
|
||||
public AnnounceControls(DataModels.Announcement model)
|
||||
{
|
||||
this._model = model;
|
||||
}
|
||||
|
||||
public AnnounceControls(ulong serverId)
|
||||
{
|
||||
this._model = new _DataModels.Announcement();
|
||||
this._model = new DataModels.Announcement();
|
||||
ServerId = serverId;
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ namespace NadekoBot.Classes.Conversations.Commands
|
||||
{
|
||||
public void SaveRequest(CommandEventArgs e, string text)
|
||||
{
|
||||
DbHandler.Instance.InsertData(new _DataModels.Request
|
||||
DbHandler.Instance.InsertData(new DataModels.Request
|
||||
{
|
||||
RequestText = text,
|
||||
UserName = e.User.Name,
|
||||
@ -23,7 +23,7 @@ namespace NadekoBot.Classes.Conversations.Commands
|
||||
// todo what if it's too long?
|
||||
public string GetRequests()
|
||||
{
|
||||
var task = DbHandler.Instance.GetAllRows<_DataModels.Request>();
|
||||
var task = DbHandler.Instance.GetAllRows<DataModels.Request>();
|
||||
|
||||
var str = "Here are all current requests for NadekoBot:\n\n";
|
||||
foreach (var reqObj in task)
|
||||
@ -35,14 +35,14 @@ namespace NadekoBot.Classes.Conversations.Commands
|
||||
}
|
||||
|
||||
public bool DeleteRequest(int requestNumber) =>
|
||||
DbHandler.Instance.Delete<_DataModels.Request>(requestNumber) != null;
|
||||
DbHandler.Instance.Delete<DataModels.Request>(requestNumber) != null;
|
||||
|
||||
/// <summary>
|
||||
/// Delete a request with a number and returns that request object.
|
||||
/// </summary>
|
||||
/// <returns>RequestObject of the request. Null if none</returns>
|
||||
public _DataModels.Request ResolveRequest(int requestNumber) =>
|
||||
DbHandler.Instance.Delete<_DataModels.Request>(requestNumber);
|
||||
public DataModels.Request ResolveRequest(int requestNumber) =>
|
||||
DbHandler.Instance.Delete<DataModels.Request>(requestNumber);
|
||||
|
||||
internal override void Init(CommandGroupBuilder cgb)
|
||||
{
|
||||
|
@ -88,7 +88,7 @@ namespace NadekoBot.Modules.Conversations
|
||||
if (string.IsNullOrWhiteSpace(text))
|
||||
return;
|
||||
await Task.Run(() =>
|
||||
Classes.DbHandler.Instance.InsertData(new _DataModels.UserQuote()
|
||||
Classes.DbHandler.Instance.InsertData(new DataModels.UserQuote()
|
||||
{
|
||||
DateAdded = DateTime.Now,
|
||||
Keyword = e.GetArg("keyword").ToLowerInvariant(),
|
||||
@ -109,7 +109,7 @@ namespace NadekoBot.Modules.Conversations
|
||||
return;
|
||||
|
||||
var quote =
|
||||
Classes.DbHandler.Instance.GetRandom<_DataModels.UserQuote>(
|
||||
Classes.DbHandler.Instance.GetRandom<DataModels.UserQuote>(
|
||||
uqm => uqm.Keyword == keyword);
|
||||
|
||||
if (quote != null)
|
||||
|
@ -1,7 +1,7 @@
|
||||
using Discord;
|
||||
using Discord.Commands;
|
||||
using NadekoBot._DataModels;
|
||||
using NadekoBot.Classes;
|
||||
using NadekoBot.DataModels;
|
||||
using NadekoBot.Extensions;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
|
@ -1,7 +1,7 @@
|
||||
using Discord;
|
||||
using Discord.Commands;
|
||||
using Discord.Modules;
|
||||
using NadekoBot._DataModels;
|
||||
using NadekoBot.DataModels;
|
||||
using NadekoBot.Classes;
|
||||
using NadekoBot.Extensions;
|
||||
using NadekoBot.Modules.Music.Classes;
|
||||
@ -443,7 +443,7 @@ namespace NadekoBot.Modules.Music
|
||||
return;
|
||||
|
||||
|
||||
var songInfos = currentPlaylist.Select(s => new _DataModels.SongInfo
|
||||
var songInfos = currentPlaylist.Select(s => new DataModels.SongInfo
|
||||
{
|
||||
Provider = s.SongInfo.Provider,
|
||||
ProviderType = (int)s.SongInfo.ProviderType,
|
||||
@ -519,7 +519,7 @@ namespace NadekoBot.Modules.Music
|
||||
psi.PlaylistId == playlist.Id);
|
||||
|
||||
var songInfos = psis.Select(psi => DbHandler.Instance
|
||||
.FindOne<_DataModels.SongInfo>(si => si.Id == psi.SongInfoId));
|
||||
.FindOne<DataModels.SongInfo>(si => si.Id == psi.SongInfoId));
|
||||
|
||||
await e.Channel.SendMessage($"`Attempting to load {songInfos.Count()} songs`");
|
||||
foreach (var si in songInfos)
|
||||
|
@ -1,7 +1,7 @@
|
||||
using Discord.Commands;
|
||||
using Discord.Modules;
|
||||
using NadekoBot.Classes;
|
||||
using NadekoBot._DataModels;
|
||||
using NadekoBot.DataModels;
|
||||
using NadekoBot.Classes.JSONModels;
|
||||
using NadekoBot.Extensions;
|
||||
using NadekoBot.Modules.Permissions.Classes;
|
||||
|
@ -2,7 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
|
||||
namespace NadekoBot.Classes.IMDB
|
||||
namespace NadekoBot.Modules.Searches.Commands.IMDB
|
||||
{
|
||||
public class ImdbMovie
|
||||
{
|
@ -18,7 +18,7 @@ using System.Text.RegularExpressions;
|
||||
* Last Updated: Feb, 2016
|
||||
*******************************************************************************/
|
||||
|
||||
namespace NadekoBot.Classes.IMDB
|
||||
namespace NadekoBot.Modules.Searches.Commands.IMDB
|
||||
{
|
||||
public static class ImdbScraper
|
||||
{
|
@ -1,11 +1,11 @@
|
||||
using Discord.Commands;
|
||||
using Discord.Modules;
|
||||
using NadekoBot.Classes;
|
||||
using NadekoBot.Classes.IMDB;
|
||||
using NadekoBot.Classes.JSONModels;
|
||||
using NadekoBot.Extensions;
|
||||
using NadekoBot.Modules.Permissions.Classes;
|
||||
using NadekoBot.Modules.Searches.Commands;
|
||||
using NadekoBot.Modules.Searches.Commands.IMDB;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
|
@ -1,7 +1,9 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace NadekoBot._DataModels {
|
||||
internal class Announcement : IDataModel {
|
||||
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;
|
@ -1,4 +1,4 @@
|
||||
namespace NadekoBot._DataModels {
|
||||
namespace NadekoBot.DataModels {
|
||||
internal class Command : IDataModel {
|
||||
public long UserId { get; set; }
|
||||
public string UserName { get; set; }
|
@ -1,4 +1,4 @@
|
||||
namespace NadekoBot._DataModels {
|
||||
namespace NadekoBot.DataModels {
|
||||
internal class CurrencyState : IDataModel {
|
||||
public long Value { get; set; }
|
||||
[SQLite.Unique]
|
@ -1,4 +1,4 @@
|
||||
namespace NadekoBot._DataModels {
|
||||
namespace NadekoBot.DataModels {
|
||||
internal class CurrencyTransaction : IDataModel {
|
||||
public string Reason { get; set; }
|
||||
public int Value { get; set; }
|
@ -1,4 +1,4 @@
|
||||
namespace NadekoBot._DataModels {
|
||||
namespace NadekoBot.DataModels {
|
||||
internal class Donator : IDataModel {
|
||||
public long UserId { get; set; }
|
||||
public string UserName { get; set; }
|
@ -1,7 +1,7 @@
|
||||
using SQLite;
|
||||
using System;
|
||||
|
||||
namespace NadekoBot._DataModels
|
||||
namespace NadekoBot.DataModels
|
||||
{
|
||||
internal abstract class IDataModel
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
namespace NadekoBot._DataModels
|
||||
namespace NadekoBot.DataModels
|
||||
{
|
||||
internal class MusicPlaylist : IDataModel
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
namespace NadekoBot._DataModels
|
||||
namespace NadekoBot.DataModels
|
||||
{
|
||||
internal class PlaylistSongInfo : IDataModel
|
||||
{
|
@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NadekoBot._DataModels
|
||||
namespace NadekoBot.DataModels
|
||||
{
|
||||
class UserPokeTypes : IDataModel
|
||||
{
|
@ -1,6 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace NadekoBot._DataModels
|
||||
namespace NadekoBot.DataModels
|
||||
{
|
||||
class Reminder : IDataModel
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
namespace NadekoBot._DataModels {
|
||||
namespace NadekoBot.DataModels {
|
||||
internal class Request : IDataModel {
|
||||
public string UserName { get; set; }
|
||||
public long UserId { get; set; }
|
@ -1,6 +1,6 @@
|
||||
using SQLite;
|
||||
|
||||
namespace NadekoBot._DataModels
|
||||
namespace NadekoBot.DataModels
|
||||
{
|
||||
internal class SongInfo : IDataModel
|
||||
{
|
@ -1,6 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace NadekoBot._DataModels {
|
||||
namespace NadekoBot.DataModels {
|
||||
internal class Stats : IDataModel {
|
||||
public int ConnectedServers { get; set; }
|
||||
public int OnlineUsers { get; set; }
|
@ -1,4 +1,4 @@
|
||||
namespace NadekoBot._DataModels {
|
||||
namespace NadekoBot.DataModels {
|
||||
internal class TypingArticle : IDataModel {
|
||||
public string Text { get; set; }
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
namespace NadekoBot._DataModels {
|
||||
namespace NadekoBot.DataModels {
|
||||
internal class UserQuote : IDataModel {
|
||||
public string UserName { get; set; }
|
||||
public string Keyword { get; set; }
|
Loading…
Reference in New Issue
Block a user