added .. [keyword] [text] and ... [keyword] quote system. closes #60

This commit is contained in:
Master Kwoth
2016-02-25 10:57:11 +01:00
parent 99d8e09ec9
commit e83c35027d
4 changed files with 61 additions and 0 deletions

View File

@ -2,6 +2,8 @@
using System.Linq;
using SQLite;
using NadekoBot.Classes._DataModels;
using System;
using System.Linq.Expressions;
namespace NadekoBot.Classes {
class DBHandler {
@ -21,6 +23,7 @@ namespace NadekoBot.Classes {
_conn.CreateTable<CurrencyState>();
_conn.CreateTable<CurrencyTransaction>();
_conn.CreateTable<Donator>();
_conn.CreateTable<UserQuote>();
_conn.Execute(Queries.TransactionTriggerQuery);
}
}
@ -76,6 +79,13 @@ namespace NadekoBot.Classes {
_conn.Update(o, typeof(T));
}
}
internal T GetRandom<T>(Expression<Func<T, bool>> p) where T : IDataModel, new() {
using (var _conn = new SQLiteConnection(_filePath)) {
var r = new Random();
return _conn.Table<T>().Where(p).ToList().OrderBy(x => r.Next()).FirstOrDefault();
}
}
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NadekoBot.Classes._DataModels {
class UserQuote : IDataModel {
public string UserName { get; set; }
public string Keyword { get; set; }
public string Text { get; set; }
}
}