Example #1
0
    private Status controlStatus;                       // Controller Status.

    // Use this for initialization
    protected override void Awake()
    {
        base.Awake();
        controlStatus = Status.IDLE;
        int[] sizes = mapWorld.GetMapSize();
        rsize = sizes[0];
        csize = sizes[1];
        myMap = new char[rsize * csize];
        // Initialize to " " space.
        for (int i = 0; i < rsize; i++)
        {
            for (int j = 0; j < csize; j++)
            {
                myMap[i * csize + j] = ' ';
            }
        }
        // --
        objectInFov = new List <GameObject>();
        botActions  = gameObject.GetComponent <BotActions>();
        deliberator = gameObject.GetComponent(deliberatorName) as IBotDeliberator;
        // Disable deliberator if deliberator exist or manual control is enabled.
        ManualControl mc = gameObject.GetComponent <ManualControl>();

        deliberatorOn = (deliberator != null) &&
                        (mc != null) &&
                        !gameObject.GetComponent <ManualControl>().enabled;
        // Update current position in myMap
        Vector3 current = gameObject.transform.position;

        int[] idxs = mapWorld.GetIndexesFromWorld(current.x, current.z);
        mapWorld.CopyRegion(myMap, idxs[0] - 1, idxs[1] - 1, 3, 3);
        // Run Thread Function Every `n` second
        InvokeRepeating("ThinkLoop", 3, thinkTick);
    }
Example #2
0
        private Activity PresentNextStep(Activity activity)
        {
            var stringToParse = activity.Text.Split(' ');

            var commandName = stringToParse[1];
            var botName     = stringToParse[0];

            if (botName.ToUpper() != "@SHAZBOT")
            {
                return(null);
            }

            switch (commandName.ToUpper())
            {
            case "YOUTUBE":
                return(BotActions.YouTubeSearch(activity, stringToParse[2]));

            case "AMAZON":
                return(null);    // Currently non functioning - Seems to be an issue getting the service to even connect... Probably something with soap clients and headers

            // return BotActions.AmazonSearch(activity, stringToParse[2]);
            case "TRANSLATE":
                return(null);

            case "FORECAST":
                return(BotActions.ForcastSearch(activity, stringToParse[2]));

            default:
                return(null);
            }
        }
Example #3
0
        private Authorizer(string token, UpdatesHandler updatesHandler, Secrets clientSecret)
        {
            updatesHandler.NullInspect(nameof(updatesHandler));
            clientSecret.NullInspect(nameof(clientSecret));

            ClientSecret           = clientSecret;
            _botActions            = new BotActions(token);
            AuthorizeRequestEvent += Authorizer_AuthorizeRequestEvent;
        }
Example #4
0
    void OnMouseDown()
    {
        bot = GameObject.Find(botName);
        float      x          = transform.position.x;
        float      z          = transform.position.z;
        BotActions botActions = bot.GetComponent <BotActions>();
        string     command    = action + " " + x + " " + z;

        botActions.DoAction(command);
    }
Example #5
0
    private Status controlStatus;                       // Controller Status.

    //public StateBook internalKnowledge;

    // Use this for initialization
    protected void Awake()
    {
        controlStatus = Status.IDLE;
        objectInFov   = new List <GameObject>();
        botActions    = gameObject.GetComponent <BotActions>();
        deliberator   = gameObject.GetComponent(deliberatorName) as IBotDeliberator;
        // Run Thread Function Every `n` second
        if (!onDemand)
        {
            InvokeRepeating("ThinkLoop", 0, thinkTick);
        }
    }
 public ChosenInlineResultHandler()
 {
     try
     {
         _botActions = new BotActions(BotInitializer.Instance.BotSettings.Token);
         InitRules();
         _dbWorker = new GmailDbContextWorker();
         BotInitializer.Instance.UpdatesHandler.TelegramChosenInlineEvent += HandleChosenInlineResult;
     }
     catch (Exception ex)
     {
         throw new TypeInitializationException(nameof(ChosenInlineResultHandler), ex);
     }
 }
