Created
July 9, 2019 17:37
-
-
Save Hidend/99f49c865f818155147bff56eacdc9da to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using FluentFTP; | |
namespace IRCFTPTing | |
{ | |
class FTPClient | |
{ | |
FtpClient client = null; | |
public FtpClient getConnection() | |
{ | |
if (client == null) | |
{ | |
client = new FtpClient("host", 21, "user", "passwd"); | |
} | |
if (!client.IsConnected) | |
{ | |
client.Connect(); | |
} | |
return client; | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using FluentFTP; | |
using Meebey.SmartIrc4net; | |
using System; | |
using System.IO; | |
namespace IRCFTPTing | |
{ | |
class FTPIRCThing | |
{ | |
FTPClient ftp = new FTPClient(); | |
public void Start() | |
{ | |
IrcClient irc = new IrcClient(); | |
irc.OnChannelMessage += new IrcEventHandler(OnChanMsg); | |
try | |
{ | |
irc.Connect("chat.freenode", 6667); | |
} | |
catch (Exception ex) | |
{ | |
Console.WriteLine("1 Unable to connect to IRC server: {0}", ex.Message); | |
} | |
try | |
{ | |
irc.Login("HdndAutoDL", "HdndAutoDL"); | |
irc.RfcJoin("#random"); | |
irc.Listen(); | |
} | |
catch (Exception ex) | |
{ | |
Console.WriteLine("2 Unable to connect to IRC server: {0}", ex.Message); | |
} | |
} | |
private void OnChanMsg(object sender, IrcEventArgs e) | |
{ | |
string releaseName = e.Data.Message; | |
string dst = $"C:\\Users\\Hidend\\Documents\\{releaseName}"; | |
string src = $"/{releaseName}/"; | |
downloadRecursively(ftp.getConnection(), src, dst); | |
} | |
private void downloadRecursively(FtpClient client, string src, string dest) | |
{ | |
int count = 0; | |
foreach (FtpListItem item in client.GetListing(src)) | |
{ | |
count++; | |
Console.WriteLine(item.Name); | |
if (item.Type == FtpFileSystemObjectType.Directory) | |
{ | |
System.IO.Directory.CreateDirectory(Path.Combine(dest, item.Name)); | |
downloadRecursively(client, Path.Combine(src, item.Name), Path.Combine(dest, item.Name)); | |
} | |
else if (item.Type == FtpFileSystemObjectType.File) | |
{ | |
client.DownloadFile(Path.Combine(dest, item.Name), item.FullName); | |
} | |
} | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace IRCFTPTing | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
FTPIRCThing fTPIRCThing = new FTPIRCThing(); | |
fTPIRCThing.Start(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment