public BotAction Get(BotActionType action) { switch (action) { case BotActionType.Farm: return(new FarmingAction(bot)); case BotActionType.ForceUnban: return(new ForceUnbanAction(bot)); case BotActionType.TransferPokemon: return(new TransferPokemonWithAlgorithmAction(bot)); default: throw new ArgumentOutOfRangeException(nameof(action), "Unknown action"); } }
protected void SendImage(BotActionType actionType) { var cl = new FacebookBotClient(); cl.SuppressThrowException = true; var l = WebApp.Current.DatabaseCache.BotActionImage .Where(el => el.BotCD == this.BotCD && el.ActionType == actionType).ToList(); if (l.Count == 0) { return; } var index = _Random.Next(l.Count); var rImage = l[index]; HttpResponse res = null; var rAttachment = WebApp.Current.DatabaseCache.FacebookAttachment.FirstOrDefault(el => el.Url == rImage.ImageUrl); if (rAttachment == null) { res = cl.SendImage(this.RecipientID, rImage.ImageUrl); if (res.StatusCode == HttpStatusCode.OK) { try { var o = JsonConvert.DeserializeObject <SendMediaResponse>(res.BodyText); rAttachment = new FacebookAttachmentRecord(); rAttachment.AttachmentID = o.Attachment_ID; rAttachment.Url = rImage.ImageUrl; rAttachment.CreateTime = DateTimeInfo.GetNow(); var dc = new SystemDataContext(); dc.FacebookAttachment_Insert(rAttachment); } catch (Exception ex) { HignullLog.Current.Add(ex); } } } else { res = cl.SendAttachment(this.RecipientID, rAttachment.AttachmentID); } }
bool CanExecuteAddAction(BotActionType param) => true;
void ExecuteAddAction(BotActionType param) { UpcomingActions.Add(actionFactory.Get(param)); Start.RaiseCanExecuteChanged(); Stop.RaiseCanExecuteChanged(); }
public String Text(BotActionType actionType) { return(this.TextManager.Text(actionType.ToStringFromEnum())); }