示例#1
0
        public override BotMessage GetResponse(MessageContext context)
        {
            var fullMessage = context.Message.GetFullMessage();

            if (HasAFileContainingExtention(fullMessage))
            {
                var uriString = fullMessage.File.UrlDownload ?? fullMessage.File.UrlPrivateDownload ?? fullMessage.File.UrlPrivate;
                Log.Information(string.Format("Downloading '{0}'", uriString));
                var resource = new Uri(uriString);
                context.Say("Reading file");
                var downloadData = resource.Download();

                using (var fileStream = File.OpenWrite(FileRunners.GetFileLocation(fullMessage.File.Name)))
                {
                    fileStream.Write(downloadData, 0, downloadData.Length);
                    context.Say("File saved");
                }
                return(new BotMessage()
                {
                    Text = string.Format("Command saved. You can type *{0}* to run the command.", Path.GetFileName(fullMessage.File.Name))
                });
            }
            return(new BotMessage()
            {
                Text = "Unknown file type."
            });
        }
示例#2
0
 private string GetCurrentMachineInformation()
 {
     return(string.Format("{0}({1})\n Script Location:{2}", Environment.MachineName, Network.GetLocalIPAddress(), FileRunners.GetScriptLocation()));
 }