Exemple #1
0
        /// <summary>
        /// Cleans up.
        /// </summary>
        private void CleanUp()
        {
            this.ActivePlayer = null;
            this._container.UnregisterHandler <ClientLurker>();
            this._container.UnregisterHandler <PlayerService>();
            this._container.UnregisterHandler <ProcessLurker>();
            this._container.UnregisterHandler <DockingHelper>();
            this._container.UnregisterHandler <PoeKeyboardHelper>();
            this._container.UnregisterHandler <ClipboardLurker>();
            this._container.UnregisterHandler <MouseLurker>();

            if (this._clipboardLurker != null)
            {
                this._clipboardLurker.Dispose();
                this._clipboardLurker = null;
            }

            if (this._currentLurker != null)
            {
                this._currentLurker.AdminRequested -= this.CurrentLurker_AdminRequested;
                this._currentLurker.Dispose();
                this._currentLurker = null;
            }

            if (this._currentCharacterService != null)
            {
                this._currentCharacterService.Dispose();
            }

            if (this._processLurker != null)
            {
                this._processLurker.ProcessClosed -= this.PoeClosed;
                this._processLurker.Dispose();
                this._processLurker = null;
            }

            if (this._currentDockingHelper != null)
            {
                this._currentDockingHelper.Dispose();
                this._currentDockingHelper = null;
            }

            if (this._afkService != null)
            {
                this._afkService.Dispose();
                this._afkService = null;
            }

            if (this._mouseLurker != null)
            {
                this._mouseLurker.Newitem -= this.MouseLurker_Newitem;
                this._mouseLurker.Dispose();
                this._mouseLurker = null;
            }

            if (this._keyboardLurker != null)
            {
                this._keyboardLurker.Dispose();
            }
        }
Exemple #2
0
        public static async Task AfkCheck(this RequestProvider requestProvider, Message message)
        {
            var afkService = new AfkService();

            if (message.ReplyToMessage != null)
            {
                var repMsg     = message.ReplyToMessage;
                var isAfkReply = await afkService.IsAfkAsync(repMsg);

                if (isAfkReply)
                {
                    await requestProvider.SendTextAsync($"{repMsg.GetFromNameLink()} sedang afk");
                }
            }

            var isAfk = await afkService.IsAfkAsync(message);

            if (isAfk)
            {
                await requestProvider.SendTextAsync($"{message.GetFromNameLink()} sudah tidak afk");

                var data = new Dictionary <string, object>()
                {
                    { "chat_id", message.Chat.Id },
                    { "user_id", message.From.Id },
                    { "is_afk", 0 },
                    { "afk_reason", "" }
                };

                await afkService.SaveAsync(data);

                await afkService.UpdateCacheAsync();
            }
        }
        /// <summary>
        /// Registers the instances.
        /// </summary>
        private void ShowOverlays(Process parentProcess)
        {
            Execute.OnUIThread(() =>
            {
                this._mouseLurker          = new MouseLurker(parentProcess, this._settingsService);
                this._mouseLurker.Newitem += this.MouseLurker_Newitem;

                var keyboarHelper          = new PoeKeyboardHelper(parentProcess);
                this._currentDockingHelper = new DockingHelper(parentProcess, this._settingsService);
                this._clipboardLurker      = new ClipboardLurker(this._settingsService, keyboarHelper);

                this._container.RegisterInstance(typeof(ProcessLurker), null, this._processLurker);
                this._container.RegisterInstance(typeof(ClientLurker), null, this._currentLurker);
                this._container.RegisterInstance(typeof(ClipboardLurker), null, this._clipboardLurker);
                this._container.RegisterInstance(typeof(DockingHelper), null, this._currentDockingHelper);
                this._container.RegisterInstance(typeof(PoeKeyboardHelper), null, keyboarHelper);

                this._incomingTradeBarOverlay = this._container.GetInstance <TradebarViewModel>();
                this._outgoingTradeBarOverlay = this._container.GetInstance <OutgoingbarViewModel>();
                this._lifeBulbOverlay         = this._container.GetInstance <LifeBulbViewModel>();
                this._manaBulbOverlay         = this._container.GetInstance <ManaBulbViewModel>();
                this._afkService     = this._container.GetInstance <AfkService>();
                this._hideoutOverlay = this._container.GetInstance <HideoutViewModel>();

                this.ActivateItem(this._incomingTradeBarOverlay);
                this.ActivateItem(this._outgoingTradeBarOverlay);
                this.ActivateItem(this._lifeBulbOverlay);
                this.ActivateItem(this._manaBulbOverlay);
                this.ActivateItem(this._hideoutOverlay);
            });
        }
Exemple #4
0
 public AfkCommand(
     SettingsService settingsService,
     TelegramService telegramService,
     AfkService afkService
     )
 {
     _settingsService = settingsService;
     _afkService      = afkService;
     _telegramService = telegramService;
 }
Exemple #5
0
        internal void AddAllToRound()
        {
            foreach (var player in Potential)
            {
                player.AddToRound();
            }

            if (AfkExtension.IsLoadedInto(BotBits))
            {
                AfkService.Of(BotBits).ResetAutoAfk();
            }
        }
Exemple #6
0
        /// <summary>
        /// Registers the instances.
        /// </summary>
        private void ShowOverlays(int processId)
        {
            Execute.OnUIThread(() =>
            {
                this._currentDockingHelper = new DockingHelper(processId, this._settingsService);

                // Keyboard
                var keyboarHelper    = new PoeKeyboardHelper(processId);
                this._keyboardLurker = new KeyboardLurker(processId, this._settingsService, keyboarHelper);

                // Mouse
                this._mouseLurker          = new MouseLurker(processId, this._settingsService);
                this._mouseLurker.Newitem += this.MouseLurker_Newitem;

                // Clipboard
                this._clipboardLurker = new ClipboardLurker();

                this._container.RegisterInstance(typeof(ProcessLurker), null, this._processLurker);
                this._container.RegisterInstance(typeof(ClientLurker), null, this._currentLurker);
                this._container.RegisterInstance(typeof(ClipboardLurker), null, this._clipboardLurker);
                this._container.RegisterInstance(typeof(DockingHelper), null, this._currentDockingHelper);
                this._container.RegisterInstance(typeof(PoeKeyboardHelper), null, keyboarHelper);

                this._incomingTradeBarOverlay = this._container.GetInstance <TradebarViewModel>();
                this._outgoingTradeBarOverlay = this._container.GetInstance <OutgoingbarViewModel>();
                this._lifeBulbOverlay         = this._container.GetInstance <LifeBulbViewModel>();
                this._manaBulbOverlay         = this._container.GetInstance <ManaBulbViewModel>();
                this._afkService     = this._container.GetInstance <AfkService>();
                this._hideoutOverlay = this._container.GetInstance <HideoutViewModel>();
                this._helpOverlay    = this._container.GetInstance <HelpViewModel>();
                this._helpOverlay.Initialize(this.ToggleBuildHelper);
                this._buildViewModel = this._container.GetInstance <BuildViewModel>();

                if (this._settingsService.BuildHelper)
                {
                    this.ActivateItem(this._helpOverlay);
                }

                this.ActivateItem(this._incomingTradeBarOverlay);
                this.ActivateItem(this._outgoingTradeBarOverlay);
                this.ActivateItem(this._lifeBulbOverlay);
                this.ActivateItem(this._manaBulbOverlay);
                this.ActivateItem(this._hideoutOverlay);
            });
        }
Exemple #7
0
        public static async Task AfkCheckAsync(this TelegramService telegramService)
        {
            Log.Information("Starting check AFK");

            var message = telegramService.MessageOrEdited;

            // var settingService = new SettingsService(message);
            var chatSettings = telegramService.CurrentSetting;
            if (!chatSettings.EnableAfkStat)
            {
                Log.Information("Afk Stat is disabled in this Group!");
                return;
            }

            var afkService = new AfkService();
            if (message.ReplyToMessage != null)
            {
                var repMsg = message.ReplyToMessage;
                var isAfkReply = await afkService.IsAfkAsync(repMsg)
                    .ConfigureAwait(false);
                if (isAfkReply)
                    await telegramService.SendTextAsync($"{repMsg.GetFromNameLink()} sedang afk")
                        .ConfigureAwait(false);
            }

            var isAfk = await afkService.IsAfkAsync(message)
                .ConfigureAwait(false);
            if (isAfk)
            {
                await telegramService.SendTextAsync($"{message.GetFromNameLink()} sudah tidak afk")
                    .ConfigureAwait(false);

                var data = new Dictionary<string, object>
                {
                    {"chat_id", message.Chat.Id}, {"user_id", message.From.Id}, {"is_afk", 0}, {"afk_reason", ""}
                };

                await afkService.SaveAsync(data).ConfigureAwait(false);
                await afkService.UpdateCacheAsync().ConfigureAwait(false);
            }
        }
