public ContactService(ITelegramHelper telegramHelper,
                       IOptions <TelegramConfiguration> telegramConfiguration,
                       IMapper mapper)
 {
     _telegramHelper        = telegramHelper;
     _telegramConfiguration = telegramConfiguration.Value;
     _mapper = mapper;
 }
Beispiel #2
0
 public TelegramSender(
     TelegramConfiguration configuration,
     HttpClient client)
 {
     _chatId = configuration.ChatId;
     _token  = configuration.Token;
     _client = client;
 }
 public ClientService(IOptions <TelegramConfiguration> clientConfiguration,
                      ITelegramHelper telegramHelper,
                      IMapper mapper)
 {
     _telegramConfiguration = clientConfiguration.Value;
     _telegramHelper        = telegramHelper;
     _mapper = mapper;
 }
        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;
        }
 public TelegramService(TelegramConfiguration configuration, IMessageBus messageBus, ILogger <TelegramService> logger)
 {
     _configuration                            = configuration ?? throw new ArgumentNullException(nameof(configuration));
     _messageBus                               = messageBus ?? throw new ArgumentNullException(nameof(messageBus));
     _logger                                   = logger ?? throw new ArgumentNullException(nameof(logger));
     _telegramBotClient                        = new TelegramBotClient(configuration.BotToken);
     _telegramBotClient.OnMessage             += ProcessMessage;
     _telegramBotClient.OnReceiveError        += LogReceiveError;
     _telegramBotClient.OnReceiveGeneralError += OnReceiveGeneralError;
 }
Beispiel #6
0
        public TelegramNotifier(
            TelegramConfiguration telegramConfiguration,
            ICurrencySubscribeService currencySubscribeService)
        {
            var token = telegramConfiguration.Token;

            Bot = new TelegramBotClient(token);

            _currencySubscribeService = currencySubscribeService;
        }
Beispiel #7
0
        public static IServiceCollection AddNotifier(this IServiceCollection services, IConfiguration configuration)
        {
            var telegramConfiguration = new TelegramConfiguration();

            configuration.Bind("Telegram", telegramConfiguration);
            services.AddSingleton(telegramConfiguration);
            //services.AddScoped<INotifier, Notifier>();
            //services.AddScoped<ITelegramNotifier, TelegramNotifier>();
            services.AddScoped <INotifier, TelegramNotifier>();

            return(services);
        }
Beispiel #8
0
 private bool tryCreateTelegram(string filepath, out TelegramConfiguration telegramConfig)
 {
     try
     {
         JObject obj = JObject.Parse(File.ReadAllText(filepath));
         telegramConfig = JsonConvert.DeserializeObject <TelegramConfiguration>(obj["telegram"].ToString());
         return(true);
     }
     catch
     {
         telegramConfig = null;
         return(false);
     }
 }
Beispiel #9
0
        internal void ReadFromFile(string filepath)
        {
            var config = new Configuration();

            // Telegram
            if (tryCreateTelegram(filepath, out TelegramConfiguration telegramConfig))
            {
                this.TelegramConfiguration = telegramConfig;
            }

            // Coinbase Pro
            if (tryCreateCoinbasePro(filepath, out CoinbaseProPortfolio coinbaseProPortfolio))
            {
                this.Portfolios.Add(coinbaseProPortfolio);
            }

            // Binance
            if (tryCreateBinance(filepath, out BinancePortfolio binancePortfolio))
            {
                this.Portfolios.Add(binancePortfolio);
            }
        }
Beispiel #10
0
        public TelegramMessagingService(
            TelegramConfiguration telegramConfiguration,
            IMediator mediator,
            ILogger <TelegramMessagingService> logger)
        {
            _telegramConfiguration = telegramConfiguration;
            _mediator = mediator;
            _logger   = logger;

            if (telegramConfiguration.Socks5Host == null)
            {
                _telegramBotClient                        = new TelegramBotClient(telegramConfiguration.BotApiKey);
                _telegramBotClient.OnMessage             += ProcessMessage;
                _telegramBotClient.OnReceiveGeneralError += LogGeneralError;
                return;
            }

            var proxy = new HttpToSocks5Proxy(
                telegramConfiguration.Socks5Host,
                telegramConfiguration.Socks5Port,
                telegramConfiguration.Socks5Username,
                telegramConfiguration.Socks5Password)
            {
                ResolveHostnamesLocally = true
            };
            var handler = new HttpClientHandler
            {
                Proxy    = proxy,
                UseProxy = true
            };

            _telegramHttpClient                       = new HttpClient(handler);
            _telegramBotClient                        = new TelegramBotClient(telegramConfiguration.BotApiKey, _telegramHttpClient);
            _telegramBotClient.OnMessage             += ProcessMessage;
            _telegramBotClient.OnReceiveGeneralError += LogGeneralError;
        }
Beispiel #11
0
 public TelegramBot(IOptions <TelegramConfiguration> _config)
 {
     config = _config.Value;
 }
Beispiel #12
0
 public TelegramSession(ILogger <TelegramSession> logger,
                        IOptions <TelegramConfiguration> configuration)
 {
     _logger        = logger;
     _configuration = configuration.Value;
 }