private static void ShowUpTime() { Task.Run(delegate { while (true) { if (Console.ReadLine().ToLower() == "uptime") { Extentions.ConsoleWriteLine(String.Format("Up time: {0}", upTime.Elapsed), ConsoleColor.Cyan); } } }); }
private static void ConnectToSkype() { Task.Run(delegate { try { if (!skype.Client.IsRunning) { skype.Client.Start(true, true); } skype.MessageStatus += OnMessageReceived; skype.Attach(7, true); Extentions.ConsoleWriteLine("Skype connected", ConsoleColor.Green); } catch (Exception ex) { Extentions.ConsoleWriteLine("Top lvl exception: " + ex.ToString(), ConsoleColor.Red); } }); }
private static TwitterStatus SendImageMessage(TwitterService service, MessageEntity message) { TwitterStatus status = null; try { HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(message.Message); WebResponse myResp = myReq.GetResponse(); using (Stream stream = myResp.GetResponseStream()) using (MemoryStream ms = new MemoryStream()) { int count = 0; do { byte[] buf = new byte[1024]; count = stream.Read(buf, 0, 1024); ms.Write(buf, 0, count); } while (stream.CanRead && count > 0); status = service.SendTweetWithMedia(new SendTweetWithMediaOptions() { Status = message.Message, DisplayCoordinates = false, Images = new Dictionary <string, Stream>() { { message.TwitterNick, ms } } }); } } catch (Exception ex) { Extentions.ConsoleWriteLine(ex.Message, ConsoleColor.Red); } return(status); }