Exemple #8
0
        public CommandHandler(IServiceProvider provider, DiscordSocketClient client, CommandService commandService,
                              AfkService afkService, RatelimitingService ratelimitingService, StarboardService starboardService, SelfAssignableRolesService selfService, AnnouncementService announcementService,
                              ModService modService, GuildCountUpdaterService guildUpdate, ExpService expService, BanService banService, InteractionsService interactionsService)
        {
            _client                     = client;
            _commands                   = commandService;
            _afkService                 = afkService;
            _services                   = provider;
            _ratelimitingService        = ratelimitingService;
            _starboardService           = starboardService;
            _selfAssignableRolesService = selfService;
            _announcementService        = announcementService;
            _modService                 = modService;
            _guildCount                 = guildUpdate;
            _banService                 = banService;
            _interactionsService        = interactionsService;

            _guildCount.Initialize(client.ShardId, Utility.TOTAL_SHARDS, client.Guilds.Count);


            _client.MessageReceived += HandleCommandsAsync;
            //_client.MessageReceived += _afkService.Client_MessageReceived;
            _commands.Log           += CommandsOnLog;
            _client.JoinedGuild     += ClientOnJoinedGuild;
            _client.LeftGuild       += ClientOnLeftGuild;
            _client.MessageReceived += expService.IncreaseEpOnMessageReceive;
            _client.ReactionAdded   += _starboardService.ClientOnReactionAdded;
            _client.ReactionRemoved += _starboardService.ClientOnReactionRemoved;
            _client.UserJoined      += _selfAssignableRolesService.ClientOnUserJoined;
            _client.UserJoined      += _announcementService.ClientOnUserJoined;
            _client.UserLeft        += _announcementService.ClientOnUserLeft;

            //mod Service
            _client.UserBanned   += _modService.ClientOnUserBanned;
            _client.UserUnbanned += _modService.ClientOnUserUnbanned;
        }
Exemple #9
0
        /// <summary>
        /// Cleans up.
        /// </summary>
        private void CleanUp()
        {
            this.ActivePlayer = null;
            this._container.UnregisterHandler <ClientLurker>();
            this._container.UnregisterHandler <PlayerService>();
            this._container.UnregisterHandler <ProcessLurker>();
            this._container.UnregisterHandler <DockingHelper>();
            this._container.UnregisterHandler <PoeKeyboardHelper>();
            this._container.UnregisterHandler <ClipboardLurker>();
            this._container.UnregisterHandler <MouseLurker>();
            this._container.UnregisterHandler <KeyboardLurker>();

            if (this._clipboardLurker != null)
            {
                this._clipboardLurker.Dispose();
                this._clipboardLurker = null;
            }

            if (this._currentLurker != null)
            {
                this._currentLurker.AdminRequested -= this.CurrentLurker_AdminRequested;
                this._currentLurker.Dispose();
                this._currentLurker = null;
            }

            if (this._currentCharacterService != null)
            {
                this._currentCharacterService.Dispose();
            }

            if (this._processLurker != null)
            {
                this._processLurker.ProcessClosed -= this.PoeClosed;
                this._processLurker.Dispose();
                this._processLurker = null;
            }

            if (this._currentDockingHelper != null)
            {
                this._currentDockingHelper.Dispose();
                this._currentDockingHelper = null;
            }

            if (this._afkService != null)
            {
                this._afkService.Dispose();
                this._afkService = null;
            }

            if (this._mouseLurker != null)
            {
                this._mouseLurker.ItemDetails    -= this.ShowItemDetails;
                this._mouseLurker.ItemIdentified -= this.ShowMap;
                this._mouseLurker.Dispose();
                this._mouseLurker = null;
            }

            if (this._keyboardLurker != null)
            {
                this._keyboardLurker.OpenWikiPressed -= this.KeyboardLurker_OpenWikiPressed;
                this._keyboardLurker.BuildToggled    -= this.KeyboardLurker_BuildToggled;
                this._keyboardLurker.Dispose();
            }
        }
