public override HandleMessageResult HandleMessage(UserActionMessage message) { if (message.ActionType == UserActionType.Postback && message.Command.CommandName == BotCommandName.StartCommand) { if (message.Command.MethodName == "StartCommand") { var commandName = message.Command.Value.ToEnum <BotCommandName>().Value; this.StartCommand(commandName); } else if (message.Command.MethodName == "RestartCommand") { var dc = new BotDataContext(this.UserCD); var commandCD = Guid.Parse(message.Command.Value); dc.BotCommand_Restart(commandCD); var r = dc.BotCommand_Get(commandCD); if (r == null) { var cl = new FacebookBotClient(); cl.SendMessage(this.RecipientID, this.Text(BotTextKey.ThisCommandMayBeDeleted)); } else { var cm = BotCommand.Create(this.RecipientID, this.BotCD, r); cm.ResponseMessage(); } } return(new HandleMessageResult(true)); } return(new HandleMessageResult(false)); }
public Bot() { BasicConfigurator.Configure(); log.Info("Starting bot instance..."); db = new BotDataContext(new SQLiteConnection("DbLinqProvider=Sqlite;Data Source=Bot.db;")); userService = new UserService(db); }
public void ResponseCommandListMessage() { var dc = new BotDataContext(this.UserCD); var l = new List <IButton>(); { var bt = new PostbackButton(); bt.Title = this.Text(BotTextKey.AddNewSchedule); var cm = new PayloadCommand(); cm.CommandName = BotCommandName.StartCommand; cm.MethodName = "StartCommand"; cm.Value = nameof(BotCommandName.ScheduleAdd); bt.SetPayload(cm); l.Add(bt); } { var bt = new PostbackButton(); bt.Title = this.Text(BotTextKey.AddNewTask); var cm = new PayloadCommand(); cm.CommandName = BotCommandName.StartCommand; cm.MethodName = "StartCommand"; cm.Value = nameof(BotCommandName.TaskAdd); bt.SetPayload(cm); l.Add(bt); } { var bt = new PostbackButton(); bt.Title = this.Text(BotTextKey.TaskConfirmation); var cm = new PayloadCommand(); cm.CommandName = BotCommandName.StartCommand; cm.MethodName = "StartCommand"; cm.Value = nameof(BotCommandName.TaskComplete); bt.SetPayload(cm); l.Add(bt); } foreach (var item in dc.BotCommand_List_Get()) { if (item.CommandName == BotCommandName.StartCommand) { continue; } var cm = BotCommand.Create(this.RecipientID, this.BotCD, item); var bt = new PostbackButton(); bt.Title = cm.GetText(); bt.SetPayload(BotCommandName.StartCommand, "RestartCommand", item.CommandCD.ToString()); l.Add(bt); } this.SendImage(BotActionType.Greeting); var cl = new FacebookBotClient(); foreach (var item in ButtonTemplateMessage.Create(this.RecipientID , this.TextManager.Text(BotTextKey.CanIHelpYou), l)) { cl.SendMessage(item); } dc.BotCommand_Update(_Record); }
private void StartTaskAddCommand() { var dc = new BotDataContext(this.UserCD); var data = new BotCommand_TaskAdd.CommandData(); var rBotCommand = dc.BotCommand_Add(DatabaseSetting.NewGuid(), this.UserCD, BotCommandName.TaskAdd, null , DateTimeInfo.GetNow().AddMinutes(BotCommand_TaskAdd.ExpireMinutes), JsonConvert.SerializeObject(data)); var cm = new BotCommand_TaskAdd(this.RecipientID, this.BotCD, rBotCommand); cm.ResponseMessage(); }
public OCUserRepository(BotDataContext dataContext) { _dataContext = dataContext; }
public UserService(BotDataContext db) { this.db = db; }
public Chanel2ServerRepository(BotDataContext dataContext) { _dataContext = dataContext; }
public void DeleteCommandData() { var dc = new BotDataContext(this.UserCD); dc.BotCommand_Delete(_Record.CommandCD); }
public void UpdateCommandData() { var dc = new BotDataContext(this.UserCD); dc.BotCommand_Update(_Record); }