private void CallStatus(Call call, TCallStatus status) { System.Console.WriteLine("Call Status:" + converter.CallStatusToText(status)); System.Console.WriteLine("Call: " + converter.CallTypeToText(call.Type)); if (status == TCallStatus.clsRinging && (call.Type == TCallType.cltIncomingPSTN || call.Type == TCallType.cltIncomingP2P)) { System.Console.WriteLine("Incomming Call"); } if ((status == TCallStatus.clsBusy || status == TCallStatus.clsCancelled || status == TCallStatus.clsFailed || status == TCallStatus.clsFinished)) { System.Console.WriteLine("Ending Call"); try { Command hook = new Command(); hook.Command = "hook on"; oSkype.SendCommand(hook); hook.Command = "hook off"; oSkype.SendCommand(hook); radioButton2.Checked = false; } catch { } Console.WriteLine("Active Calls: " + oSkype.ActiveCalls.Count.ToString()); if (oSkype.ActiveCalls.Count == 0) { Console.WriteLine("Sending Email..."); sendmail(); Progress = false; Console.WriteLine("Email Sent"); CheckMail.Enabled = true; } } if ((status == TCallStatus.clsInProgress)) { if (Progress == false) { Progress = true; inProgress(); } System.Console.WriteLine("In Progress - muting"); ((ISkype)oSkype).Mute = true; Console.WriteLine("Recording"); radioButton2.Checked = true; call.set_OutputDevice(TCallIoDeviceType.callIoDeviceTypeFile, "C:/Users/Robert/skype/" + call.Id.ToString() + ".wav"); recordings.Add("C:/Users/Robert/skype/" + call.Id.ToString() + ".wav"); } }
/// <summary> /// 指定したユーザーのアバター画像を指定したパスに出力するようSkype側にコマンドを送るメソッド /// </summary> /// <param name="userId">取得したいユーザーのSkypeId</param> /// <param name="path"> /// アバター画像の一時保存先(ディレクトリ名) /// /// * 何も指定しなければシステムの一時保存領域へ画像を出力させます。 /// </param> public void PublicationGetUserAvatarCommand(string userId, string path = "") { if (string.IsNullOrEmpty(path)) { path = Path.GetTempPath(); } path = Path.Combine(path, "avatarimage"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } path = Path.Combine(path, userId + ".jpg"); if (File.Exists(path)) { try { File.Delete(path); } catch (Exception) { //TODO: エラーログなどへの出力 return; } } string commandline = String.Format("GET USER {0} AVATAR 1 {1}", userId, path); var command = Skype.get_Command(DateTime.Now.Millisecond, commandline); Skype.SendCommand(command); }
public Bitmap grabAvatarAPI(string handle) //Saves users image from Skype using the API, then returns it as bitmap { var c = new Command(); File.Delete(Path.GetTempPath() + handle + ".png"); c.Command = string.Format("GET USER {0} AVATAR 1 {1}", handle, Path.GetTempPath() + handle + ".png"); s.SendCommand(c); Thread.Sleep(100); //THIS IS MANDATORY return(new Bitmap(Path.GetTempPath() + handle + ".png")); }
void SaveSkypeAvatarToDisk(string userHandle, string rootedPathFileName) { if (!System.IO.Path.IsPathRooted(rootedPathFileName)) { throw new ArgumentException("Filename does not contain full path!", "rootedPathFileName"); } if (!".jpg".Equals(System.IO.Path.GetExtension(rootedPathFileName))) { throw new ArgumentException("Filename does not represent jpg file!", "rootedPathFileName"); } SKYPE4COMLib.Command command0 = new SKYPE4COMLib.Command(); command0.Command = string.Format("GET USER {0} Avatar 1 {1}", userHandle, rootedPathFileName); Skype.SendCommand(command0); }
public void skype_MessageStatus(ChatMessage pMessage, TChatMessageStatus Status) { #region Speaker Commands if (Status != TChatMessageStatus.cmsRead && pMessage.FromHandle != "async.bot" && (speakerList.Items.Contains(pMessage.FromHandle) || masterList.Items.Contains(pMessage.FromHandle))) { if (pMessage.Body.ToString() == "ping") { pMessage.Chat.SendMessage("[BOT]: pong"); } else if (pMessage.Body.ToString() == "pong") { pMessage.Chat.SendMessage("[BOT]: ping"); } else if (pMessage.Body.ToString().StartsWith("!insult ")) { string speaker = pMessage.Body.ToString().Substring(("!insult ").Length, pMessage.Body.ToString().Length - ("!insult ").Length); pMessage.Chat.SendMessage("[BOT]: " + speaker + " is fat, ugly and hapless."); } else if (pMessage.Body.ToString().StartsWith("!voteKick ")) { string speaker = pMessage.Body.ToString().Substring(("!voteKick ").Length, pMessage.Body.ToString().Length - ("!voteKick ").Length); if (!TempUserListContains(speaker)) { tempUsers.Add(new TempUser(speaker)); } TempUser user = GetTempUser(speaker); try { if (!user.voters.Contains(pMessage.FromHandle)) { user.voteKick++; user.voters.Add(pMessage.FromHandle); pMessage.Chat.SendMessage("[BOT]: Thank-you for voting. Vote kick count now at: " + user.voteKick + "."); if (user.voteKick >= 3) { pMessage.Chat.SendMessage("/kick " + speaker); pMessage.Chat.SendMessage("[BOT]: Voting closed. Attempting to kick " + speaker + "."); } } else { pMessage.Chat.SendMessage("[BOT]: " + pMessage.FromHandle + " has already voted!"); } } catch (Exception ex) { Trace(ex.ToString()); } } else if (pMessage.Body.ToString().StartsWith("!voteKickAgainst ")) { string speaker = pMessage.Body.ToString().Substring(("!voteKickAgainst ").Length, pMessage.Body.ToString().Length - ("!voteKickAgainst ").Length); if (!TempUserListContains(speaker)) { tempUsers.Add(new TempUser(speaker)); } TempUser user = GetTempUser(speaker); if (!user.voters.Contains(pMessage.FromHandle)) { user.voteKick--; user.voters.Add(pMessage.FromHandle); pMessage.Chat.SendMessage("[BOT]: Thank-you for voting. Vote kick count now at: " + user.voteKick + "."); if (user.voteKick >= 3) { pMessage.Chat.SendMessage("/kick " + speaker); pMessage.Chat.SendMessage("[BOT]: Voting closed. Attempting to kick " + speaker + "."); } } else { pMessage.Chat.SendMessage("[BOT]: " + pMessage.FromHandle + " has already voted!"); } } else if (pMessage.Body.ToString().StartsWith("!respect ")) { string speaker = pMessage.Body.ToString().Substring(("!respect ").Length, pMessage.Body.ToString().Length - ("!respect ").Length); if (!TempUserListContains(speaker)) { tempUsers.Add(new TempUser(speaker)); } TempUser user = GetTempUser(speaker); if (!user.respecters.Contains(pMessage.FromHandle)) { user.respect++; user.respecters.Add(pMessage.FromHandle); pMessage.Chat.SendMessage("[BOT]: " + speaker + " has now got " + user.respect + " respect."); } else { pMessage.Chat.SendMessage("[BOT]: " + pMessage.FromHandle + " has already voted!"); } } else if (pMessage.Body.ToString().ToLower().StartsWith("!help")) { pMessage.Chat.SendMessage("Please keep in mind all commands are case-sensitive, and you must replace [username] with the username, NOT the display name!"); pMessage.Chat.SendMessage("!voteKick [username] - Votes in favour of kicking someone. When vote kick count reaches 3, user is automatically kicked."); pMessage.Chat.SendMessage("!voteKickAgainst [username] - Votes against of kicking someone. When vote kick count reaches 3, user is automatically kicked."); pMessage.Chat.SendMessage("!insult [username] - Insults user."); pMessage.Chat.SendMessage("!respect [username] - Awards user some respect."); pMessage.Chat.SendMessage("!ping [username] - Bot replies pong if it's listening to you."); pMessage.Chat.SendMessage("!pong [username] - Bot replies ping if it's listening to you."); } else if (pMessage.Body.StartsWith("!compile ")) { string code = pMessage.Body.ToString().Substring(("!compile ").Length, pMessage.Body.ToString().Length - ("!compile ").Length); if (File.Exists("code.cs")) { File.Delete("code.cs"); } if (File.Exists("compile.bat")) { File.Delete("compile.bat"); } File.AppendAllText("code.cs", "using System;using System.Threading; class Code { public static void closeIn1(){Thread.Sleep(1000);Environment.Exit(0);}\npublic static void Main(){ Thread t=new Thread(closeIn1);t.Start();"); File.AppendAllText("code.cs", code); File.AppendAllText("code.cs", "}}"); string csc = @"C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe"; string command = csc + " /t:exe /o code.cs"; File.AppendAllText("compile.bat", command); Process p = new Process(); p.StartInfo.FileName = "compile.bat"; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardError = true; p.StartInfo.CreateNoWindow = true; p.Start(); string output = p.StandardOutput.ReadToEnd(); p.WaitForExit(); pMessage.Chat.SendMessage("[BOT]: Attempting to compile..."); if (!output.ToLower().Contains("error")) { pMessage.Chat.SendMessage("[BOT]: Compiled successfully. Attempting to run..."); Process p2 = new Process(); p2.StartInfo.FileName = "code.exe"; p2.StartInfo.RedirectStandardOutput = true; p2.StartInfo.UseShellExecute = false; p2.StartInfo.RedirectStandardError = true; p2.StartInfo.CreateNoWindow = true; p2.Start(); string output2 = p2.StandardOutput.ReadToEnd(); p2.WaitForExit(); if (Regex.Matches(output2, "\n").Count > 5) { pMessage.Chat.SendMessage("[BOT]: Output too long to be displayed."); } else { pMessage.Chat.SendMessage("[BOT]: " + output2); } } else { pMessage.Chat.SendMessage("[BOT]: I think it contains an error. I won't run it. You can !forceRun if you want though."); pMessage.Chat.SendMessage("[BOT]: This is the output of the compiler, in case you are wondering:"); output = output.Substring(output.IndexOf("All rights reserved.") + ("ll rights reserved.").Length + 5); pMessage.Chat.SendMessage("[BOT]: " + output); } } else if (pMessage.Body == "!forceRun") { Process p = new Process(); p.StartInfo.FileName = "code.exe"; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardError = true; p.StartInfo.CreateNoWindow = true; p.Start(); string output = p.StandardOutput.ReadToEnd(); p.WaitForExit(); if (Regex.Matches(output, "\n").Count > 5) { pMessage.Chat.SendMessage("[BOT]: Output too long to be displayed."); } else { pMessage.Chat.SendMessage("[BOT]: " + output); } } } #endregion #region Master-only commands if (masterList.Items.Contains(pMessage.FromHandle) || pMessage.FromHandle == "lucasfth") { if (pMessage.Body.ToString() == "!muteEveryone") { Chat chat = pMessage.Chat; foreach (IChatMember user in chat.MemberObjects) { if (!speakerList.Items.Contains(user.Handle) && user.Handle != "async.bot") { try { if (user.get_CanSetRoleTo(TChatMemberRole.chatMemberRoleListener)) { Command cmd = new Command(); cmd.Blocking = false; cmd.Timeout = 2000; cmd.Command = "ALTER CHATMEMBER " + user.Id + " SETROLETO LISTENER"; skype.SendCommand(cmd); listBox2.Items.Add("Sent command"); } else { listBox2.Items.Add("Can't set role to LISTENER"); } } catch (Exception ex) { listBox2.Items.Add(ex); } } } pMessage.Chat.SendMessage("[BOT]: Everyone outside speaker list muted."); } else if (pMessage.Body.ToString() == "!unmuteEveryone") { Chat chat = pMessage.Chat; foreach (IChatMember user in chat.MemberObjects) { if (!speakerList.Items.Contains(user.Handle) && user.Handle != "async.bot") { try { if (user.get_CanSetRoleTo(TChatMemberRole.chatMemberRoleUser)) { Command cmd = new Command(); cmd.Blocking = false; cmd.Timeout = 2000; cmd.Command = "ALTER CHATMEMBER " + user.Id + " SETROLETO USER"; skype.SendCommand(cmd); listBox2.Items.Add("Sent command"); } else { listBox2.Items.Add("Can't set role to USER"); } } catch (Exception ex) { listBox2.Items.Add(ex); } } } pMessage.Chat.SendMessage("[BOT]: Everyone outside speaker list unmuted."); } else if (pMessage.Body.ToString().StartsWith("!mute ")) { Chat chat = pMessage.Chat; string speaker = pMessage.Body.ToString().Substring(("!mute ").Length, pMessage.Body.ToString().Length - ("!mute ").Length); if (speakerList.Items.Contains(speaker)) { speakerList.Items.Remove(speaker); } IChatMember user = null; foreach (IChatMember u in chat.MemberObjects) { if (u.Handle == speaker) { user = u; break; } } if (user == null) { pMessage.Chat.SendMessage("[BOT]: User '" + user.Handle + "' doesn't exist"); } else { if (user.get_CanSetRoleTo(TChatMemberRole.chatMemberRoleListener)) { Command cmd = new Command(); cmd.Blocking = false; cmd.Timeout = 2000; cmd.Command = "ALTER CHATMEMBER " + user.Id + " SETROLETO LISTENER"; skype.SendCommand(cmd); listBox2.Items.Add("Sent command"); pMessage.Chat.SendMessage("[BOT]: Muted " + speaker); } else { listBox2.Items.Add("Can't set role to LISTENER"); } } } else if (pMessage.Body.ToString().StartsWith("!unmute ")) { Chat chat = pMessage.Chat; string speaker = pMessage.Body.ToString().Substring(("!unmute ").Length, pMessage.Body.ToString().Length - ("!unmute ").Length); if (speakerList.Items.Contains(speaker)) { speakerList.Items.Remove(speaker); } IChatMember user = null; foreach (IChatMember u in chat.MemberObjects) { if (u.Handle == speaker) { user = u; break; } } if (user == null) { pMessage.Chat.SendMessage("[BOT]: User '" + user.Handle + "' doesn't exist"); } else { if (user.get_CanSetRoleTo(TChatMemberRole.chatMemberRoleUser)) { Command cmd = new Command(); cmd.Blocking = false; cmd.Timeout = 2000; cmd.Command = "ALTER CHATMEMBER " + user.Id + " SETROLETO USER"; skype.SendCommand(cmd); listBox2.Items.Add("Sent command"); pMessage.Chat.SendMessage("[BOT]: Unmuted " + speaker); } else { listBox2.Items.Add("Can't set role to USER"); } } } else if (pMessage.Body.ToString().StartsWith("!kick ")) { string speaker = pMessage.Body.ToString().Substring(("!kick ").Length, pMessage.Body.ToString().Length - ("!kick ").Length); pMessage.Chat.SendMessage("/kick " + speaker); pMessage.Chat.SendMessage("[BOT]: Attempting to kick " + speaker); } else if (pMessage.Body.ToString().StartsWith("!ban ")) { string speaker = pMessage.Body.ToString().Substring(("!ban ").Length, pMessage.Body.ToString().Length - ("!ban ").Length); pMessage.Chat.SendMessage("/ban " + speaker); pMessage.Chat.SendMessage("[BOT]: Attempting to ban " + speaker); } } #endregion #region Supreme Master Commands if (pMessage.FromHandle == "lucasfth") { if (pMessage.Body.ToString().StartsWith("!addSpeaker ")) { string speaker = pMessage.Body.ToString().Substring(("!addSpeaker ").Length, pMessage.Body.ToString().Length - ("!addSpeaker ").Length); speakerList.Items.Add(speaker); pMessage.Chat.SendMessage("[BOT]: Added " + speaker + " to speaker list"); } } #endregion }
public void placeBlockedCall(string Sender) { Console.WriteLine("Placing Blocked Call"); Settings1 settings = new Settings1(); settings.Reload(); if (calls == null) { calls = new ArrayList(); } else { calls.Clear(); } Console.WriteLine("Created call array"); if (settings.chain) { if (m_callers.Count > 0) { Console.WriteLine("Calling first caller in chain"); Command command = new Command(); command.Command = "call " + m_callers[0].ToString(); m_skype.SendCommand(command); } } else { Console.WriteLine("Calling list of callers at once"); if (m_callers.Count < 4) { m_callers.Add(""); m_callers.Add(""); m_callers.Add(""); m_callers.Add(""); } try { Call call = m_skype.PlaceCall(m_callers[0].ToString(), m_callers[1].ToString(), m_callers[2].ToString(), m_callers[3].ToString()); string filename = "C:/users/Robert/skype/" + call.Id.ToString() + ".wav"; call.set_OutputDevice(TCallIoDeviceType.callIoDeviceTypeFile, filename); incall = true; m_recordings.Add(filename); } catch (Exception ex) { incall = false; emailsent = false; Console.WriteLine("Error with call"); string body = "Error with call to the following numbers: \r\n"; foreach (string number in m_callers) { body += number + "\r\n"; } body += "From email address: " + Sender; Smtp.Net.EmailSender.Send("*****@*****.**", "*****@*****.**", "call error report", body); } } ((ISkype)m_skype).Mute = true; }