コード例 #1
0
        public Messenger(IOptions <TelegramOptions> options, ICameraRegistry registry, ILogger <Messenger> logger)
        {
            _options  = options.Value;
            _registry = registry;
            _logger   = logger;

            // create the client
            string apiToken = _options.ApiToken;

            if (!string.IsNullOrEmpty(_options.Socks5?.Hostname))
            {
                IWebProxy webProxy = new HttpToSocks5Proxy(_options.Socks5.Hostname, _options.Socks5.Port);
                _client = new TelegramBotClient(apiToken, webProxy);
            }
            else
            {
                _client = new TelegramBotClient(apiToken);
            }
        }
コード例 #2
0
        public static Task <Message> SendSnapshotSuccess(this TelegramBotClient client, Snapshot snapshot,
                                                         ISnapshotRequest request, Node nodeToNavigate, TelegramOptions options, CancellationToken cancellationToken = default)
        {
            CallbackQuery query = ((SnapshotRequest)request).Query;

            // post the snapshot and navigation controls in a new message
            var          photo       = new InputOnlineFile(snapshot.Stream);
            string       caption     = MessageHelpers.GetCaptionMarkdown(snapshot, options.HoursOffset, options.DateTimeFormat);
            IReplyMarkup replyMarkup = MessageHelpers.GetReplyMarkup(snapshot.Node.Parent);

            return(client.SendPhotoAsync(query.Message.Chat.Id, photo, caption, ParseMode.Markdown,
                                         replyMarkup: replyMarkup, cancellationToken: cancellationToken));
        }