static void Main(string[] args) { bot = new HelloBot(); bot.OnErrorOccured += BotOnErrorOccured; Task.Run(delegate { try { skype.MessageStatus += OnMessageReceived; skype.Attach(5, true); chatSyncer = new SkypeChatSyncer(); chatSyncer.OnSendMessageRequired += ChatSyncerOnOnSendMessageRequired; Console.WriteLine("skype attached"); } catch (Exception ex) { Console.WriteLine("top lvl exception : " + ex.ToString()); } while (true) { Thread.Sleep(1000); } }); while (true) { Thread.Sleep(1000); } }
public Task StartBot(ISkypeAdapter skype, ITeamCityClient teamCity, BotParameters botParameters, Dictionary <string, string> moduleParameters, TimeConfig timeConfig) { _working = true; _skype = skype; _teamcity = teamCity; _botParameters = botParameters; _timeConfig = timeConfig; var task = Task.Run(delegate { try { _publishChat = _skype.GetChat(botParameters.PublishChatName); if (_publishChat != null) { Console.WriteLine("publish chat found!"); } else { Console.WriteLine("publish chat NOT found!"); } _skype.OnMessageReceived += OnMessageReceived; _timer = new Timer { Interval = timeConfig.BuildCheckInterval.TotalMilliseconds }; _timer.Elapsed += timer_Elapsed; _timer.AutoReset = false; _timer.Start(); while (_working) { Thread.Sleep(5); } } catch (Exception ex) { Console.WriteLine("top lvl exception : " + ex); } }); buildCheckers = _botParameters.Branches.Select( x => new TeamCityBuildChecker( BuildLocator.WithDimensions(BuildTypeLocator.WithId(_botParameters.BuildConfigId), branch: x), _teamcity, x, _timeConfig)).ToList(); _bot = new HelloBot(moduleParameters, buildCheckers, MailSettingsSectionGroup => SendMessage(MailSettingsSectionGroup, _publishChat)); _bot.OnErrorOccured += BotOnErrorOccured; return(task); }
static void Main(string[] args) { HelloBot bot = new HelloBot(); //bot.HandleMessage("!Скажи риновский", s => //{ // Console.WriteLine(s); //},null); //List<string> s2 = new List<string>() { "Сиськи" }; //foreach (var v in s2) //{ // new Quote().HandleMessage(v, null, s => // Console.WriteLine(s)); //} Console.ReadLine(); }
public BotController(ILogger <BotController> logger, IConfiguration configuration, HelloBot bot) : base() { _logger = logger; _configuration = configuration; _bot = bot; }