Example #7
0
 public InlineQueryHandler()
 {
     try
     {
         _botSettings = BotInitializer.Instance.BotSettings;
         _botActions  = new BotActions(_botSettings.Token);
         _dbWorker    = new GmailDbContextWorker();
         InitFullAccessRules();
         InitNotifyAccessRules();
         BotInitializer.Instance.UpdatesHandler.TelegramInlineQueryEvent += HandleInlineQuery;
     }
     catch (Exception ex)
     {
         throw new TypeInitializationException(nameof(InlineQueryHandler), ex);
     }
 }
Example #8
0
 public NotifyHandler()
 {
     try
     {
         _botSettings    = BotInitializer.Instance.BotSettings;
         _botActions     = new BotActions(_botSettings.Token);
         _messageHandler = BotInitializer.Instance.MessageHandler;
         _dbWorker       = new GmailDbContextWorker();
         var authorizer = BotInitializer.Instance.Authorizer;
         authorizer.AuthorizationRegistredEvent += Instance_AuthorizationRegistredEvent;
     }
     catch (Exception ex)
     {
         throw new TypeInitializationException(nameof(NotifyHandler), ex);
     }
 }
Example #9
0
 public static void Handle(TwitchBot twitchBot, ChatMessage chatMessage)
 {
     if (MessageHelper.IsCommand(chatMessage))
     {
         ((CommandType[])Enum.GetValues(typeof(CommandType))).ToList().ForEach(type =>
         {
             if (chatMessage.MatchesAnyAlias(type))
             {
                 if (!BotActions.IsOnCooldown(chatMessage.Username, type))
                 {
                     CommandHelper.GetCommand(type).Alias.ForEach(alias =>
                     {
                         if (chatMessage.GetMessage().IsMatch(PatternCreator.Create(alias, PrefixHelper.GetPrefix(chatMessage.Channel), @"(\s|$)")))
                         {
                             BotActions.AddUserToCooldownDictionary(chatMessage.Username, type);
                             Type.GetType(CommandHelper.GetCommandClassName(type)).GetMethod(_handleName).Invoke(null, new object[] { twitchBot, chatMessage, alias });
                             BotActions.AddCooldown(chatMessage.Username, type);
                         }
                     });
                 }
             }
         });
         twitchBot.CommandCount++;
     }
     else if (MessageHelper.IsAfkCommand(chatMessage))
     {
         ((AfkCommandType[])Enum.GetValues(typeof(AfkCommandType))).ToList().ForEach(type =>
         {
             if (chatMessage.MatchesAnyAlias(type))
             {
                 if (!BotActions.IsOnAfkCooldown(chatMessage.Username))
                 {
                     CommandHelper.GetAfkCommand(type).Alias.ForEach(alias =>
                     {
                         if (chatMessage.GetMessage().IsMatch(PatternCreator.Create(alias, PrefixHelper.GetPrefix(chatMessage.Channel), @"(\s|$)")))
                         {
                             BotActions.AddUserToAfkCooldownDictionary(chatMessage.Username);
                             AfkCommandHandler.Handle(twitchBot, chatMessage, type);
                             BotActions.AddAfkCooldown(chatMessage.Username);
                         }
                     });
                 }
             }
         });
         twitchBot.CommandCount++;
     }
 }
Example #10
0
        public async Task <bool> WaitUntilActionAccept(BotActions action, int timeout = 30000)
        {
            if (botActions.Count == 0)
            {
                return(true);
            }
            var waitTimes = 0;

            while (true && waitTimes < timeout)
            {
                if (botActions.Count == 0)
                {
                    return(true);
                }
                ///implement logic of action dependent
                waitTimes += 1000;
                await Task.Delay(1000);
            }
            return(false); //timedout
        }
