public void ErrorTest() { string errorMessage = "Server *.fi already exists."; string expected = "ERROR :Server *.fi already exists."; Assert.AreEqual(expected, IrcCommand.Error(errorMessage)); }
public override void Process(IrcCommand command) { base.Process(command); var helpCommand = new UserLoginHelpCommand(); if (HandleNoParameters(helpCommand, forcePrivate: true)) return; if (command.Parameters[0] == "help" || !ValidParameters()) { helpCommand.Process(command); return; } var username = command.Parameters[0]; var password = command.Parameters[1]; string message = string.Empty; Data.User user; if (TryLogin(username, password, out message, out user)) { command.Bot.RegisterUser( new IrcBotUser { UserName = username, NickName = command.Source.Name, IsAdmin = user.IsAdmin, IsBotAdmin = user.IsBotAdmin } ); } SendPrivateMessage(message); }
protected override void OnReceivedLine(string line) { var cmd = new IrcCommand(); cmd.Channel = line.SubString(x,y); cmd.Message = line.SubString(z,a); CommandReceived(this, new IrcCommandEventArgs(cmd)); }
public string FindFileOLD(IrcCommand command) { string name = command.Parameters[0]; string searchstring = RevDBs[CurrentBranchOLD].FindFile(name); return("Done: " + searchstring.Haste()); }
public void PassTest() { const string password = "******"; const string expected = "PASS TestPassword"; Assert.AreEqual(expected, IrcCommand.Pass(password)); }
public void NoticeTest() { const string target = "Angel"; const string message = "yes I'm receiving it!"; Assert.AreEqual("NOTICE Angel :yes I'm receiving it!", IrcCommand.Notice(target, message)); }
public void IsonTest() { Assert.AreEqual("ISON Wiz", IrcCommand.Ison("Wiz")); Assert.AreEqual("ISON Wiz Angel", IrcCommand.Ison(new List <string> { "Wiz", "Angel" })); }
public string RegisterUser(IrcCommand command) { userdb.RegisterUser(command.Source.Nick, command.Parameters[0], command.Source.Hostmask); SaveDB(); return("Done. Your password is stored with SHA256"); }
public void AdminTest() { Assert.AreEqual("ADMIN", IrcCommand.Admin()); string target = "tolsun.oulu.fi"; Assert.AreEqual($"ADMIN {target}", IrcCommand.Admin(target)); }
public void NickTest() { const string nickname = "Tom"; const string expected = "NICK Tom"; Assert.AreEqual(expected, IrcCommand.Nick(nickname)); }
public override void Process(IrcCommand command) { base.Process(command); if (!HasAdminUser()) return; var message = string.Format("I'm going to need a little more information, {0}.", command.Source.Name); if (HandleNoParameters(message, new AwsElbRepairHelpCommand())) return; SendMessage("checking status..."); this.states = GetInstanceStates(); SendMessage(GetInstanceStatusMessage()); var badInstances = GetBadInstances(); if (badInstances.Count > 0) { RebootInstances(badInstances); } else { SendMessage( string.Format( "no out of service instances detected, {0}. celebrate!", this.command.Source.Name ) ); } }
public void PrivateMessageTest() { const string target = "Angel"; const string message = "yes I'm receiving it!"; Assert.AreEqual("PRIVMSG Angel :yes I'm receiving it!", IrcCommand.PrivateMessage(target, message)); }
public static BotCommand Parse(IrcCommand ircCommand) { BotCommand botCommand = new BotCommand(); SetProperties(ircCommand, botCommand); return(botCommand); }
public void InviteTest() { const string nickname = "Wiz"; const string channel = "#Twilight_Zone"; Assert.AreEqual("INVITE Wiz #Twilight_Zone", IrcCommand.Invite(nickname, channel)); }
public void QuitTest() { const string message = "Gone to have lunch"; const string expected = "QUIT :Gone to have lunch"; Assert.AreEqual("QUIT", IrcCommand.Quit()); Assert.AreEqual(expected, IrcCommand.Quit(message)); }
public void TopicTest() { const string channel = "#test"; Assert.AreEqual("TOPIC #test :another topic", IrcCommand.Topic(channel, "another topic")); Assert.AreEqual("TOPIC #test :", IrcCommand.ClearTopic(channel)); Assert.AreEqual("TOPIC #test", IrcCommand.GetTopic(channel)); }
public void OperTest() { const string name = "foo"; const string password = "******"; const string expected = "OPER foo bar"; Assert.AreEqual(expected, IrcCommand.Oper(name, password)); }
public void UserModeTest() { const string nickname = "WiZ"; const string modeString = "-w"; const string expected = "MODE WiZ -w"; Assert.AreEqual(expected, IrcCommand.UserMode(nickname, modeString)); }
public void SquitTest() { const string server = "tolsun.oulu.fi"; const string message = "Bad Link"; const string expected = "SQUIT tolsun.oulu.fi :Bad Link"; Assert.AreEqual(expected, IrcCommand.Squit(server, message)); }
/// <summary> /// Create an INCOMPLETE IrcMessage only carrying username /// </summary> /// <param name="user"></param> public IrcMessage(string user) { _parameters = null; User = user; Hostmask = null; Command = IrcCommand.Unknown; Tags = null; }
public void UserHostTest() { Assert.AreEqual("USERHOST Wiz", IrcCommand.UserHost("Wiz")); Assert.AreEqual("USERHOST Wiz Michael syrk", IrcCommand.UserHost(new List <string> { "Wiz", "Michael", "syrk" })); }
public void AwayTest() { Assert.AreEqual("AWAY", IrcCommand.Away()); string message = "Gone to lunch."; string expected = "AWAY :Gone to lunch."; Assert.AreEqual(expected, IrcCommand.Away(message)); }
public override void Process(IrcCommand command) { base.Process(command); SendMessage( "It's easy! Just type this: aws elb status <load balancer name>. If you need a list of load balancers, that command is: aws elb list." ); }
public override void Process(IrcCommand command) { base.Process(command); SendMessage("retrieving list of load balancers..."); var descriptions = this.elb.List(command.Parameters.FirstOrDefault()); SendMessages(GetMessages(descriptions)); SendMessage("use \"aws elb status <elb name>\" to see more information"); }
public string SendMessage(IrcCommand command) { string username = command.Parameters[0]; string message = command.Message.Remove(0, username.Length + 1); message = "From " + command.Source.Nick + " on " + DateTime.Now.ToString() + ": " + message; return(SendMemo(username, message) ? "Message Sent" : "User does not exist"); }
public void InfoTest() { string target = "csd.bu.edu"; string expected = "INFO csd.bu.edu"; Assert.AreEqual(expected, IrcCommand.Info(target)); expected = "INFO"; Assert.AreEqual(expected, IrcCommand.Info()); }
public void ServiceTest() { const string serviceName = "dict"; const string distribution = "*.fr"; const string info = "French Dictionary"; const string expected = "SERVICE dict * *.fr 0 0 :French Dictionary"; Assert.AreEqual(expected, IrcCommand.Service(serviceName, distribution, info)); }
public void NamesTest() { Assert.AreEqual("NAMES", IrcCommand.Names()); Assert.AreEqual("NAMES #42", IrcCommand.Names("#42")); List <string> channels = new List <string> { "#twilight_zone", "#42" }; Assert.AreEqual("NAMES #twilight_zone,#42", IrcCommand.Names(channels)); }
/// <summary> /// Create an IrcMessage /// </summary> /// <param name="command">IRC Command</param> /// <param name="parameters">Command params</param> /// <param name="hostmask">User</param> /// <param name="tags">IRCv3 tags</param> public IrcMessage(IrcCommand command, string[] parameters, string hostmask, Dictionary <string, string> tags = null) { var idx = hostmask.IndexOf('!'); User = idx != -1 ? hostmask.Substring(0, idx) : hostmask; Hostmask = hostmask; _parameters = parameters; Command = command; Tags = tags; }
public string DumpRevs(IrcCommand command) { string data = ""; foreach (Revision rev in RevDBs[CurrentBranchOLD].AllRevisions) { data += rev.name + "\n"; } return("Done: " + data.Haste()); }
public override void Process(IrcCommand command) { base.Process(command); var message = string.Format("I'm going to need a little more information, {0}.", command.Source.Name); if (HandleNoParameters(message, new AwsElbStatusHelpCommand())) return; SendMessage("checking status..."); SendMessage(GetInstanceStatusMessage()); }
public void UserTest() { const string user = "******"; const string modeString = "-i+a"; const string realname = "Ronnie Reagan"; string expected = "USER guest 0 * :Ronnie Reagan"; expected = "USER guest -i+a * :Ronnie Reagan"; Assert.AreEqual(expected, IrcCommand.User(user, modeString, realname)); }
public void PartTest() { Assert.AreEqual("PART #twilight_zone", IrcCommand.Part("#twilight_zone")); List <string> channels = new List <string> { "#oz-ops", "&group5" }; Assert.AreEqual("PART #oz-ops,&group5", IrcCommand.Part(channels)); Assert.AreEqual("PART #twilight_zone :Lunch Time.", IrcCommand.Part("#twilight_zone", "Lunch Time.")); Assert.AreEqual("PART #oz-ops,&group5 :Lunch Time.", IrcCommand.Part(channels, "Lunch Time.")); }
public override void Process(IrcCommand command) { base.Process(command); if (HandleNoParameters(new AwsElbHelpCommand())) return; command.Shift(); var processor = processorFactory.CreateByCommand(command); processor.Process(command); }
public string OpenRevisionOLD(IrcCommand command) { if (RevDBs[CurrentBranchOLD].RevisionOpen) { return("Cannot open revision while " + RevDBs[CurrentBranchOLD].openRev + " is Open"); } string name = command.Parameters[0]; RevDBs[CurrentBranchOLD].OpenRevision(name); return("Opened " + name); }
public string DeleteRevision(IrcCommand command) { Revision rev = RevDBs[CurrentBranchOLD].GetRevisionByName(command.Parameters[0]); if (rev == null) { return("No Revision " + command.Parameters[0]); } RevDBs[CurrentBranchOLD].DeleteRevision(rev); return("Done"); }
public override void Process(IrcCommand command) { base.Process(command); if (!HasParameters) { PrintTaskList(); } else { command.Shift(); var processor = processorFactory.CreateByCommand(command); processor.Process(command); } }
public override void Process(IrcCommand command) { base.Process(command); var helpCommand = new UserRegisterHelpCommand(); if (HandleNoParameters(helpCommand, forcePrivate: true)) return; if (command.Parameters[0] == "help" || !ValidParameters()) { helpCommand.Process(command); return; } CreateUser(); }
public override void Process(IrcCommand command) { base.Process(command); var message = string.Format( "I need more information, {0}.", command.Source.Name ); if (HandleNoParameters(message, new UserHelpCommand())) return; command.Shift(); var processor = processorFactory.CreateByCommand(command); processor.Process(command); }
public override void Process(IrcCommand command) { base.Process(command); if (HandleNoParameters("usage: pause <task #>")) return; int taskNumber = 0; if (int.TryParse(command.Parameters.FirstOrDefault(), out taskNumber)) { IIrcTask task; if (command.Bot.TryPauseTask(taskNumber, command, out task)) { SendMessage(string.Format("{0} has been paused.", task.Name)); } } }
public override void Process(IrcCommand command) { base.Process(command); var message = string.Format( "I need the name of the load balancer, {0}.", command.Source.Name ); if (HandleNoParameters(message)) { SendMessage("Try: aws elb instances <load balancer name>. If you need a list of load balancers, that command is: aws elb list."); return; } SendMessage("retrieving elb status and ec2 instance urls..."); GetInstanceStates(); GetDescriptions(); PrintUrls(); }
public override void Process(IrcCommand command) { base.Process(command); var message = string.Format( "I need the name of the load balancer, {0}.", command.Source.Name ); if (HandleNoParameters(message)) { SendMessage("Try: aws elb instances <load balancer name>. If you need a list of load balancers, that command is: aws elb list."); return; } var loadBalancerName = command.Parameters[0]; var elb = new ELB(); var ec2 = new EC2(); var instances = elb.Instances(loadBalancerName); var outOfLB = ElbState.GetStates(loadBalancerName).ToDictionary(s => s.State.InstanceId, s => s); var descriptions = ec2.InstanceDescriptions(instances.Select(i => i.InstanceId)); foreach (var description in descriptions) { var timeOutString = outOfLB.ContainsKey(description.InstanceId) ? "Out For: " + outOfLB[description.InstanceId].TimeSincePulled() : "InService"; SendNotice( string.Format( @"id: {0} / ip: {1} / state: {2} / type: {3} / ami: {4} / dns: {5} / Elb State: {6}", description.InstanceId, description.IpAddress, description.InstanceState.Name, description.InstanceType, description.ImageId, description.PublicDnsName, timeOutString ) ); } }
public override void Process(IrcCommand command) { base.Process(command); SendPrivateMessage("usage: login <username> <password>"); }
public override void Process(IrcCommand command) { base.Process(command); SendPrivateMessage("usage: register <username> <password> <email>"); }
/*/// <summary> /// Return wether or not a command may be triggered. /// Is called everytime, a command is triggered /// By default Squishy is set to do nothing until you override this and add an auth system /// </summary> public bool MayTriggerCommand(CmdTrigger<IrcCmdArgs> cmdTrigger) { return MayTriggerCommand(cmdTrigger, cmdTrigger.Command.RootCmd); }*/ /// <summary> /// Return wether or not a command may be triggered. /// Is called everytime, a command is triggered /// By default Squishy is set to do nothing until you override this and add an auth system /// </summary> /// <param name="cmd">A command.</param> public virtual bool MayTriggerCommand(CmdTrigger<IrcCmdArgs> trigger, IrcCommand cmd) { return trigger.Args.User == null || trigger.Args.User == Me; }
internal void UnregisterRawCommand(IrcCommand cmd, IrcMessageHandler callback) { con.UnregisterRawCommand(this, cmd, callback); }
public BotCommand(IrcCommand ircCommand) { this.Parameters = new List<string>(); SetProperties(ircCommand, this); }
public static BotCommand Parse(IrcCommand ircCommand) { BotCommand botCommand = new BotCommand(); SetProperties(ircCommand, botCommand); return botCommand; }
public static void SetProperties(IrcCommand source, BotCommand target) { if (source == null) throw new ArgumentNullException("source"); if (target == null) throw new ArgumentNullException("target"); string[] botCommandParts = source.Parameter.Split(' '); target.Command = botCommandParts[0]; target.IrcCommand = source.Command; target.Nick = source.Nick; foreach (var parameter in botCommandParts.Skip(1)) { target.Parameters.Add(parameter); } target.User = source.User; }
public void addCommand(string command, IrcCommand ircCommand) { this.commandList.Add(command, ircCommand); }