Example #1
0
        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");
            }
        }
Example #2
0
        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);
            }
        }
Example #3
0
 bool CanExecuteAddAction(BotActionType param) => true;
Example #4
0
 void ExecuteAddAction(BotActionType param)
 {
     UpcomingActions.Add(actionFactory.Get(param));
     Start.RaiseCanExecuteChanged();
     Stop.RaiseCanExecuteChanged();
 }
Example #5
0
 public String Text(BotActionType actionType)
 {
     return(this.TextManager.Text(actionType.ToStringFromEnum()));
 }