Exemple #10
0
        /// <summary>
        /// Registers the instances.
        /// </summary>
        private void ShowOverlays(int processId)
        {
            Execute.OnUIThread(() =>
            {
                this._currentDockingHelper = new DockingHelper(processId, this._settingsService);

                // Keyboard
                var keyboarHelper    = new PoeKeyboardHelper(processId);
                this._keyboardLurker = new KeyboardLurker(processId, this._settingsService, this._keyCodeService, keyboarHelper);
                this._keyboardLurker.BuildToggled    += this.KeyboardLurker_BuildToggled;
                this._keyboardLurker.OpenWikiPressed += this.KeyboardLurker_OpenWikiPressed;

                // Mouse
                this._mouseLurker                 = new MouseLurker(processId, this._settingsService);
                this._mouseLurker.ItemDetails    += this.ShowItemDetails;
                this._mouseLurker.ItemIdentified += this.ShowMap;

                // Clipboard
                this._clipboardLurker = new ClipboardLurker();

                this._container.RegisterInstance(typeof(ProcessLurker), null, this._processLurker);
                this._container.RegisterInstance(typeof(MouseLurker), null, this._mouseLurker);
                this._container.RegisterInstance(typeof(ClientLurker), null, this._currentLurker);
                this._container.RegisterInstance(typeof(PlayerService), null, this._currentCharacterService);
                this._container.RegisterInstance(typeof(ClipboardLurker), null, this._clipboardLurker);
                this._container.RegisterInstance(typeof(DockingHelper), null, this._currentDockingHelper);
                this._container.RegisterInstance(typeof(PoeKeyboardHelper), null, keyboarHelper);
                this._container.RegisterInstance(typeof(KeyboardLurker), null, this._keyboardLurker);

                this._skillTimelineOverlay    = this._container.GetInstance <BuildTimelineViewModel>();
                this._incomingTradeBarOverlay = this._container.GetInstance <TradebarViewModel>();
                this._outgoingTradeBarOverlay = this._container.GetInstance <OutgoingbarViewModel>();
                this._popup           = this._container.GetInstance <PopupViewModel>();
                this._lifeBulbOverlay = this._container.GetInstance <LifeBulbViewModel>();
                this._manaBulbOverlay = this._container.GetInstance <ManaBulbViewModel>();
                this._afkService      = this._container.GetInstance <AfkService>();
                this._hideoutOverlay  = this._container.GetInstance <HideoutViewModel>();
                this._helpOverlay     = this._container.GetInstance <HelpViewModel>();
                this._helpOverlay.Initialize(this.ToggleBuildHelper);
                this._buildViewModel = this._container.GetInstance <BuildViewModel>();

                if (this._settingsService.BuildHelper)
                {
                    this.ActivateItem(this._buildViewModel);
                }

                if (this._settingsService.BuildHelper)
                {
                    if (this._settingsService.TimelineEnabled)
                    {
                        this.ActivateItem(this._skillTimelineOverlay);
                    }

                    this.ActivateItem(this._helpOverlay);
                }

                if (this._settingsService.IncomingTradeEnabled)
                {
                    this.ActivateItem(this._incomingTradeBarOverlay);
                }

                if (this._settingsService.OutgoingTradeEnabled)
                {
                    this.ActivateItem(this._outgoingTradeBarOverlay);
                }

                if (this._settingsService.HideoutEnabled)
                {
                    this.ActivateItem(this._hideoutOverlay);
                }

                this.ActivateItem(this._lifeBulbOverlay);
                this.ActivateItem(this._manaBulbOverlay);
            });
        }
Exemple #11
0
 public AfkModule(AfkService afkService)
 {
     _afkService = afkService;
 }
 public AfkCommand()
 {
     _afkService = new AfkService();
 }