Ejemplo n.º 1
0
        public async Task <IActionResult> StartServerBot(int id)
        {
            var serverModel = await _context.Servers.FindAsync(id);

            var channels = await _context.Channels.Where(channel => channel.ServerModelId == id).ToListAsync();

            if (channels != null)
            {
                foreach (var channel in channels)
                {
                    var bot = _runningBots.Find(x => (x.Channel == channel.ChannelName) && (x.Username == serverModel.Username) && (x.Server == serverModel.Host));
                    if (bot == null)
                    {
                        CytubeBot cytubebot = new CytubeBot(serverModel.Host, channel.ChannelName, serverModel.Username, serverModel.Password);
                        cytubebot.websocket.MessageReceived += new CytubeBotWeb.Helper.CytubeBotCoreHelper(channel, cytubebot).websocket_MessageReceivedLog;
                        cytubebot.Connect();
                        _runningBots.Add(cytubebot);
                    }
                }
            }

            return(RedirectToAction(nameof(Index)));
        }
Ejemplo n.º 2
0
 public CytubeBotCoreHelper(ChannelModel channel, CytubeBot cytubebot)
 {
     _channel = channel;
     _bot     = cytubebot;
 }