public BotManager(
            TelegramConfiguration telegramConfiguration,
            IUserManager userManager,
            IDealerService dealerService,
            IEventService eventService,
            IEventConferenceRoomService eventConferenceRoomService,
            IRegSysAlternativePinAuthenticationProvider regSysAlternativePinAuthenticationProvider,
            IEntityRepository <PushNotificationChannelRecord> pushNotificationChannelRepository,
            IEntityRepository <FursuitBadgeRecord> fursuitBadgeRepository,
            IPrivateMessageService privateMessageService,
            ICollectingGameService collectingGameService,
            ConventionSettings conventionSettings,
            ILoggerFactory loggerFactory,
            ITelegramMessageBroker telegramMessageBroker
            )
        {
            _logger        = loggerFactory.CreateLogger(GetType());
            _userManager   = userManager;
            _dealerService = dealerService;
            _eventService  = eventService;
            _eventConferenceRoomService = eventConferenceRoomService;
            _regSysAlternativePinAuthenticationProvider = regSysAlternativePinAuthenticationProvider;
            _pushNotificationChannelRepository          = pushNotificationChannelRepository;
            _fursuitBadgeRepository = fursuitBadgeRepository;
            _privateMessageService  = privateMessageService;
            _collectingGameService  = collectingGameService;
            _conventionSettings     = conventionSettings;
            _telegramMessageBroker  = telegramMessageBroker;

            _botClient =
                string.IsNullOrEmpty(telegramConfiguration.Proxy)
                    ? new TelegramBotClient(telegramConfiguration.AccessToken)
                    : new TelegramBotClient(telegramConfiguration.AccessToken,
                                            new MiniProxy(telegramConfiguration.Proxy));

            _conversationManager = new ConversationManager(
                loggerFactory,
                _botClient,
                (chatId) => new AdminConversation(
                    _userManager,
                    _regSysAlternativePinAuthenticationProvider,
                    _pushNotificationChannelRepository,
                    _fursuitBadgeRepository,
                    privateMessageService,
                    _collectingGameService,
                    _conventionSettings,
                    loggerFactory
                    )
                );

            _botClient.OnMessage       += BotClientOnOnMessage;
            _botClient.OnCallbackQuery += BotClientOnOnCallbackQuery;

            _botClient.OnInlineQuery += BotClientOnOnInlineQuery;

            _telegramMessageBroker.OnSendMarkdownMessageToChatAsync += _telegramMessageBroker_OnSendMarkdownMessageToChatAsync;
        }
Exemple #2
0
 public FursuitsController(
     IFursuitBadgeService fursuitBadgeService,
     ICollectingGameService collectingGameService,
     IApiPrincipal apiPrincipal
     )
 {
     _fursuitBadgeService   = fursuitBadgeService;
     _collectingGameService = collectingGameService;
     _apiPrincipal          = apiPrincipal;
 }
        public CollectionGameServiceTests()
        {
            var builder = new ContainerBuilder();

            builder.RegisterModule(new App.Tests.Common.TestLogger.AutofacModule());
            builder.RegisterModule(new App.Tests.Common.InMemoryRepository.AutofacModule());
            builder.RegisterModule(new DependencyResolution.AutofacModule());

            var _telegramMessageSender = new Mock <ITelegramMessageSender>().As <ITelegramMessageSender>();
            var _configuration         = new CollectionGameConfiguration();

            builder.RegisterInstance(_telegramMessageSender.Object).As <ITelegramMessageSender>();
            builder.RegisterInstance(_configuration).As <CollectionGameConfiguration>();

            _container = builder.Build();

            _collectingGameService          = _container.Resolve <ICollectingGameService>();
            _fursuitParticipationRepository = _container.Resolve <IEntityRepository <FursuitParticipationRecord> >();
            _playerParticipationRepository  = _container.Resolve <IEntityRepository <PlayerParticipationRecord> >();
            _regSysIdentityRepository       = _container.Resolve <IEntityRepository <RegSysIdentityRecord> >();
            _fursuitBadgeRepository         = _container.Resolve <IEntityRepository <FursuitBadgeRecord> >();
            _tokenRepository = _container.Resolve <IEntityRepository <TokenRecord> >();
        }
