Advertisement
Guest User

Untitled

a guest
Dec 21st, 2011
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.91 KB | None | 0 0
  1.     class Own3dTVMonitor
  2.     {
  3.         private string _OTVdescription;
  4.         private string _OTVnick;
  5.         private string _OTVid;
  6.         private bool _OTVstreamOnline;
  7.         private int _OTVstreamViewers;
  8.         private bool _OTVstreamNotification;
  9.         private static int _OTVonlineStreams = 0;
  10.         private static bool _OTVFirstRun = true;
  11.         private bool _OTVoverridden;
  12.         private bool _OTVstreamNumber;
  13.  
  14.         private string OTVdescription
  15.         {
  16.             get { return _OTVdescription; } set {_OTVdescription = value;}
  17.         }
  18.  
  19.         public string OTVnick
  20.         {
  21.             get { return _OTVnick; } //set {_OTVnick = value;}
  22.         }
  23.  
  24.         public string OTVid
  25.         {
  26.             get { return _OTVid; } //set {_OTVurl = value;}
  27.         }
  28.  
  29.         public bool OTVstreamOnline
  30.         {
  31.             get { return _OTVstreamOnline; } set {_OTVstreamOnline = value;}
  32.         }
  33.  
  34.         public int OTVstreamViewers
  35.         {
  36.             get { return _OTVstreamViewers; } set {_OTVstreamViewers = value;}
  37.         }
  38.  
  39.         public bool OTVstreamNotification
  40.         {
  41.             get { return OTVstreamNotification; } set {_OTVstreamNotification = value;}
  42.         }
  43.  
  44.         public static int OTVonlineStreams
  45.         {
  46.             get { return _OTVonlineStreams; } set { _OTVonlineStreams = value; }
  47.         }
  48.  
  49.         public bool OTVoverridden
  50.         {
  51.             get { return _OTVoverridden; } set {_OTVoverridden = value;}
  52.         }
  53.  
  54.         public Own3dTVMonitor(string OTVnick, string OTVurl)
  55.         {
  56.             _OTVnick = OTVnick;
  57.             _OTVid = OTVurl;
  58.             _OTVdescription = "";
  59.             _OTVstreamOnline = false;
  60.         }
  61.  
  62.         public Own3dTVMonitor(string OTVnick, string OTVurl, string OTVdescription)
  63.         {
  64.             _OTVnick = OTVnick;
  65.             _OTVid = OTVurl;
  66.             _OTVdescription = OTVdescription;
  67.         }
  68.  
  69.         public static void checkAll()
  70.         {
  71.             foreach (Own3dTVMonitor OTVstream in Bot.OTVstreams)
  72.             {
  73.                 OTVstream.checkOnline();
  74.             }
  75.         }
  76.  
  77.  
  78.         public void checkOnline()
  79.         {
  80.             try
  81.             {
  82.                 XmlTextReader reader = new XmlTextReader("http://api.own3d.tv/liveCheck.php?live_id=" + OTVid);
  83.                 bool done = false;
  84.                 while (reader.Read() && !done)
  85.                 {
  86.                     switch (reader.NodeType)
  87.                     {
  88.                         case XmlNodeType.Text:
  89.                             if (OTVstreamOnline != bool.Parse(reader.Value) && !OTVoverridden)
  90.                             {
  91.                                 OTVstreamOnline = bool.Parse(reader.Value);
  92.                                 if (OTVstreamOnline)
  93.                                 {
  94.                                     OTVonlineStreams++;
  95.                                 }
  96.                                 else
  97.                                 {
  98.                                     OTVonlineStreams--;
  99.                                 }
  100.                                 OTVAnnounce();
  101.                             }
  102.                             break;
  103.                         case XmlNodeType.EndElement:
  104.                             done = true;
  105.                             Console.WriteLine(OTVnick + " online = " + OTVstreamOnline);
  106.                             break;
  107.  
  108.                     }
  109.                 }
  110.             }
  111.             catch (XmlException)
  112.             {
  113.                 Console.WriteLine("File not found.");
  114.             }
  115.         }
  116.  
  117.         public void OTVAnnounce()
  118.         {
  119.             if (OTVstreamOnline)
  120.             {
  121.                 Bot.sendMessage(Bot.ircChannel, "Now broadcasting: " + OTVnick + " - " + OTVweblink());
  122.                 OTVupdateTopic();
  123.             }
  124.             else
  125.             {
  126.                 Bot.sendMessage(Bot.ircChannel, "Broadcast ended: " + OTVnick);
  127.                 OTVupdateTopic();
  128.             }
  129.         }
  130.  
  131.         public static void OTVupdateTopic()
  132.         {
  133.             StreamReader streamReader = new StreamReader("Data\\topic.txt");
  134.             string topic = streamReader.ReadLine();
  135.             streamReader.Close();
  136.             if (OTVonlineStreams > 0)
  137.             {
  138.                 Bot.changeTopic(Bot.ircChannel, (char)15 + topic + " " + (char)3 + "03" + OTVonlineStreams + " online streams" + (char)15 + ", use \"!streams\" to display the stream information.");
  139.             }
  140.             else
  141.             {
  142.                 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.");
  143.             }
  144.         }
  145.  
  146.         public string OTVweblink()
  147.         {
  148.             string otvlink = "http://www.own3d.tv/live/" + OTVid;
  149.             return otvlink;
  150.         }
  151.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement