Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Own3dTVMonitor
- {
- private string _OTVdescription;
- private string _OTVnick;
- private string _OTVid;
- private bool _OTVstreamOnline;
- private int _OTVstreamViewers;
- private bool _OTVstreamNotification;
- private static int _OTVonlineStreams = 0;
- private static bool _OTVFirstRun = true;
- private bool _OTVoverridden;
- private bool _OTVstreamNumber;
- private string OTVdescription
- {
- get { return _OTVdescription; } set {_OTVdescription = value;}
- }
- public string OTVnick
- {
- get { return _OTVnick; } //set {_OTVnick = value;}
- }
- public string OTVid
- {
- get { return _OTVid; } //set {_OTVurl = value;}
- }
- public bool OTVstreamOnline
- {
- get { return _OTVstreamOnline; } set {_OTVstreamOnline = value;}
- }
- public int OTVstreamViewers
- {
- get { return _OTVstreamViewers; } set {_OTVstreamViewers = value;}
- }
- public bool OTVstreamNotification
- {
- get { return OTVstreamNotification; } set {_OTVstreamNotification = value;}
- }
- public static int OTVonlineStreams
- {
- get { return _OTVonlineStreams; } set { _OTVonlineStreams = value; }
- }
- public bool OTVoverridden
- {
- get { return _OTVoverridden; } set {_OTVoverridden = value;}
- }
- public Own3dTVMonitor(string OTVnick, string OTVurl)
- {
- _OTVnick = OTVnick;
- _OTVid = OTVurl;
- _OTVdescription = "";
- _OTVstreamOnline = false;
- }
- public Own3dTVMonitor(string OTVnick, string OTVurl, string OTVdescription)
- {
- _OTVnick = OTVnick;
- _OTVid = OTVurl;
- _OTVdescription = OTVdescription;
- }
- public static void checkAll()
- {
- foreach (Own3dTVMonitor OTVstream in Bot.OTVstreams)
- {
- OTVstream.checkOnline();
- }
- }
- public void checkOnline()
- {
- try
- {
- XmlTextReader reader = new XmlTextReader("http://api.own3d.tv/liveCheck.php?live_id=" + OTVid);
- bool done = false;
- while (reader.Read() && !done)
- {
- switch (reader.NodeType)
- {
- case XmlNodeType.Text:
- if (OTVstreamOnline != bool.Parse(reader.Value) && !OTVoverridden)
- {
- OTVstreamOnline = bool.Parse(reader.Value);
- if (OTVstreamOnline)
- {
- OTVonlineStreams++;
- }
- else
- {
- OTVonlineStreams--;
- }
- OTVAnnounce();
- }
- break;
- case XmlNodeType.EndElement:
- done = true;
- Console.WriteLine(OTVnick + " online = " + OTVstreamOnline);
- break;
- }
- }
- }
- catch (XmlException)
- {
- Console.WriteLine("File not found.");
- }
- }
- public void OTVAnnounce()
- {
- if (OTVstreamOnline)
- {
- Bot.sendMessage(Bot.ircChannel, "Now broadcasting: " + OTVnick + " - " + OTVweblink());
- OTVupdateTopic();
- }
- else
- {
- Bot.sendMessage(Bot.ircChannel, "Broadcast ended: " + OTVnick);
- OTVupdateTopic();
- }
- }
- public static void OTVupdateTopic()
- {
- StreamReader streamReader = new StreamReader("Data\\topic.txt");
- string topic = streamReader.ReadLine();
- streamReader.Close();
- if (OTVonlineStreams > 0)
- {
- Bot.changeTopic(Bot.ircChannel, (char)15 + topic + " " + (char)3 + "03" + OTVonlineStreams + " online streams" + (char)15 + ", use \"!streams\" to display the stream information.");
- }
- else
- {
- Bot.changeTopic(Bot.ircChannel, (char)15 + topic + " " + (char)3 + "04All streams are offline" + (char)15 + ", use \"/msg " + Bot.ircNick + " !help\" to find out how to add your stream to the bot.");
- }
- }
- public string OTVweblink()
- {
- string otvlink = "http://www.own3d.tv/live/" + OTVid;
- return otvlink;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement