Add Best invitation
This commit is contained in:
parent
f9a5dc5e34
commit
2c491b63de
@ -198,7 +198,8 @@ namespace WebAPI.Services.AutoReplyCommands
|
|||||||
|
|
||||||
public bool Enabled(PastoralDomain pastoralDomain = null, string command = null)
|
public bool Enabled(PastoralDomain pastoralDomain = null, string command = null)
|
||||||
{
|
{
|
||||||
return COMMANDS.Any(c=>c.IndexOf(command)==0);
|
this.pastoralDomain = pastoralDomain;
|
||||||
|
return COMMANDS.Any(c=> c.IndexOf(command, StringComparison.OrdinalIgnoreCase)==0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,14 +12,14 @@ namespace WebAPI.Services.AutoReplyCommands
|
|||||||
{
|
{
|
||||||
private PastoralDomain pastoralDomain;
|
private PastoralDomain pastoralDomain;
|
||||||
private static readonly string[] COMMANDS = { "小組" };
|
private static readonly string[] COMMANDS = { "小組" };
|
||||||
|
|
||||||
private static readonly DomainType[] GROUPS = {
|
private static readonly DomainType[] GROUPS = {
|
||||||
DomainType.CellGroup,
|
DomainType.CellGroup,
|
||||||
};
|
};
|
||||||
|
|
||||||
public string Description => "顯示小組聚會資訊";
|
public string Description => "顯示小組聚會資訊";
|
||||||
public IEnumerable<string> Commands => COMMANDS;
|
public IEnumerable<string> Commands => COMMANDS;
|
||||||
public string ReplyTextMessage =>
|
public string ReplyTextMessage =>
|
||||||
"新生命靈糧堂 Arcadia 牧區 - 方舟小組\n" +
|
"新生命靈糧堂 Arcadia 牧區 - 方舟小組\n" +
|
||||||
"聚會時間 & 流程 周五晚上\n" +
|
"聚會時間 & 流程 周五晚上\n" +
|
||||||
"07:30 PM ~ 08:30 PM - PotLuck 時光\n" +
|
"07:30 PM ~ 08:30 PM - PotLuck 時光\n" +
|
||||||
@ -34,7 +34,8 @@ namespace WebAPI.Services.AutoReplyCommands
|
|||||||
}
|
}
|
||||||
public bool Enabled(PastoralDomain pastoralDomain = null, string command = null)
|
public bool Enabled(PastoralDomain pastoralDomain = null, string command = null)
|
||||||
{
|
{
|
||||||
return COMMANDS.Any(c => c.IndexOf(command) == 0);
|
this.pastoralDomain = pastoralDomain;
|
||||||
|
return COMMANDS.Any(c => c.IndexOf(command, StringComparison.OrdinalIgnoreCase) == 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,11 +12,10 @@ namespace WebAPI.Services.AutoReplyCommands
|
|||||||
{
|
{
|
||||||
|
|
||||||
private static readonly string[] COMMANDS = { "教會", "church" };
|
private static readonly string[] COMMANDS = { "教會", "church" };
|
||||||
private static readonly string MESSAGES =
|
private static readonly string MESSAGES =
|
||||||
"新生命靈糧堂 Arcadia 牧區\n聚會時間 周日 11:00 AM - 12:30PM\n聚會後有提供精緻午餐唷!\n"+
|
"新生命靈糧堂 Arcadia 牧區\n聚會時間 周日 11:00 AM - 12:30PM\n聚會後有提供精緻午餐唷!\n" +
|
||||||
"1881 S 1st Ave, Arcadia, CA 91006";
|
"1881 S 1st Ave, Arcadia, CA 91006";
|
||||||
private static readonly DomainType[] GROUPS = {
|
private static readonly DomainType[] GROUPS = {
|
||||||
DomainType.HappinessGroup,
|
|
||||||
DomainType.CellGroup
|
DomainType.CellGroup
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -30,11 +29,8 @@ namespace WebAPI.Services.AutoReplyCommands
|
|||||||
|
|
||||||
public bool Enabled(PastoralDomain pastoralDomain = null, string command = null)
|
public bool Enabled(PastoralDomain pastoralDomain = null, string command = null)
|
||||||
{
|
{
|
||||||
return COMMANDS.Any(c => c.IndexOf(command) == 0);
|
return COMMANDS.Any(c => c.IndexOf(command, StringComparison.OrdinalIgnoreCase) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Initialize(PastoralDomain pastoralDomain = null)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
134
WebAPI/Services/AutoReplyCommands/ArHappinessBEST.cs
Normal file
134
WebAPI/Services/AutoReplyCommands/ArHappinessBEST.cs
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
using Church.Net.DAL.EF;
|
||||||
|
using Church.Net.Entity;
|
||||||
|
using Church.Net.Utility;
|
||||||
|
using LineMessaging;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using WebAPI.Logics;
|
||||||
|
using WebAPI.Services.Interfaces;
|
||||||
|
|
||||||
|
namespace WebAPI.Services.AutoReplyCommands
|
||||||
|
{
|
||||||
|
public class ArHappinessBEST : IAutoReplyCommand
|
||||||
|
{
|
||||||
|
private PastoralDomain pastoralDomain;
|
||||||
|
public ArHappinessBEST(
|
||||||
|
PastoralDomainLogic logic)
|
||||||
|
{
|
||||||
|
this.logic = logic;
|
||||||
|
}
|
||||||
|
private static readonly string[] COMMANDS = { "BEST" };
|
||||||
|
|
||||||
|
private static readonly DomainType[] GROUPS = {
|
||||||
|
DomainType.HappinessGroup,
|
||||||
|
};
|
||||||
|
private readonly PastoralDomainLogic logic;
|
||||||
|
|
||||||
|
public string Description => "顯示幸福小組 Best 電子邀請函連結";
|
||||||
|
public IEnumerable<string> Commands => COMMANDS;
|
||||||
|
public IEnumerable<DomainType> SupportGroups => GROUPS;
|
||||||
|
public string ReplyTextMessage => null;
|
||||||
|
|
||||||
|
public IEnumerable<ILineMessage> LineMessage
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var random = new Random();
|
||||||
|
|
||||||
|
List<ILineMessage> list = new List<ILineMessage>();
|
||||||
|
string title = $"W{weekSeq} {week.Topic} 邀請卡";
|
||||||
|
string imageUrl = $"https://happiness.tours/assets/images/HappinessGroup/week0{weekSeq}.jpg";
|
||||||
|
var flexMessage = new LineFlexMessage();
|
||||||
|
flexMessage.AltText = title;
|
||||||
|
|
||||||
|
#region Header
|
||||||
|
var headerContent = flexMessage.Contents.InitHeader();
|
||||||
|
headerContent.Add(
|
||||||
|
new LineFlexText(title)
|
||||||
|
{
|
||||||
|
Size = FlexObjectSize.lg,
|
||||||
|
Weight = FlexObjectTextWeidht.Bold,
|
||||||
|
Align = "center"
|
||||||
|
});
|
||||||
|
#endregion
|
||||||
|
#region Hero
|
||||||
|
flexMessage.Contents.InitHero()
|
||||||
|
.Add(
|
||||||
|
new LineFlexImage(imageUrl)
|
||||||
|
{
|
||||||
|
Size = FlexObjectSize.full,
|
||||||
|
AspectRatio = "1.5:1"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
#endregion
|
||||||
|
#region Body
|
||||||
|
|
||||||
|
var bodyContent = flexMessage.Contents.InitBody();
|
||||||
|
|
||||||
|
bodyContent.Add(new LineFlexSeparator());
|
||||||
|
#endregion
|
||||||
|
#region Footer
|
||||||
|
var footer = flexMessage.Contents.InitFooter();
|
||||||
|
foreach (var best in pastoralDomain.Bests)
|
||||||
|
{
|
||||||
|
footer.Add(
|
||||||
|
new LineFlexButton()
|
||||||
|
{
|
||||||
|
Action = new MessageAction()
|
||||||
|
{
|
||||||
|
Text = $"親愛的 {best.Name},想邀請你來參加這周的幸福聚會唷! 這是這周的邀請函!\n\nhttps://happiness.tours/invitation/{best.Id}",
|
||||||
|
Label = best.Name,
|
||||||
|
//InputOption= "openKeyboard"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
list.Insert(0, flexMessage);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Initialize(PastoralDomain pastoralDomain = null)
|
||||||
|
{
|
||||||
|
this.pastoralDomain = pastoralDomain;
|
||||||
|
}
|
||||||
|
private int weekSeq = 0;
|
||||||
|
private HappinessWeek week = null;
|
||||||
|
public bool Enabled(PastoralDomain pastoralDomain = null, string command = null)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (pastoralDomain != null && COMMANDS.Any(c => c.ToLower().IndexOf(command) == 0))
|
||||||
|
{
|
||||||
|
|
||||||
|
this.pastoralDomain = pastoralDomain;
|
||||||
|
logic.GetHappinessGroupInfo(pastoralDomain);
|
||||||
|
command = command.Replace("BEST", "");
|
||||||
|
|
||||||
|
//if (command.Length > 0)
|
||||||
|
//{
|
||||||
|
// weekSeq = int.Parse(command);
|
||||||
|
//}
|
||||||
|
//if (weekSeq > 0)
|
||||||
|
//{
|
||||||
|
// week = pastoralDomain.HappinessWeeks.Where(w => w.SEQ == weekSeq).FirstOrDefault();
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
week = pastoralDomain.HappinessWeeks.Where(w => w.Date >= DateTime.UtcNow).FirstOrDefault();
|
||||||
|
weekSeq = week.SEQ;
|
||||||
|
//}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -16,6 +16,5 @@ namespace WebAPI.Services.Interfaces
|
|||||||
IEnumerable<DomainType> SupportGroups { get; }
|
IEnumerable<DomainType> SupportGroups { get; }
|
||||||
IEnumerable<ILineMessage> LineMessage { get; }
|
IEnumerable<ILineMessage> LineMessage { get; }
|
||||||
bool Enabled(PastoralDomain pastoralDomain = null, string command = null);
|
bool Enabled(PastoralDomain pastoralDomain = null, string command = null);
|
||||||
void Initialize(PastoralDomain pastoralDomain = null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -65,7 +65,7 @@ namespace WebAPI
|
|||||||
|
|
||||||
services.AddSingleton<GameRoomLogic>();
|
services.AddSingleton<GameRoomLogic>();
|
||||||
//services.AddSingleton(_ => new DatabaseOptions { ConnectionString = "Host=192.168.86.131;Port=49154;Database=Church;Username=chris;Password=1124" });
|
//services.AddSingleton(_ => new DatabaseOptions { ConnectionString = "Host=192.168.86.131;Port=49154;Database=Church;Username=chris;Password=1124" });
|
||||||
services.AddSingleton(_ => new DatabaseOptions { ConnectionString = "Host=192.168.86.131;Port=49154;Database=ChurchSandbox;Username=chris;Password=1124" });
|
services.AddSingleton(_ => new DatabaseOptions { ConnectionString = "Host=192.168.86.131;Port=49154;Database=Church;Username=chris;Password=1124" });
|
||||||
//services.AddSingleton<ChurchNetContext>(new ChurchNetContext());
|
//services.AddSingleton<ChurchNetContext>(new ChurchNetContext());
|
||||||
services.AddDbContext<ChurchNetContext>(options =>
|
services.AddDbContext<ChurchNetContext>(options =>
|
||||||
options.UseNpgsql(
|
options.UseNpgsql(
|
||||||
@ -79,6 +79,7 @@ namespace WebAPI
|
|||||||
services.AddScoped<IAutoReplyCommand, ArArkCellGroupDinner>();
|
services.AddScoped<IAutoReplyCommand, ArArkCellGroupDinner>();
|
||||||
services.AddScoped<IAutoReplyCommand, ArArkCellGroupPrayer>();
|
services.AddScoped<IAutoReplyCommand, ArArkCellGroupPrayer>();
|
||||||
services.AddScoped<IAutoReplyCommand, ArHappinessGroupTask>();
|
services.AddScoped<IAutoReplyCommand, ArHappinessGroupTask>();
|
||||||
|
services.AddScoped<IAutoReplyCommand, ArHappinessBEST>();
|
||||||
|
|
||||||
services.AddScoped<IScheduledTask, MorningPrayer>();
|
services.AddScoped<IScheduledTask, MorningPrayer>();
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user