Exemple #4
0
        public AdminConversation(
            IUserManager userManager,
            IRegSysAlternativePinAuthenticationProvider regSysAlternativePinAuthenticationProvider,
            IEntityRepository <PushNotificationChannelRecord> pushNotificationChannelRepository,
            IEntityRepository <FursuitBadgeRecord> fursuitBadgeRepository,
            IPrivateMessageService privateMessageService,
            ICollectingGameService collectingGameService,
            ConventionSettings conventionSettings,
            ILoggerFactory loggerFactory
            )
        {
            _logger      = loggerFactory.CreateLogger(GetType());
            _userManager = userManager;
            _regSysAlternativePinAuthenticationProvider = regSysAlternativePinAuthenticationProvider;
            _pushNotificationChannelRepository          = pushNotificationChannelRepository;
            _fursuitBadgeRepository = fursuitBadgeRepository;
            _privateMessageService  = privateMessageService;
            _collectingGameService  = collectingGameService;
            _conventionSettings     = conventionSettings;

            _commands = new List <CommandInfo>()
            {
                new CommandInfo()
                {
                    Command            = "/pin",
                    Description        = "Create an alternative password for an attendee to login",
                    RequiredPermission = PermissionFlags.PinCreate,
                    CommandHandler     = CommandPinRequest
                },
                new CommandInfo()
                {
                    Command            = "/pinInfo",
                    Description        = "Show the pin & issue log for a given registration number",
                    RequiredPermission = PermissionFlags.PinQuery,
                    CommandHandler     = CommandPinInfo
                },
                new CommandInfo()
                {
                    Command            = "/users",
                    Description        = "Manage Users",
                    RequiredPermission = PermissionFlags.UserAdmin,
                    CommandHandler     = CommandUserAdmin
                }
                ,
                new CommandInfo()
                {
                    Command            = "/statistics",
                    Description        = "Show some statistics",
                    RequiredPermission = PermissionFlags.Statistics,
                    CommandHandler     = CommandStatistics
                },
                new CommandInfo()
                {
                    Command            = "/locate",
                    Description        = "Figure out if a given regNo is signed in on any device",
                    RequiredPermission = PermissionFlags.Locate,
                    CommandHandler     = CommandLocate
                },
                new CommandInfo()
                {
                    Command            = "/pm",
                    Description        = "Send a personal message to a specific RegNo",
                    RequiredPermission = PermissionFlags.SendPm,
                    CommandHandler     = CommandSendMessage
                },
                new CommandInfo()
                {
                    Command            = "/badgeChecksum",
                    Description        = "Calculate the checksum letter of a given reg no.",
                    RequiredPermission = PermissionFlags.BadgeChecksum,
                    CommandHandler     = CommandBadgeChecksum
                },
                new CommandInfo()
                {
                    Command            = "/fursuitBadgeById",
                    Description        = "Lookup fursuit badge (by id)",
                    RequiredPermission = PermissionFlags.CollectionGameAdmin,
                    CommandHandler     = CommandFursuitBadge
                },
                new CommandInfo()
                {
                    Command            = "/collectionGameRegisterFursuit",
                    Description        = "Register a fursuit for the game",
                    RequiredPermission = PermissionFlags.CollectionGameAdmin,
                    CommandHandler     = CommandCollectionGameRegisterFursuit
                },
                new CommandInfo()
                {
                    Command            = "/collectionGameUnban",
                    Description        = "Unban someone from the game",
                    RequiredPermission = PermissionFlags.CollectionGameAdmin,
                    CommandHandler     = CommandCollectionGameUnban
                }
            };
        }