public void Initialize(BotConfig config) { m_output.LogMessage("info", string.Format("[READCHATMODULE]: I was Initialized! My name is {0}", config.general.BotName)); SetUpSpeechSynth(); }
public void ChannelParted(TwitchChannel channel) { m_output.LogMessage("info", string.Format("[TESTMODULE]: Left Channel - {0} ", channel.Channel)); }
private void Handler_OnData(object sender, WebsocketDataEventArgs data) { byte[] databuffer = data.Data; m_Output.LogMessage("Info", "[WEBSOCKET]: We got some weird data"); }
public OSHttpRequest(IHttpClientContext context, IHttpRequest req) { _botOutput = BotOutput.Instance; _request = req; _context = context; if (req.Headers["content-encoding"] != null) { _contentEncoding = Encoding.GetEncoding(_request.Headers["content-encoding"]); } if (req.Headers["content-type"] != null) { _contentType = _request.Headers["content-type"]; } if (req.Headers["user-agent"] != null) { _userAgent = _request.Headers["user-agent"]; } if (req.Headers["remote_addr"] != null) { try { IPAddress addr = IPAddress.Parse(req.Headers["remote_addr"]); string[] strPorts = _request.Headers["remote_port"].Split(new char[] { ',' }); if (strPorts.Length > 1) { _botOutput.LogMessage("error", string.Format("[HttpRequest]: format exception on addr/port {0}:{1}, ignoring {2}", _request.Headers["remote_addr"], _request.Headers["remote_port"], Environment.NewLine)); } int port = Int32.Parse(strPorts[0]); _remoteIPEndPoint = new IPEndPoint(addr, port); } catch (FormatException) { // _botOutput.LogMessage("error", string.Format("[HttpRequest]: format exception on addr/port {0}:{1}, ignoring {2}", _request.Headers["remote_addr"], _request.Headers["remote_port"], Environment.NewLine)); } } _queryString = new NameValueCollection(); _query = new Hashtable(); try { foreach (HttpInputItem item in req.QueryString) { try { _queryString.Add(item.Name, item.Value); _query[item.Name] = item.Value; } catch (InvalidCastException) { _botOutput.LogMessage("error", string.Format("[HttpRequest]: error parsing {0} query item, skipping it {1}", item.Name, Environment.NewLine)); } } } catch (Exception) { _botOutput.LogMessage("error", "[HttpRequest]: error parsing querystring."); } }
private void StartHTTP() { if (HTTPRunning) { return; } int m_port_original = 0; int m_optional_port = 0; try { m_port_original = (int)m_port; m_optional_port = m_port_original + 1; m_HttpListener = CoolHTTPListener.Create(IPAddress.Any, (int)m_port); m_HttpListener.ExceptionThrown += httpServerException; m_HttpListener.RequestReceived += OnRequest; m_HttpListener.Start(m_BotConfig.httpserver.BacklogQueue); HTTPRunning = true; } catch (Exception e) { m_Output.LogMessage("error", "[HTTPD]: Failed to start HTTPD with " + e.Message + ". Trying alternate port." + Environment.NewLine); try { m_HttpListener = CoolHTTPListener.Create(IPAddress.Any, (int)m_optional_port); m_HttpListener.ExceptionThrown += httpServerException; m_HttpListener.RequestReceived += OnRequest; m_HttpListener.Start(m_BotConfig.httpserver.BacklogQueue); HTTPRunning = true; } catch (Exception f) { m_Output.LogMessage("error", "[HTTPD]: Failed to start HTTPD with " + f.Message + Environment.NewLine); } } }