Browse Source

Added Stats, Links, Version, Kick, Invite, List, and Names commands

tags/3.0.0
Teknikode 5 years ago
parent
commit
256a4f5853
2 changed files with 151 additions and 4 deletions
  1. 110
    2
      IRC/IRCMethods.cs
  2. 41
    2
      IRC/IRCTypes.cs

+ 110
- 2
IRC/IRCMethods.cs View File

@@ -10,9 +10,13 @@ namespace Combot
internal partial class IRCService
{

// ----------------------- //
// Public Mapped Functions //
// ----------------------- //

// ------------------- //
// Internal Functions //
// ------------------- //
// Internal Functions //
// ------------------ //

/// <summary>
/// Sends a private message to a nick or channel
@@ -237,5 +241,109 @@ namespace Combot
{
SendTCPMessage(string.Format("TOPIC {0} :{1}", channel.Name, topic));
}

/// <summary>
/// Sends a Names command to get a list of visible users
/// </summary>
protected void SendNames()
{
SendTCPMessage("NAMES");
}

protected void SendNames(Channel channel)
{
SendTCPMessage(string.Format("NAMES ", channel.Name));
}

protected void SendNames(List<Channel> channels)
{
string channel_list = string.Empty;
foreach(Channel channel in channels)
{
channel_list += channel.Name + ",";
}
SendTCPMessage(string.Format("NAMES ", channel_list.TrimEnd(',')));
}

/// <summary>
/// Sends a List command to get the topic of channels
/// </summary>
protected void SendList()
{
SendTCPMessage("LIST");
}

protected void SendList(Channel channel)
{
SendTCPMessage(string.Format("LIST ", channel.Name));
}

protected void SendList(List<Channel> channels)
{
string channel_list = string.Empty;
foreach (Channel channel in channels)
{
channel_list += channel.Name + ",";
}
SendTCPMessage(string.Format("LIST ", channel_list.TrimEnd(',')));
}

/// <summary>
/// Sends an Invite command that invites the specified nick to the channel
/// </summary>
/// <param name="channel"></param>
/// <param name="nick"></param>
protected void SendInvite(Channel channel, Nick nick)
{
SendTCPMessage(string.Format("INVITE {0} {1}", nick.Nickname, channel.Name));
}

/// <summary>
/// Sends a Kick command to remove a user from a channel
/// </summary>
/// <param name="channel"></param>
/// <param name="nick"></param>
protected void SendKick(Channel channel, Nick nick)
{
SendTCPMessage(string.Format("KICK {0} {1}", channel.Name, nick.Nickname));
}

protected void SendKick(Channel channel, Nick nick, string reason)
{
SendTCPMessage(string.Format("KICK {0} {1} :{2}", channel.Name, nick.Nickname, reason));
}

/// <summary>
/// Sends a Version command to the server to get a Version reply
/// </summary>
/// <param name="server"></param>
protected void SendVersion(string server)
{
SendTCPMessage(string.Format("VERSION {0}", server));
}

/// <summary>
/// Sends a Stats command to view Server information and statistics
/// </summary>
/// <param name="stat"></param>
protected void SendStats(ServerStat stat)
{
SendTCPMessage(string.Format("STATS {0}", stat.ToString()));
}

protected void SendStats(ServerStat stat, string parameter)
{
SendTCPMessage(string.Format("STATS {0} {1}", stat.ToString(), parameter));
}

protected void SendLinks(string server)
{
SendTCPMessage(string.Format("LINKS {0}", server));
}

protected void SendLinks(List<string> servers)
{

}
}
}

+ 41
- 2
IRC/IRCTypes.cs View File

@@ -5,6 +5,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using System.Net;

namespace Combot
{
@@ -183,6 +184,28 @@ namespace Combot
z
}

public enum ServerStat
{
[Description("List of Servers that allow Server Connection")]
c,
[Description("List of Server Hubs")]
h,
[Description("List of Hosts that allow Client Connection")]
i,
[Description("List of banned user/hostname of Server")]
k,
[Description("Lists Server Connections")]
l,
[Description("Commands Supported")]
m,
[Description("Lists Hosts that allow Normal Operators")]
o,
[Description("List Class lines from Server Config")]
y,
[Description("Server Uptime")]
u
}

public class BotError
{
public ErrorType Type { get; set; }
@@ -194,6 +217,7 @@ namespace Combot
public string Realname { get; set; }
public string Host { get; set; }
public string Nickname { get; set; }
public string Password { get; set; }
public bool Identified { get; set; }
public bool Registered { get; set; }
public List<UserMode> Modes { get; set; }
@@ -203,16 +227,18 @@ namespace Combot
Realname = string.Empty;
Host = string.Empty;
Nickname = string.Empty;
Password = string.Empty;
Identified = false;
Registered = false;
Modes = new List<UserMode>();
}

public Nick(string realname, string host, string nickname, bool identified, bool registered, List<UserMode> modes)
public Nick(string realname, string host, string nickname, string password, bool identified, bool registered, List<UserMode> modes)
{
Realname = realname;
Host = host;
Nickname = nickname;
Password = password;
Identified = identified;
Registered = registered;
Modes = modes;
@@ -250,6 +276,7 @@ namespace Combot
public string Name { get; set; }
public string Topic { get; set; }
public string Key { get; set; }
public bool AutoJoin { get; set; }
public DateTime Registration { get; set; }
public List<ChannelMode> Modes { get; set; }
public List<Nick> Nicks { get; set; }
@@ -259,15 +286,18 @@ namespace Combot
Name = string.Empty;
Topic = string.Empty;
Key = string.Empty;
AutoJoin = false;
Registration = DateTime.Now;
Modes = new List<ChannelMode>();
Nicks = new List<Nick>();
}

public Channel(string name, string topic, DateTime registration, List<ChannelMode> modes, List<Nick> nicks)
public Channel(string name, string topic, string key, bool autojoin, DateTime registration, List<ChannelMode> modes, List<Nick> nicks)
{
Name = name;
Topic = topic;
Key = key;
AutoJoin = autojoin;
Registration = registration;
Modes = modes;
Nicks = nicks;
@@ -326,6 +356,15 @@ namespace Combot
}
}

public class Server
{
public string Name { get; set; }
public List<IPEndPoint> Hosts { get; set; }
public List<Channel> Channels { get; set; }
public bool AutoConnect { get; set; }
public Nick Nick { get; set; }
}

public class Message
{
public MessageType Type { get; set; }

Loading…
Cancel
Save