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