Example #11
0
 public MessageHandler()
 {
     try
     {
         _authorizer  = BotInitializer.Instance.Authorizer;
         _dbWorker    = new GmailDbContextWorker();
         _botSettings = BotInitializer.Instance.BotSettings;
         _botActions  = new BotActions(_botSettings.Token);
         InitFullAccessRules();
         InitNotifyAccessRules();
         InitFullForceReplyRules();
         InitNotifyForceReplyRules();
         BotInitializer.Instance.UpdatesHandler.TelegramTextMessageEvent     += HandleTextMessage;
         BotInitializer.Instance.UpdatesHandler.TelegramTextMessageEvent     += HandleForceReplyMessage;
         BotInitializer.Instance.UpdatesHandler.TelegramDocumentMessageEvent += HandleForceReplyMessage;
         BotInitializer.Instance.UpdatesHandler.TelegramAudioMessageEvent    += HandleForceReplyMessage;
         BotInitializer.Instance.UpdatesHandler.TelegramVideoMessageEvent    += HandleForceReplyMessage;
     }
     catch (Exception ex)
     {
         throw new TypeInitializationException(nameof(MessageHandler), ex);
     }
 }
Example #12
0
 //public StateBook internalKnowledge;
 // Use this for initialization
 protected void Awake()
 {
     controlStatus = Status.IDLE;
     objectInFov = new List<GameObject>();
     botActions = gameObject.GetComponent<BotActions>();
     deliberator = gameObject.GetComponent(deliberatorName) as IBotDeliberator;
     // Run Thread Function Every `n` second
     if (!onDemand) {
         InvokeRepeating("ThinkLoop", 0, thinkTick);
     }
 }
Example #13
0
 // Use this for initialization
 protected override void Awake()
 {
     base.Awake();
     attributes = gameObject.GetComponent<BotAttributes>();
     parentAction = gameObject.GetComponent<BotActions>();
 }
Example #14
0
 // Use this for initialization
 void Start()
 {
     botActions = gameObject.GetComponent<BotActions>();
 }
Example #15
0
 // Use this for initialization
 protected override void Awake()
 {
     base.Awake();
     controlStatus = Status.IDLE;
     int[] sizes = mapWorld.GetMapSize();
     rsize = sizes[0];
     csize = sizes[1];
     myMap = new char[rsize * csize];
     // Initialize to " " space.
     for (int i = 0; i < rsize; i++)
     {
         for (int j = 0; j < csize; j++)
         {
             myMap[i * csize + j] = ' ';
         }
     }
     // --
     objectInFov = new List<GameObject>();
     botActions = gameObject.GetComponent<BotActions>();
     deliberator = gameObject.GetComponent(deliberatorName) as IBotDeliberator;
     // Disable deliberator if deliberator exist or manual control is enabled.
     ManualControl mc = gameObject.GetComponent<ManualControl>();
     deliberatorOn = (deliberator != null) &&
         (mc != null) &&
         !gameObject.GetComponent<ManualControl>().enabled;
     // Update current position in myMap
     Vector3 current = gameObject.transform.position;
     int[] idxs = mapWorld.GetIndexesFromWorld(current.x, current.z);
     mapWorld.CopyRegion(myMap, idxs[0] - 1, idxs[1] - 1, 3, 3);
     // Run Thread Function Every `n` second
     InvokeRepeating("ThinkLoop", 3, thinkTick);
 }
Example #16
0
 public BlockableScope(ISession session, BotActions action)
 {
     this.session = session;
     this.action  = action;
 }
Example #17
0
 // Use this for initialization
 void Start()
 {
     botActions = gameObject.GetComponent <BotActions>();
 }
Example #18
0
    public float speedDecreaseRate;         /**< Speed decrease rate by gold. */

    // Use this for initialization
    protected override void Awake()
    {
        base.Awake();
        attributes   = gameObject.GetComponent <BotAttributes>();
        parentAction = gameObject.GetComponent <BotActions>();
    }