public async Task HandleCommand(IListener listener, IRespondable respondTo, IList <string> args, LinkedMessage e) { if (args.Count < 1) { await respondTo.respond("Missing arguments"); return; } TerminalOptions opts = new TerminalOptions(); try{ opts.Parse(args); if (opts.Parameters.Count != 0) { SshClient = CreateClient(opts); SshClient.ErrorOccurred += (sender, eventArgs) => Logger.Error(eventArgs.Exception, "SSH Error: \n{0}", eventArgs.Exception); SshClient.Connect(); await respondTo.respond("Connected", e.author); } } catch (GetOptException ex) { await respondTo.respond(ex.Message, e.author); Task task = Help(listener, respondTo, args, e); Logger.Warn(ex); await task; } }
public async Task HandleCommand(IListener listener, IRespondable respondTo, IList <string> args, LinkedMessage e) { if (!e.server.isIrc) { await respondTo.respond("This command only works in IRC", e.author); return; } IrcClient client = ((IrcListener)listener).IrcClient; LeaveOptions opts = new LeaveOptions(); try{ opts.Parse(args); if (opts.Parameters.Count != 0) { foreach (string channelToLeave in opts.Parameters) { IrcChannel ircChannel; if ((ircChannel = client.Channels[channelToLeave]) != default) { ircChannel.Part(LeaveMessage); } } return; } ((LinkedIrcChannel)e.channel).channel.Part(LeaveMessage); } catch (GetOptException) { await Help(listener, respondTo, args, e); } }
public async Task HandleCommand(IListener listener, IRespondable respondTo, IList <string> args, LinkedMessage e) { SendOptions opts = new SendOptions(); try{ opts.Parse(args); string msg = opts.Parameters.Count > 0 ? LilGUtil.ArgJoiner(opts.Parameters.ToArray()) : opts.Parameters[0]; if (opts.Raw) { LinkedIrcMessage message = (LinkedIrcMessage)e; message.Client.SendRawMessage(msg); return; } if (opts.channelId != 0) { DiscordChannel channel = await Program.Config.DiscordSocketClient.GetChannelAsync(opts.channelId); await channel.SendMessageAsync(msg); return; } if (opts.channel != null) { LinkedIrcMessage message = (LinkedIrcMessage)e; if (message.Client.Channels.Contains(opts.channel)) { message.Client.SendMessage(msg, opts.channel); } } } catch (GetOptException) { await Help(listener, respondTo, args, e); } }
public async Task HandleCommand(IListener listener, IRespondable respondTo, IList <string> args, LinkedMessage e) { var opts = new ReplOptions(); try{ opts.Parse(args); string code; if (opts.Parameters.Count > 1) { code = LilGUtil.ArgJoiner(opts.Parameters.ToArray()); } else { code = opts.Parameters[0]; } Globals.e = e; Globals.args = args; Globals.listener = listener; Globals.respondTo = respondTo; Globals.server = e.server; Globals.channel = e.channel; Globals.author = e.author; Task <object> task = CSharpScriptEngine.Execute(code, Globals); await respondTo.respond((await task).ToString(), e.author); } catch (GetOptException) { await Help(listener, respondTo, args, e); } }
public async Task HandleCommand(IListener listener, IRespondable respondTo, IList <string> args, LinkedMessage e) { InfoOptions opts = new InfoOptions(); try{ opts.Parse(args); if (Program.CommandList.ContainsCommand(opts.Parameters[0])) { await Program.CommandList[opts.Parameters[0]].Help(listener, respondTo, args, e); } else { await respondTo.respond("That command doesn't exist."); } } catch (GetOptException) { await Help(listener, respondTo, args, e); } }
public async Task HandleCommand(IListener listener, IRespondable respondTo, IList <string> args, LinkedMessage e) { var opts = new ClearMessagesOptions(); try{ opts.Parse(args); if (opts.regex && opts.mask) { throw new InvalidValueException("Regex and Mask formatting cannot both be used"); } } catch (GetOptException ex) { await Help(listener, respondTo, args, e); } }
public async Task HandleCommand(IListener listener, IRespondable respondTo, IList <string> args, LinkedMessage e) { if (!e.server.isIrc) { await respondTo.respond("This command only works in IRC", e.author); return; } IrcClient client = ((IrcListener)listener).IrcClient; JoinOptions opts = new JoinOptions(); try{ opts.Parse(args); foreach (string channelToJoin in opts.Parameters) { client.Channels.Join(channelToJoin); } } catch (GetOptException) { await Help(listener, respondTo, args, e); } }
public async Task HandleCommand(IListener listener, IRespondable respondTo, IList <string> args, LinkedMessage e) { await respondTo.respond("Fore!"); Pause(1); await respondTo.respond("I mean five!"); Pause(1); await respondTo.respond("I mean fire!"); Pause(1); if (e.server.isIrc) { foreach (Configuration.ServerConfiguration serversValue in Program.Config.servers.Values) { serversValue.IrcClient.Quit("🔥🔥🔥"); } Pause(5); } Environment.Exit(0); }
public async Task onMessage(IListener listener, IRespondable respondTo, LinkedMessage e) { if (!e.message.StartsWith(termChar)) { return; } if (!LilGUtil.CheckIfOwner(e)) { return; } bool?connected = SshClient?.IsConnected; if ((connected == null) || (bool)!connected) { await respondTo.respond("Need to connect to a client first"); return; } using (SshCommand command = SshClient.RunCommand(e.message.Substring(1))){ await respondTo.respond(command.Result); } }
public async Task HandleCommand(IListener listener, IRespondable respondTo, IList <string> args, LinkedMessage e) { var opts = new JSOptions(); try{ opts.Parse(args); string code; if (opts.Parameters.Count > 1) { code = ArgJoiner(opts.Parameters.ToArray()); } else { code = opts.Parameters[0]; } bool owner = CheckIfOwner(e); Engine engine; if (owner) { engine = OpEngine; engine.SetValue("listener", listener); engine.SetValue("respondTo", respondTo); engine.SetValue("args", args); engine.SetValue("e", e); const string serverVar = "server"; switch (e.server) { case LinkedIrcServer ircServer: engine.SetValue(serverVar, ircServer.IrcServer); break; case LinkedDiscordServer discordServer: engine.SetValue(serverVar, discordServer.DiscordGuild); break; } const string channelVar = "channel"; switch (e.channel) { case LinkedIrcChannel ircChannel: engine.SetValue(channelVar, ircChannel.channel); break; case LinkedDiscordChannel discordChannel: engine.SetValue(channelVar, discordChannel.channel); break; } const string userVar = "user"; switch (e.author) { case LinkedIrcUser ircUser: engine.SetValue(userVar, ircUser.IrcUser); break; case LinkedDiscordUser discordUser: engine.SetValue(userVar, discordUser.DiscordMember ?? discordUser.DiscordUser); break; } const string selfVar = "self"; const string clientVar = "client"; switch (listener) { case IrcListener ircListener: engine.SetValue(selfVar, ircListener.IrcSelf); engine.SetValue(clientVar, ircListener.IrcClient); break; case DiscordListener discordListener: engine.SetValue(selfVar, discordListener.client.CurrentUser); engine.SetValue(clientVar, discordListener.client); break; } } else { engine = UserEngine; } Logger.Info("Executing JS code as {0}: {1}", owner ? "Owner" : "Normal User", code); await respondTo.respond(engine.Execute(code).GetCompletionValue().ToString(), e.author); } catch (GetOptException) { await Help(listener, respondTo, args, e); } }
public async Task Help(IListener listener, IRespondable respondTo, IList <string> args, LinkedMessage e) { await respondTo.respond(new JSOptions().AssembleUsage(int.MaxValue), e.author); }
public async Task onMessage(IListener listener, IRespondable respondTo, LinkedMessage e) { await AddMessage(e.message); }
public async Task Help(IListener listener, IRespondable respondTo, IList <string> args, LinkedMessage e) { await respondTo.respond(new TerminalOptions().AssembleUsage(byte.MaxValue)); }
public void Message(IRespondable item) { item.Respond(); }
/// <summary> /// 发送微信返回消息 /// </summary> /// <param name="message"></param> public static void RespondMessage(IRespondable respond) { HttpContext.Current.Response.Write(respond.GetRespond()); }
public async Task HandleCommand(IListener listener, IRespondable respondTo, IList <string> args, LinkedMessage e) { int choice = LilGUtil.RandInt(1, 20); string response = ""; switch (choice) { case 1: response = "It is certain"; break; case 2: response = "It is decidedly so"; break; case 3: response = "Without a doubt"; break; case 4: response = "Yes - definitely"; break; case 5: response = "You may rely on it"; break; case 6: response = "As I see it, yes"; break; case 7: response = "Most likely"; break; case 8: response = "Outlook good"; break; case 9: response = "Signs point to yes"; break; case 10: response = "Yes"; break; case 11: response = "Reply hazy, try again"; break; case 12: response = "Ask again later"; break; case 13: response = "Better not tell you now"; break; case 14: response = "Cannot predict now"; break; case 15: response = "Concentrate and ask again"; break; case 16: response = "Don't count on it"; break; case 17: response = "My reply is no"; break; case 18: response = "My sources say no"; break; case 19: response = "Outlook not so good"; break; case 20: response = "Very doubtful"; break; } await respondTo.respond(response, e.author); }
#pragma warning disable 1998 public async Task Help(IListener listener, IRespondable respondTo, IList <string> args, LinkedMessage e) { }
public async Task Help(IListener listener, IRespondable respondTo, IList <string> args, LinkedMessage e) { await respondTo.respond("Would you like an 🥚 in this trying time"); }
public async Task HandleCommand(IListener listener, IRespondable respondTo, IList <string> args, LinkedMessage e) { await respondTo.respond("🥚"); }
public async Task Help(IListener listener, IRespondable respondTo, IList <string> args, LinkedMessage e) { LinkedChannel channel = e.channel; await channel.respond(">_>"); }