Exemplo n.º 1
0
 public Task <IConversation> StartConversation(IMainBot mainBot, ITgUser tgUserInfo, string firstMessage)
 {
     return(Task <IConversation> .Factory.StartNew(() =>
     {
         var conversation = new UserUnbuildedConversation(mainBot, tgUserInfo, firstMessage);
         conversation.ProcessConversation();
         return conversation;
     }));
 }
        public Task <IConversation> StartConversation(IMainBot mainBot, ITgUser tgUserInfo, string firstMessage)
        {
            var reMatch = this.FirstMessage.Match(firstMessage);
            var prjName = tgUserInfo.Name;

            if (reMatch.Groups["prj"].Success)
            {
                prjName = reMatch.Groups["prj"].Value.Trim();
            }
            string ver = null;

            if (reMatch.Groups["ver"].Success)
            {
                ver = reMatch.Groups["ver"].Value.Trim();
            }

            var prj = mainBot.Projects.SingleOrDefault(x => x.RedmineProjectName != null && x.RedmineProjectName.ToLower() == prjName.ToLower());

            if (prj != null)
            {
                return(Task <IConversation> .Factory.StartNew(() =>
                {
                    var conversation = new SimpleMessageConversation(mainBot, tgUserInfo);
                    var versionMessage = ConversationHelper.GenerateVersionInfo(prj, mainBot, prj.VersionCurrent).Result;
                    var msgTask = conversation.ProcessMessage(versionMessage);
                    if (!msgTask.IsCompleted)
                    {
                        msgTask.Wait();
                    }
                    return conversation;
                }));
            }
            else
            {
                return(Task <IConversation> .Factory.StartNew(() =>
                {
                    var conversation = new SimpleMessageConversation(mainBot, tgUserInfo);
                    var msgTask = conversation.ProcessMessage("Проект неизвестен");
                    if (!msgTask.IsCompleted)
                    {
                        msgTask.Wait();
                    }
                    return conversation;
                }));
            }
        }
Exemplo n.º 3
0
 public SimpleMessageConversation([NotNull] IMainBot mainBot, [NotNull] ITgUser tgUserInfo)
 {
     this.MainBot  = mainBot;
     this.TgUser   = tgUserInfo;
     this.IsActive = true;
 }
Exemplo n.º 4
0
 public async Task EditMessageText(ITgUser tgUser, int messageId, string message)
 {
     await this.TgService.Value.EditMessage(tgUser.TgId.Value, messageId, message);
 }
Exemplo n.º 5
0
 public async Task <int> DirectSendMessage(ITgUser tgUser, string message)
 {
     return(await this.TgService.Value.SendMessage(tgUser.TgId.Value, message));
 }
Exemplo n.º 6
0
 public void FinishDialog(ITgUser tgUser)
 {
     this.Conversations.TryRemove(tgUser, out _);
 }
Exemplo n.º 7
0
 public UserUnbuildedConversation(IMainBot mainBot, ITgUser tgUserInfo, string firstMessage)
 {
     this.MainBot      = mainBot;
     this.TgUser       = tgUserInfo;
     this.FirstMessage = firstMessage;
 }
Exemplo n.º 8
0
 public UserStatLongTimeConversation(IMainBot mainBot, ITgUser tgUserInfo, string firstMessage)
 {
     this.MainBot      = mainBot;
     this.TgUser       = tgUserInfo;
     this.FirstMessage = firstMessage;
 }