コード例 #1
0
        public async override Task Execute(Callback callback, IViberBotClient client)
        {
            TextMessage msg    = SendShedule(callback);
            long        result = await client.SendTextMessageAsync(msg);

            LeaguesCommand leaguesCommand = new LeaguesCommand(_leagueRepository, version);
            await leaguesCommand.Execute(callback, client);
        }
コード例 #2
0
        public async override Task Execute(Callback callback, IViberBotClient client)
        {
            PictureMessage msg = await GetImage(callback);

            long result = await client.SendPictureMessageAsync(msg);

            TeamsCommand teamsCommand = new TeamsCommand(_leagueRepository, version);
            await teamsCommand.Execute(callback, client);
        }
コード例 #3
0
        public void Init()
        {
            var config = new ConfigurationBuilder()
                         .SetBasePath(Directory.GetCurrentDirectory())
                         .AddJsonFile("appsettings.json")
                         .Build();

            _authToken  = config["authToken"];
            _webhookUrl = config["webhookUrl"];
            _adminId    = config["adminId"];

            _viberBotClient = new ViberBotClient(_authToken);
        }
コード例 #4
0
 public ViberBotService(IConfiguration configuration, IViberBotClient viberBotClient, IDataVersionRepository dataVersionRepository, IImageHelper imageHelper,
                        IUserRepository userRepository, ILeagueRepository leagueRepository, IScheduleRepository scheduleRepository, IMapper mapper)
 {
     _mapper                = mapper;
     _viberBotClient        = viberBotClient;
     _userRepository        = userRepository;
     _leagueRepository      = leagueRepository;
     _scheduleRepository    = scheduleRepository;
     _dataVersionRepository = dataVersionRepository;
     _imageHelper           = imageHelper;
     _webHook               = configuration["WebHook"];
     _viberUrl              = "/api/viber/update";
 }
コード例 #5
0
        public async override Task Execute(Callback callback, IViberBotClient client)
        {
            KeyboardMessage msg = await GetTeams(callback);

            long result = await client.SendKeyboardMessageAsync(msg);
        }
コード例 #6
0
        // ### Methods --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
        #region Methods
        // *** Service *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        #region Service
        /// <summary>
        /// Установить. Настройки
        /// </summary>
        public void SetSetting()
        {
            _authToken = "ХХХХХХХ";

            _viberBotClient = new ViberBotClient(_authToken);
        }
コード例 #7
0
ファイル: DialogueFrame.cs プロジェクト: LiveStone322/chatbot
        public static async void SendNextMessage(DialogueFrame df, HealthBotContext ctx, users dbUser,
                                                 CallbackData callbackData, IViberBotClient client)
        {
            string   message = "";
            Keyboard keyboard;

            string[] buttons = null;

            if (df.Activity == EnumActivity.Unknown)
            {
                if (df.Entity != "")
                {
                    message = df.Entity;
                }
                else
                {
                    return;
                }
            }
            else
            {
                message = await GetNextMessage(df, dbUser, ctx, buttons);

                if (df.Activity == EnumActivity.CallHuman)
                {
                    dbUser.id_last_question        = null;
                    dbUser.is_last_question_system = null;
                    dbUser.chatting = "viber";
                }
                if (dbUser.is_last_question_system.HasValue)
                {
                    //если нужно прислать картинку
                    if (dbUser.is_last_question_system.Value == true && dbUser.id_last_question == (int)SystemMessages.SendBiomark_plot)
                    {
                        using (Stream stream = System.IO.File.OpenRead(dbUser.token + ".png"))
                        {
                            await client.SendPictureMessageAsync(
                                new PictureMessage()
                            {
                                Text          = "Ваш график",
                                Receiver      = callbackData.Sender.Id,
                                MinApiVersion = callbackData.Message.MinApiVersion,
                                TrackingData  = callbackData.Message.TrackingData,
                                Media         = "https://upload.wikimedia.org/wikipedia/commons/5/57/Viber-logo.png" //viber is lame
                            }
                                );
                        }
                        dbUser.id_last_question        = null;
                        dbUser.is_last_question_system = null;
                    }
                }
                if (message != "")
                {
                    dbUser.id_last_question = (int?)df.Tag;
                    if (buttons != null)
                    {
                        keyboard = new Keyboard()
                        {
                            BackgroundColor = "#32C832",
                            Buttons         = buttons.Select(t => new Viber.Bot.KeyboardButton()
                            {
                                Text = t
                            }).ToList()
                        };
                        await client.SendKeyboardMessageAsync(new KeyboardMessage
                        {
                            Text          = message,
                            Keyboard      = keyboard,
                            Receiver      = callbackData.Sender.Id,
                            MinApiVersion = callbackData.Message.MinApiVersion,
                            TrackingData  = callbackData.Message.TrackingData
                        });
                    }
                    else
                    {
                        await client.SendTextMessageAsync(new TextMessage()
                        {
                            Text          = message,
                            Receiver      = callbackData.Sender.Id,
                            MinApiVersion = callbackData.Message.MinApiVersion,
                            TrackingData  = callbackData.Message.TrackingData
                        });
                    }
                }
                else
                {
                    dbUser.id_last_question = null;
                }
            }
        }
コード例 #8
0
 public abstract Task Execute(Callback callback, IViberBotClient client);
コード例 #9
0
 public ViberMessageSender(IViberBotClient viber)
 {
     _viber = viber;
 }
コード例 #10
0
        public SendMessageService(IBotFactory <IViberBotClient> viberBotFactory)
        {
            var botId = 1;

            this.viberBotClient = viberBotFactory.GetClient(botId);
        }