async Task <bool> ITempMessage.TempMessage(MiraiHttpSession session, ITempMessageEventArgs e) { if (BotInfo.BannedUser.Contains(e.Sender.Id)) { return(false); } if (BotInfo.DebugMode) { if (BotInfo.DebugReplyAdminOnly) { if (!BotInfo.AdminQQ.Contains(e.Sender.Id)) { return(false); } } } if (e.Chain.Length > 1) //普通消息 { switch (e.Chain[1].Type) { case "Plain": PlainMessageHandler.HandleFriendMesage(session, e.Chain, e.Sender.Id); break; case "Image": for (int i = 1; i < e.Chain.Length; i++) { ImageMessage imgMsg = e.Chain[i] as ImageMessage; await SearchPictureHandler.SearchPicture(imgMsg, picStream => session.UploadPictureAsync(UploadTarget.Group, picStream), msg => session.SendTempMessageAsync(e.Sender.Id, e.Sender.Group.Id, msg)); } break; } } return(false); }
public async Task <bool> TempMessage(MiraiHttpSession session, ITempMessageEventArgs e) { if (e.Chain.Length != 2 || !(e.Chain[1] is PlainMessage)) { return(false); } var cmd = ((PlainMessage)e.Chain[1]).Message.Split(' ').Where(s => s != string.Empty).ToArray(); if (!CalenderBot.Config.CommandStart.Contains(cmd[0])) { return(false); } var helpMsg = new StringBuilder(); using var writer = new StringWriter(helpMsg); var parser = new Parser(config => config.HelpWriter = writer); await parser.ParseArguments <CommandParser.Default, CommandParser.Config, CommandParser.GenerateCalender>(cmd.Skip(1)) .WithParsedAsync <CommandParser.Config>(async with => await ConfigUser.RunTemp(with, session, e)); if (helpMsg.Length != 0) { await session.SendGroupMessageAsync(e.Sender.Group.Id, new IMessageBase[] { new AtMessage(e.Sender.Id), new PlainMessage("\r\n" + helpMsg.ToString()) }); } return(false); }
public async Task HandleMessageAsync(IMiraiHttpSession client, ITempMessageEventArgs e) { MsgReplyTemp r = new MsgReplyTemp() { fromGroup = e.Sender.Group.Id, qq = e.Sender.Id }; ProcessMessage(r, e.Chain); return; }
public async Task <bool> TempMessage(MiraiHttpSession session, ITempMessageEventArgs e) { OnMessage(session, Utils.GetCQMessage(e.Chain), new Source { FromGroup = 0, FromQQ = e.Sender.Id, Session = session, IsTemp = true }); return(false); }
public async Task <bool> TempMessage(MiraiHttpSession session, ITempMessageEventArgs e) { foreach (var item in e.Chain) { if (item.Type.Equals("Plain")) { string message = item.ToString(); GameInput gameInput = new GameInput(session, message, e.Sender, e.Sender.Group); try { await GameSelector.DealCommand(gameInput); } catch (Exception ex) { await gameInput.ReplyGroup("命令错误!" + ex.Message); } } } return(false); }
public Task <bool> TempMessage(MiraiHttpSession session, ITempMessageEventArgs e) { BotCore.OnMessage(new MessageSource(e.Sender.Group.Id, e.Sender.Id, true), new QMessage(e.Chain)); return(Task.FromResult(true)); }
public async Task <bool> TempMessage(MiraiHttpSession session, ITempMessageEventArgs e) { qc.chainReceived(e.Sender, e.Chain, 2); return(false); }
public static async Task RunTemp(CommandParser.Config args, MiraiHttpSession session, ITempMessageEventArgs e) { await session.SendGroupMessageAsync(e.Sender.Group.Id, new AtMessage(e.Sender.Id), new PlainMessage("\r\n正在保存...")); var user = new User(e.Sender.Id) { Username = args.Username, Password = args.Password }; bool ok = await user.TrySave(); await session.SendGroupMessageAsync(e.Sender.Group.Id, new AtMessage(e.Sender.Id), new PlainMessage(ok ? "\r\n成功更改了配置。" : "抱歉,遇到了错误,请稍后再试。")); }