Added command specific info types. Modified all instances of bot commands to use the new class.tags/3.0.1
@@ -357,20 +357,20 @@ namespace Combot | |||
LoggedIn = true; | |||
if (!GhostSent && IRC.Nickname != ServerConfig.Nicknames[CurNickChoice]) | |||
{ | |||
IRC.SendPrivateMessage("NickServ", string.Format("GHOST {0} {1}", ServerConfig.Nicknames[CurNickChoice], ServerConfig.Password)); | |||
IRC.Command.SendPrivateMessage("NickServ", string.Format("GHOST {0} {1}", ServerConfig.Nicknames[CurNickChoice], ServerConfig.Password)); | |||
Thread.Sleep(1000); | |||
IRC.SendNick(ServerConfig.Nicknames[CurNickChoice]); | |||
IRC.Command.SendNick(ServerConfig.Nicknames[CurNickChoice]); | |||
GhostSent = true; | |||
} | |||
// Identify to NickServ if need be | |||
IRC.SendPrivateMessage("NickServ", string.Format("IDENTIFY {0}", ServerConfig.Password)); | |||
IRC.Command.SendPrivateMessage("NickServ", string.Format("IDENTIFY {0}", ServerConfig.Password)); | |||
// Join all required channels | |||
// Delay joining channels for configured time | |||
Thread.Sleep(ServerConfig.JoinDelay); | |||
foreach (ChannelConfig channel in ServerConfig.Channels) | |||
{ | |||
IRC.SendJoin(channel.Name, channel.Key); | |||
IRC.Command.SendJoin(channel.Name, channel.Key); | |||
} | |||
break; | |||
} | |||
@@ -383,7 +383,7 @@ namespace Combot | |||
case IRCErrorCode.ERR_NOTREGISTERED: | |||
if (ServerConfig.AutoRegister && ServerConfig.Password != string.Empty && ServerConfig.Email != string.Empty) | |||
{ | |||
IRC.SendPrivateMessage("NickServ", string.Format("REGISTER {0} {1}", ServerConfig.Password, ServerConfig.Email)); | |||
IRC.Command.SendPrivateMessage("NickServ", string.Format("REGISTER {0} {1}", ServerConfig.Password, ServerConfig.Email)); | |||
} | |||
break; | |||
case IRCErrorCode.ERR_NICKNAMEINUSE: | |||
@@ -484,7 +484,7 @@ namespace Combot | |||
{ | |||
string whoStyle = string.Format(@"[^\s]+\s[^\s]+\s[^\s]+\s[^\s]+\s({0})\s(?<Modes>[^\s]+)\s:[\d]\s(.+)", newCommand.Nick.Nickname); | |||
Regex whoRegex = new Regex(whoStyle); | |||
IRC.SendWho(newCommand.Nick.Nickname); | |||
IRC.Command.SendWho(newCommand.Nick.Nickname); | |||
ServerReplyMessage whoReply = IRC.Message.GetServerReply(IRCReplyCode.RPL_WHOREPLY, whoStyle); | |||
if (whoReply.ReplyCode != 0) | |||
{ |
@@ -86,18 +86,7 @@ namespace Combot.Modules | |||
else | |||
{ | |||
string noAccessMessage = string.Format("You do not have access to use \u0002{0}\u000F.", command.Command); | |||
switch (command.MessageType) | |||
{ | |||
case MessageType.Channel: | |||
Bot.IRC.SendPrivateMessage(command.Location, noAccessMessage); | |||
break; | |||
case MessageType.Query: | |||
Bot.IRC.SendPrivateMessage(command.Nick.Nickname, noAccessMessage); | |||
break; | |||
case MessageType.Notice: | |||
Bot.IRC.SendNotice(command.Nick.Nickname, noAccessMessage); | |||
break; | |||
} | |||
SendResponse(command.MessageType, command.Location, command.Nick.Nickname, noAccessMessage); | |||
} | |||
} | |||
} | |||
@@ -293,13 +282,13 @@ namespace Combot.Modules | |||
switch (messageType) | |||
{ | |||
case MessageType.Channel: | |||
Bot.IRC.SendPrivateMessage(location, message); | |||
Bot.IRC.Command.SendPrivateMessage(location, message); | |||
break; | |||
case MessageType.Query: | |||
Bot.IRC.SendPrivateMessage(nickname, message); | |||
Bot.IRC.Command.SendPrivateMessage(nickname, message); | |||
break; | |||
case MessageType.Notice: | |||
Bot.IRC.SendNotice(nickname, message); | |||
Bot.IRC.Command.SendNotice(nickname, message); | |||
break; | |||
} | |||
} |
@@ -0,0 +1,99 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
namespace Combot.IRCServices.Commanding | |||
{ | |||
abstract public class ICommand : EventArgs | |||
{ | |||
public DateTime TimeStamp { get; set; } | |||
public ICommand() | |||
{ | |||
TimeStamp = DateTime.Now; | |||
} | |||
} | |||
public class PrivateMessageCommand : ICommand | |||
{ | |||
public string Recipient { get; set; } | |||
public string Message { get; set; } | |||
} | |||
public class PrivateNoticeCommand : ICommand | |||
{ | |||
public string Recipient { get; set; } | |||
public string Message { get; set; } | |||
} | |||
public class CTCPMessageCommand : ICommand | |||
{ | |||
public string Recipient { get; set; } | |||
public string Command { get; set; } | |||
public string Arguments { get; set; } | |||
} | |||
public class TopicCommand : ICommand | |||
{ | |||
public string Channel { get; set; } | |||
public string Nick { get; set; } | |||
public string Topic { get; set; } | |||
} | |||
public class ChannelModeCommandInfo : ICommand | |||
{ | |||
public string Channel { get; set; } | |||
public string Nick { get; set; } | |||
public List<ChannelModeInfo> Modes { get; set; } | |||
} | |||
public class UserModeCommandInfo : ICommand | |||
{ | |||
public string Nick { get; set; } | |||
public List<UserModeInfo> Modes { get; set; } | |||
} | |||
public class NickCommandInfo : ICommand | |||
{ | |||
public string OldNick { get; set; } | |||
public string NewNick { get; set; } | |||
} | |||
public class InviteCommandInfo : ICommand | |||
{ | |||
public string Channel { get; set; } | |||
public string Recipient { get; set; } | |||
} | |||
public class JoinCommandInfo : ICommand | |||
{ | |||
public string Channel { get; set; } | |||
} | |||
public class PartCommandInfo : ICommand | |||
{ | |||
public string Channel { get; set; } | |||
} | |||
public class KickCommandInfo : ICommand | |||
{ | |||
public string Channel { get; set; } | |||
public string Nick { get; set; } | |||
public string Reason { get; set; } | |||
} | |||
public class QuitCommandInfo : ICommand | |||
{ | |||
public string Nick { get; set; } | |||
public string Message { get; set; } | |||
} | |||
public class PingCommandInfo : ICommand | |||
{ | |||
public string Message { get; set; } | |||
} | |||
public class PongCommandInfo : ICommand | |||
{ | |||
public string Message { get; set; } | |||
} | |||
} |
@@ -1,15 +1,46 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Net; | |||
using System.Threading; | |||
using Combot.IRCServices.Messaging; | |||
namespace Combot.IRCServices | |||
namespace Combot.IRCServices.Commanding | |||
{ | |||
public partial class IRC | |||
public class Commands | |||
{ | |||
public event EventHandler<string> RawMessageSentEvent; | |||
public event EventHandler<ChannelMessage> MessageSentEvent; | |||
public event EventHandler<PrivateMessage> PrivateMessageSentEvent; | |||
public event EventHandler<ServerNotice> ServerNoticeSentEvent; | |||
public event EventHandler<ChannelNotice> ChannelNoticeSentEvent; | |||
public event EventHandler<PrivateNotice> PrivateNoticeSentEvent; | |||
public event EventHandler<CTCPMessage> CTCPMessageSentEvent; | |||
public event EventHandler<CTCPMessage> CTCPNoticeSentEvent; | |||
public event EventHandler<TopicChangeInfo> TopicSentEvent; | |||
public event EventHandler<ChannelModeChangeInfo> ChannelModeSentEvent; | |||
public event EventHandler<UserModeChangeInfo> UserModeSentEvent; | |||
public event EventHandler<NickChangeInfo> NickSentEvent; | |||
public event EventHandler<InviteChannelInfo> InviteSentEvent; | |||
public event EventHandler<JoinChannelInfo> JoinSentEvent; | |||
public event EventHandler<PartChannelInfo> PartSentEvent; | |||
public event EventHandler<KickInfo> KickSentEvent; | |||
public event EventHandler<QuitInfo> QuitSentEvent; | |||
public event EventHandler<PingInfo> PingSentEvent; | |||
public event EventHandler<PongInfo> PongSentEvent; | |||
private IRC _IRC; | |||
private int MaxMessageLength; | |||
private int MessageSendDelay; | |||
private DateTime LastMessageSend; | |||
public Commands(IRC irc, int maxMessageLength, int messageSendDelay) | |||
{ | |||
_IRC = irc; | |||
LastMessageSend = DateTime.Now; | |||
MaxMessageLength = maxMessageLength; | |||
MessageSendDelay = messageSendDelay; | |||
} | |||
/// <summary> | |||
/// Sends a private message to a nick or channel | |||
/// </summary> | |||
@@ -25,7 +56,7 @@ namespace Combot.IRCServices | |||
LastMessageSend = DateTime.Now; | |||
if (message.Length > MaxMessageLength) | |||
{ | |||
List<string> splitMessage = message.Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries).ToList(); | |||
List<string> splitMessage = message.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList(); | |||
string subMessage = string.Empty; | |||
string nextMessage = string.Empty; | |||
for (int i = 0; i < splitMessage.Count; i++) | |||
@@ -39,12 +70,12 @@ namespace Combot.IRCServices | |||
} | |||
subMessage = string.Join(" ", subMessage, splitMessage[i]); | |||
} | |||
SendTCPMessage(string.Format("PRIVMSG {0} :{1}", recipient, subMessage.Remove(0, 1))); | |||
_IRC.SendTCPMessage(string.Format("PRIVMSG {0} :{1}", recipient, subMessage.Remove(0, 1))); | |||
SendPrivateMessage(recipient, nextMessage); | |||
} | |||
else | |||
{ | |||
SendTCPMessage(string.Format("PRIVMSG {0} :{1}", recipient, message)); | |||
_IRC.SendTCPMessage(string.Format("PRIVMSG {0} :{1}", recipient, message)); | |||
} | |||
} | |||
@@ -68,12 +99,12 @@ namespace Combot.IRCServices | |||
TimeSpan sinceLastMessage = (DateTime.Now - LastMessageSend); | |||
if (sinceLastMessage.TotalMilliseconds < MessageSendDelay) | |||
{ | |||
Thread.Sleep((int) (MessageSendDelay - sinceLastMessage.TotalMilliseconds)); | |||
Thread.Sleep((int)(MessageSendDelay - sinceLastMessage.TotalMilliseconds)); | |||
} | |||
LastMessageSend = DateTime.Now; | |||
if (message.Length > MaxMessageLength) | |||
{ | |||
List<string> splitMessage = message.Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries).ToList(); | |||
List<string> splitMessage = message.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList(); | |||
string subMessage = string.Empty; | |||
string nextMessage = string.Empty; | |||
for (int i = 0; i < splitMessage.Count; i++) | |||
@@ -87,12 +118,12 @@ namespace Combot.IRCServices | |||
} | |||
subMessage = string.Join(" ", subMessage, splitMessage[i]); | |||
} | |||
SendTCPMessage(string.Format("NOTICE {0} :{1}", recipient, subMessage.Remove(0, 1))); | |||
_IRC.SendTCPMessage(string.Format("NOTICE {0} :{1}", recipient, subMessage.Remove(0, 1))); | |||
SendNotice(recipient, nextMessage); | |||
} | |||
else | |||
{ | |||
SendTCPMessage(string.Format("NOTICE {0} :{1}", recipient, message)); | |||
_IRC.SendTCPMessage(string.Format("NOTICE {0} :{1}", recipient, message)); | |||
} | |||
} | |||
@@ -119,7 +150,7 @@ namespace Combot.IRCServices | |||
{ | |||
message = " " + message; | |||
} | |||
SendTCPMessage(string.Format("PRIVMSG {0} :\u0001{1}{2}\u0001", recipient, command, message)); | |||
_IRC.SendTCPMessage(string.Format("PRIVMSG {0} :\u0001{1}{2}\u0001", recipient, command, message)); | |||
} | |||
public void SendCTCPMessage(List<string> recipients, string command, string message) | |||
@@ -148,7 +179,7 @@ namespace Combot.IRCServices | |||
{ | |||
message = " " + message; | |||
} | |||
SendTCPMessage(string.Format("NOTICE {0} :\u0001{1}{2}\u0001", recipient, command, message)); | |||
_IRC.SendTCPMessage(string.Format("NOTICE {0} :\u0001{1}{2}\u0001", recipient, command, message)); | |||
} | |||
public void SendCTCPNotice(List<string> recipients, string command, string message) | |||
@@ -171,7 +202,7 @@ namespace Combot.IRCServices | |||
/// <param name="password"></param> | |||
public void SendPassword(string password) | |||
{ | |||
SendTCPMessage(string.Format("PASSWORD {0}", password)); | |||
_IRC.SendTCPMessage(string.Format("PASSWORD {0}", password)); | |||
} | |||
/// <summary> | |||
@@ -180,7 +211,7 @@ namespace Combot.IRCServices | |||
/// <param name="nick"></param> | |||
public void SendNick(string nick) | |||
{ | |||
SendTCPMessage(string.Format("NICK {0}", nick)); | |||
_IRC.SendTCPMessage(string.Format("NICK {0}", nick)); | |||
} | |||
/// <summary> | |||
@@ -189,7 +220,7 @@ namespace Combot.IRCServices | |||
/// <param name="user"></param> | |||
public void SendUser(string username, string hostname, string servername, string realname) | |||
{ | |||
SendTCPMessage(string.Format("USER {0} {1} {2} :{3}", username, hostname, servername, realname)); | |||
_IRC.SendTCPMessage(string.Format("USER {0} {1} {2} :{3}", username, hostname, servername, realname)); | |||
} | |||
/// <summary> | |||
@@ -199,7 +230,7 @@ namespace Combot.IRCServices | |||
/// <param name="password"></param> | |||
public void SendOper(string username, string password) | |||
{ | |||
SendTCPMessage(string.Format("OPER {0} {1}", username, password)); | |||
_IRC.SendTCPMessage(string.Format("OPER {0} {1}", username, password)); | |||
} | |||
/// <summary> | |||
@@ -208,12 +239,12 @@ namespace Combot.IRCServices | |||
/// <param name="message"></param> | |||
public void SendQuit() | |||
{ | |||
SendTCPMessage("QUIT"); | |||
_IRC.SendTCPMessage("QUIT"); | |||
} | |||
public void SendQuit(string message) | |||
{ | |||
SendTCPMessage(string.Format("QUIT :{0}", message)); | |||
_IRC.SendTCPMessage(string.Format("QUIT :{0}", message)); | |||
} | |||
/// <summary> | |||
@@ -224,7 +255,7 @@ namespace Combot.IRCServices | |||
{ | |||
string message = string.Empty; | |||
message = (key != string.Empty) ? string.Format("{0} {1}", channel, key) : channel; | |||
SendTCPMessage(string.Format("JOIN {0}", message)); | |||
_IRC.SendTCPMessage(string.Format("JOIN {0}", message)); | |||
} | |||
public void SendJoin(List<string> channels, List<string> keys) | |||
@@ -234,7 +265,7 @@ namespace Combot.IRCServices | |||
string key_string = string.Empty; | |||
foreach (string channel in channels) | |||
{ | |||
{ | |||
channel_string += channel + ","; | |||
} | |||
foreach (string key in keys) | |||
@@ -248,7 +279,7 @@ namespace Combot.IRCServices | |||
key_string = key_string.TrimEnd(','); | |||
message = (key_string != string.Empty) ? string.Format("{0} {1}", channel_string, key_string) : channel_string; | |||
SendTCPMessage(string.Format("JOIN {0}", message)); | |||
_IRC.SendTCPMessage(string.Format("JOIN {0}", message)); | |||
} | |||
/// <summary> | |||
@@ -257,7 +288,7 @@ namespace Combot.IRCServices | |||
/// <param name="channel"></param> | |||
public void SendPart(string channel) | |||
{ | |||
SendTCPMessage(string.Format("PART {0}", channel)); | |||
_IRC.SendTCPMessage(string.Format("PART {0}", channel)); | |||
} | |||
public void SendPart(List<string> channels) | |||
@@ -280,7 +311,7 @@ namespace Combot.IRCServices | |||
public void SendMode(string channel, ChannelModeInfo modeInfo) | |||
{ | |||
string mode_set = modeInfo.Set ? "+" : "-"; | |||
SendTCPMessage(string.Format("MODE {0} {1} {2}", channel, mode_set + modeInfo.Mode.ToString(), modeInfo.Parameter)); | |||
_IRC.SendTCPMessage(string.Format("MODE {0} {1} {2}", channel, mode_set + modeInfo.Mode.ToString(), modeInfo.Parameter)); | |||
} | |||
public void SendMode(string channel, List<ChannelModeInfo> modeInfos) | |||
@@ -294,7 +325,7 @@ namespace Combot.IRCServices | |||
public void SendMode(string nick, UserModeInfo modeInfo) | |||
{ | |||
string mode_set = modeInfo.Set ? "+" : "-"; | |||
SendTCPMessage(string.Format("MODE {0} {1}", nick, mode_set + modeInfo.Mode.ToString())); | |||
_IRC.SendTCPMessage(string.Format("MODE {0} {1}", nick, mode_set + modeInfo.Mode.ToString())); | |||
} | |||
public void SendMode(string nick, List<UserModeInfo> modeInfos) | |||
@@ -311,12 +342,12 @@ namespace Combot.IRCServices | |||
/// <param name="channel"></param> | |||
public void SendTopic(string channel) | |||
{ | |||
SendTCPMessage(string.Format("TOPIC {0}", channel)); | |||
_IRC.SendTCPMessage(string.Format("TOPIC {0}", channel)); | |||
} | |||
public void SendTopic(string channel, string topic) | |||
{ | |||
SendTCPMessage(string.Format("TOPIC {0} :{1}", channel, topic)); | |||
_IRC.SendTCPMessage(string.Format("TOPIC {0} :{1}", channel, topic)); | |||
} | |||
/// <summary> | |||
@@ -324,12 +355,12 @@ namespace Combot.IRCServices | |||
/// </summary> | |||
public void SendNames() | |||
{ | |||
SendTCPMessage("NAMES"); | |||
_IRC.SendTCPMessage("NAMES"); | |||
} | |||
public void SendNames(string channel) | |||
{ | |||
SendTCPMessage(string.Format("NAMES {0}", channel)); | |||
_IRC.SendTCPMessage(string.Format("NAMES {0}", channel)); | |||
} | |||
public void SendNames(List<string> channels) | |||
@@ -347,12 +378,12 @@ namespace Combot.IRCServices | |||
/// </summary> | |||
public void SendList() | |||
{ | |||
SendTCPMessage("LIST"); | |||
_IRC.SendTCPMessage("LIST"); | |||
} | |||
public void SendList(string channel) | |||
{ | |||
SendTCPMessage(string.Format("LIST {0}", channel)); | |||
_IRC.SendTCPMessage(string.Format("LIST {0}", channel)); | |||
} | |||
public void SendList(List<string> channels) | |||
@@ -372,7 +403,7 @@ namespace Combot.IRCServices | |||
/// <param name="nick"></param> | |||
public void SendInvite(string channel, string nick) | |||
{ | |||
SendTCPMessage(string.Format("INVITE {0} {1}", nick, channel)); | |||
_IRC.SendTCPMessage(string.Format("INVITE {0} {1}", nick, channel)); | |||
} | |||
/// <summary> | |||
@@ -382,12 +413,12 @@ namespace Combot.IRCServices | |||
/// <param name="nick"></param> | |||
public void SendKick(string channel, string nick) | |||
{ | |||
SendTCPMessage(string.Format("KICK {0} {1}", channel, nick)); | |||
_IRC.SendTCPMessage(string.Format("KICK {0} {1}", channel, nick)); | |||
} | |||
public void SendKick(string channel, string nick, string reason) | |||
{ | |||
SendTCPMessage(string.Format("KICK {0} {1} :{2}", channel, nick, reason)); | |||
_IRC.SendTCPMessage(string.Format("KICK {0} {1} :{2}", channel, nick, reason)); | |||
} | |||
/// <summary> | |||
@@ -396,7 +427,7 @@ namespace Combot.IRCServices | |||
/// <param name="server"></param> | |||
public void SendVersion(string server) | |||
{ | |||
SendTCPMessage(string.Format("VERSION {0}", server)); | |||
_IRC.SendTCPMessage(string.Format("VERSION {0}", server)); | |||
} | |||
/// <summary> | |||
@@ -405,12 +436,12 @@ namespace Combot.IRCServices | |||
/// <param name="stat"></param> | |||
public void SendStats(ServerStat stat) | |||
{ | |||
SendTCPMessage(string.Format("STATS {0}", stat.ToString())); | |||
_IRC.SendTCPMessage(string.Format("STATS {0}", stat.ToString())); | |||
} | |||
public void SendStats(ServerStat stat, string parameter) | |||
{ | |||
SendTCPMessage(string.Format("STATS {0} {1}", stat.ToString(), parameter)); | |||
_IRC.SendTCPMessage(string.Format("STATS {0} {1}", stat.ToString(), parameter)); | |||
} | |||
/// <summary> | |||
@@ -419,12 +450,12 @@ namespace Combot.IRCServices | |||
/// <param name="mask"></param> | |||
public void SendLinks(string mask) | |||
{ | |||
SendTCPMessage(string.Format("LINKS {0}", mask)); | |||
_IRC.SendTCPMessage(string.Format("LINKS {0}", mask)); | |||
} | |||
public void SendLinks(string server, string mask) | |||
{ | |||
SendTCPMessage(string.Format("LINKS {0} {1}", mask, server)); | |||
_IRC.SendTCPMessage(string.Format("LINKS {0} {1}", mask, server)); | |||
} | |||
/// <summary> | |||
@@ -432,12 +463,12 @@ namespace Combot.IRCServices | |||
/// </summary> | |||
public void SendTime() | |||
{ | |||
SendTCPMessage("TIME"); | |||
_IRC.SendTCPMessage("TIME"); | |||
} | |||
public void SendTime(string server) | |||
{ | |||
SendTCPMessage(string.Format("TIME {0}", server)); | |||
_IRC.SendTCPMessage(string.Format("TIME {0}", server)); | |||
} | |||
/// <summary> | |||
@@ -446,12 +477,12 @@ namespace Combot.IRCServices | |||
/// <param name="server"></param> | |||
public void SendConnect(string server) | |||
{ | |||
SendTCPMessage(string.Format("CONNECT {0}", server)); | |||
_IRC.SendTCPMessage(string.Format("CONNECT {0}", server)); | |||
} | |||
public void SendConnect(string server, string originator, int port) | |||
{ | |||
SendTCPMessage(string.Format("CONNECT {0} {1} {2}", originator, port, server)); | |||
_IRC.SendTCPMessage(string.Format("CONNECT {0} {1} {2}", originator, port, server)); | |||
} | |||
/// <summary> | |||
@@ -460,7 +491,7 @@ namespace Combot.IRCServices | |||
/// <param name="target"></param> | |||
public void SendTrace(string target) | |||
{ | |||
SendTCPMessage(string.Format("TRACE {0}", target)); | |||
_IRC.SendTCPMessage(string.Format("TRACE {0}", target)); | |||
} | |||
/// <summary> | |||
@@ -468,12 +499,12 @@ namespace Combot.IRCServices | |||
/// </summary> | |||
public void SendAdmin() | |||
{ | |||
SendTCPMessage("ADMIN"); | |||
_IRC.SendTCPMessage("ADMIN"); | |||
} | |||
public void SendAdmin(string host) | |||
{ | |||
SendTCPMessage(string.Format("ADMIN {0}", host)); | |||
_IRC.SendTCPMessage(string.Format("ADMIN {0}", host)); | |||
} | |||
/// <summary> | |||
@@ -482,7 +513,7 @@ namespace Combot.IRCServices | |||
/// <param name="host"></param> | |||
public void SendInfo(string host) | |||
{ | |||
SendTCPMessage(string.Format("INFO {0}", host)); | |||
_IRC.SendTCPMessage(string.Format("INFO {0}", host)); | |||
} | |||
/// <summary> | |||
@@ -490,7 +521,7 @@ namespace Combot.IRCServices | |||
/// </summary> | |||
public void SendWho() | |||
{ | |||
SendTCPMessage("WHO"); | |||
_IRC.SendTCPMessage("WHO"); | |||
} | |||
public void SendWho(string host, bool ops = false) | |||
@@ -504,7 +535,7 @@ namespace Combot.IRCServices | |||
{ | |||
msg = string.Format("WHO {0}", host); | |||
} | |||
SendTCPMessage(msg); | |||
_IRC.SendTCPMessage(msg); | |||
} | |||
/// <summary> | |||
@@ -513,12 +544,12 @@ namespace Combot.IRCServices | |||
/// <param name="nick"></param> | |||
public void SendWhois(string nick) | |||
{ | |||
SendTCPMessage(string.Format("WHOIS {0}", nick)); | |||
_IRC.SendTCPMessage(string.Format("WHOIS {0}", nick)); | |||
} | |||
public void SendWhois(string nick, string server) | |||
{ | |||
SendTCPMessage(string.Format("WHOIS {0} {1}", server, nick)); | |||
_IRC.SendTCPMessage(string.Format("WHOIS {0} {1}", server, nick)); | |||
} | |||
/// <summary> | |||
@@ -527,17 +558,17 @@ namespace Combot.IRCServices | |||
/// <param name="nick"></param> | |||
public void SendWhowas(string nick) | |||
{ | |||
SendTCPMessage(string.Format("WHOIS {0}", nick)); | |||
_IRC.SendTCPMessage(string.Format("WHOIS {0}", nick)); | |||
} | |||
public void SendWhowas(string nick, int entries) | |||
{ | |||
SendTCPMessage(string.Format("WHOIS {0} {1}", nick, entries)); | |||
_IRC.SendTCPMessage(string.Format("WHOIS {0} {1}", nick, entries)); | |||
} | |||
public void SendWhowas(string nick, int entries, string server) | |||
{ | |||
SendTCPMessage(string.Format("WHOIS {0} {1} {2}", nick, entries, server)); | |||
_IRC.SendTCPMessage(string.Format("WHOIS {0} {1} {2}", nick, entries, server)); | |||
} | |||
/// <summary> | |||
@@ -547,7 +578,7 @@ namespace Combot.IRCServices | |||
/// <param name="comment"></param> | |||
public void SendKill(string nick, string comment) | |||
{ | |||
SendTCPMessage(string.Format("KILL {0} {1}", nick, comment)); | |||
_IRC.SendTCPMessage(string.Format("KILL {0} {1}", nick, comment)); | |||
} | |||
/// <summary> | |||
@@ -556,7 +587,7 @@ namespace Combot.IRCServices | |||
/// <param name="recipient"></param> | |||
public void SendPing(string recipient) | |||
{ | |||
SendTCPMessage(string.Format("PING {0}", recipient)); | |||
_IRC.SendTCPMessage(string.Format("PING {0}", recipient)); | |||
} | |||
/// <summary> | |||
@@ -566,26 +597,25 @@ namespace Combot.IRCServices | |||
/// <param name="recipient"></param> | |||
public void SendPong() | |||
{ | |||
SendTCPMessage("PONG"); | |||
_IRC.SendTCPMessage("PONG"); | |||
} | |||
public void SendPong(string message) | |||
{ | |||
SendTCPMessage(string.Format("PONG {0}", message)); | |||
_IRC.SendTCPMessage(string.Format("PONG {0}", message)); | |||
} | |||
public void SendPong(string sender, string recipient) | |||
{ | |||
SendTCPMessage(string.Format("PONG {0} {1}", sender, recipient)); | |||
_IRC.SendTCPMessage(string.Format("PONG {0} {1}", sender, recipient)); | |||
} | |||
/// <summary> | |||
/// Sends an Away command to unset away status | |||
/// </summary> | |||
public void SendAway() | |||
{ | |||
SendTCPMessage("AWAY"); | |||
_IRC.SendTCPMessage("AWAY"); | |||
} | |||
/// <summary> | |||
@@ -594,7 +624,7 @@ namespace Combot.IRCServices | |||
/// <param name="message"></param> | |||
public void SendAway(string message) | |||
{ | |||
SendTCPMessage(string.Format("AWAY {0}", message)); | |||
_IRC.SendTCPMessage(string.Format("AWAY {0}", message)); | |||
} | |||
/// <summary> | |||
@@ -602,7 +632,7 @@ namespace Combot.IRCServices | |||
/// </summary> | |||
public void SendRehash() | |||
{ | |||
SendTCPMessage("REHASH"); | |||
_IRC.SendTCPMessage("REHASH"); | |||
} | |||
/// <summary> | |||
@@ -610,7 +640,7 @@ namespace Combot.IRCServices | |||
/// </summary> | |||
public void SendRestart() | |||
{ | |||
SendTCPMessage("RESTART"); | |||
_IRC.SendTCPMessage("RESTART"); | |||
} | |||
/// <summary> | |||
@@ -619,17 +649,17 @@ namespace Combot.IRCServices | |||
/// <param name="nick"></param> | |||
public void SendSummon() | |||
{ | |||
SendTCPMessage("SUMMON"); | |||
_IRC.SendTCPMessage("SUMMON"); | |||
} | |||
public void SendSummon(string nick) | |||
{ | |||
SendTCPMessage(string.Format("SUMMON {0}", nick)); | |||
_IRC.SendTCPMessage(string.Format("SUMMON {0}", nick)); | |||
} | |||
public void SendSummon(string nick, string host) | |||
{ | |||
SendTCPMessage(string.Format("SUMMON {0} {1}", nick, host)); | |||
_IRC.SendTCPMessage(string.Format("SUMMON {0} {1}", nick, host)); | |||
} | |||
/// <summary> | |||
@@ -638,7 +668,7 @@ namespace Combot.IRCServices | |||
/// <param name="server"></param> | |||
public void SendUsers(string server) | |||
{ | |||
SendTCPMessage(string.Format("USERS {0}", server)); | |||
_IRC.SendTCPMessage(string.Format("USERS {0}", server)); | |||
} | |||
/// <summary> | |||
@@ -647,7 +677,7 @@ namespace Combot.IRCServices | |||
/// <param name="message"></param> | |||
public void SendWallops(string message) | |||
{ | |||
SendTCPMessage(string.Format("WALLOPS :{0}", message)); | |||
_IRC.SendTCPMessage(string.Format("WALLOPS :{0}", message)); | |||
} | |||
/// <summary> | |||
@@ -661,7 +691,7 @@ namespace Combot.IRCServices | |||
{ | |||
message += " " + nick; | |||
} | |||
SendTCPMessage(string.Format("USERHOST {0}", message.Trim())); | |||
_IRC.SendTCPMessage(string.Format("USERHOST {0}", message.Trim())); | |||
} | |||
/// <summary> | |||
@@ -675,7 +705,7 @@ namespace Combot.IRCServices | |||
{ | |||
message += " " + nick; | |||
} | |||
SendTCPMessage(string.Format("ISON {0}", message.Trim())); | |||
_IRC.SendTCPMessage(string.Format("ISON {0}", message.Trim())); | |||
} | |||
} | |||
} | |||
} |
@@ -9,6 +9,7 @@ using System.Net; | |||
using System.Net.NetworkInformation; | |||
using System.Net.Sockets; | |||
using Combot.IRCServices.Messaging; | |||
using Combot.IRCServices.Commanding; | |||
using Combot.IRCServices.TCP; | |||
namespace Combot.IRCServices | |||
@@ -17,15 +18,13 @@ namespace Combot.IRCServices | |||
{ | |||
public List<Channel> Channels = new List<Channel>(); | |||
public Messages Message; | |||
public Commands Command; | |||
public event Action ConnectEvent; | |||
public event Action DisconnectEvent; | |||
public event Action<TCPError> TCPErrorEvent; | |||
public string Nickname; | |||
public Dictionary<string, PrivilegeMode> PrivilegeMapping = new Dictionary<string, PrivilegeMode>() { { "+", PrivilegeMode.v }, { "%", PrivilegeMode.h }, { "@", PrivilegeMode.o }, { "&", PrivilegeMode.a }, { "~", PrivilegeMode.q } }; | |||
private int MaxMessageLength; | |||
private int MessageSendDelay; | |||
private DateTime LastMessageSend; | |||
private int ReadTimeout; | |||
private int AllowedFailedReads; | |||
private Thread TCPReader; | |||
@@ -38,11 +37,9 @@ namespace Combot.IRCServices | |||
{ | |||
_TCP = new TCPInterface(); | |||
Message = new Messages(this); | |||
Command = new Commands(this, maxMessageLength, messageSendDelay); | |||
Nickname = string.Empty; | |||
ChannelRWLock = new ReaderWriterLockSlim(); | |||
LastMessageSend = DateTime.Now; | |||
MaxMessageLength = maxMessageLength; | |||
MessageSendDelay = messageSendDelay; | |||
ReadTimeout = readTimeout; | |||
AllowedFailedReads = allowedFailedReads; | |||
@@ -134,8 +131,8 @@ namespace Combot.IRCServices | |||
public void Login(string serverName, Nick nick) | |||
{ | |||
Nickname = nick.Nickname; | |||
SendNick(nick.Nickname); | |||
SendUser(nick.Username, nick.Host, serverName, nick.Realname); | |||
Command.SendNick(nick.Nickname); | |||
Command.SendUser(nick.Username, nick.Host, serverName, nick.Realname); | |||
} | |||
/// <summary> | |||
@@ -264,7 +261,7 @@ namespace Combot.IRCServices | |||
return null; | |||
} | |||
private void SendTCPMessage(string message) | |||
internal void SendTCPMessage(string message) | |||
{ | |||
if (_TCP.Connected) | |||
{ | |||
@@ -323,7 +320,7 @@ namespace Combot.IRCServices | |||
/// <param name="e"></param> | |||
private void HandlePing(object sender, PingInfo e) | |||
{ | |||
SendPong(e.Message); | |||
Command.SendPong(e.Message); | |||
} | |||
private void HandleTCPConnection(int e) | |||
@@ -506,7 +503,7 @@ namespace Combot.IRCServices | |||
break; | |||
} | |||
} | |||
SendWho(channel.Name); | |||
Command.SendWho(channel.Name); | |||
} | |||
ChannelRWLock.ExitWriteLock(); | |||
} | |||
@@ -582,7 +579,7 @@ namespace Combot.IRCServices | |||
newChannel.Name = e.Channel; | |||
newChannel.Nicks.Add(e.Nick); | |||
Channels.Add(newChannel); | |||
SendWho(newChannel.Name); | |||
Command.SendWho(newChannel.Name); | |||
} | |||
ChannelRWLock.ExitWriteLock(); | |||
} |
@@ -12,6 +12,7 @@ | |||
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion> | |||
<FileAlignment>512</FileAlignment> | |||
<IsWebBootstrapper>false</IsWebBootstrapper> | |||
<NuGetPackageImportStamp>6839a7db</NuGetPackageImportStamp> | |||
<PublishUrl>publish\</PublishUrl> | |||
<Install>true</Install> | |||
<InstallFrom>Disk</InstallFrom> | |||
@@ -26,7 +27,6 @@ | |||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion> | |||
<UseApplicationTrust>false</UseApplicationTrust> | |||
<BootstrapperEnabled>true</BootstrapperEnabled> | |||
<NuGetPackageImportStamp>6839a7db</NuGetPackageImportStamp> | |||
</PropertyGroup> | |||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | |||
<DebugSymbols>true</DebugSymbols> | |||
@@ -56,12 +56,13 @@ | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Compile Include="Channel.cs" /> | |||
<Compile Include="Commanding\Commands.cs" /> | |||
<Compile Include="Commanding\CommandTypes.cs" /> | |||
<Compile Include="IRC.cs" /> | |||
<Compile Include="Messaging\GetError.cs" /> | |||
<Compile Include="Messaging\GetReply.cs" /> | |||
<Compile Include="Messaging\Messages.cs" /> | |||
<Compile Include="Messaging\MessageTypes.cs" /> | |||
<Compile Include="SendCommand.cs" /> | |||
<Compile Include="Nick.cs" /> | |||
<Compile Include="Properties\AssemblyInfo.cs" /> | |||
<Compile Include="TCP\TCPInterface.cs" /> |
@@ -17,8 +17,8 @@ namespace Combot.IRCServices.Messaging | |||
public event EventHandler<ServerNotice> ServerNoticeReceivedEvent; | |||
public event EventHandler<ChannelNotice> ChannelNoticeReceivedEvent; | |||
public event EventHandler<PrivateNotice> PrivateNoticeReceivedEvent; | |||
public event EventHandler<CTCPMessage> CTCPMessageRecievedEvent; | |||
public event EventHandler<CTCPMessage> CTCPNoticeRecievedEvent; | |||
public event EventHandler<CTCPMessage> CTCPMessageReceivedEvent; | |||
public event EventHandler<CTCPMessage> CTCPNoticeReceivedEvent; | |||
public event EventHandler<TopicChangeInfo> TopicChangeEvent; | |||
public event EventHandler<ChannelModeChangeInfo> ChannelModeChangeEvent; | |||
public event EventHandler<UserModeChangeInfo> UserModeChangeEvent; | |||
@@ -132,9 +132,9 @@ namespace Combot.IRCServices.Messaging | |||
await Task.Run(() => | |||
{ | |||
if (CTCPMessageRecievedEvent != null) | |||
if (CTCPMessageReceivedEvent != null) | |||
{ | |||
CTCPMessageRecievedEvent(this, ctcpMessage); | |||
CTCPMessageReceivedEvent(this, ctcpMessage); | |||
} | |||
}); | |||
} | |||
@@ -198,9 +198,9 @@ namespace Combot.IRCServices.Messaging | |||
await Task.Run(() => | |||
{ | |||
if (CTCPNoticeRecievedEvent != null) | |||
if (CTCPNoticeReceivedEvent != null) | |||
{ | |||
CTCPNoticeRecievedEvent(this, ctcpMessage); | |||
CTCPNoticeReceivedEvent(this, ctcpMessage); | |||
} | |||
}); | |||
} |
@@ -306,7 +306,7 @@ namespace Interface.ViewModels | |||
{ | |||
if (botInstance.IRC.Channels.Exists(chan => chan.Name == SelectedLocation)) | |||
{ | |||
botInstance.IRC.SendPrivateMessage(SelectedLocation, message); | |||
botInstance.IRC.Command.SendPrivateMessage(SelectedLocation, message); | |||
} | |||
else | |||
{ | |||
@@ -315,7 +315,7 @@ namespace Interface.ViewModels | |||
} | |||
else | |||
{ | |||
botInstance.IRC.SendPrivateMessage(SelectedLocation, message); | |||
botInstance.IRC.Command.SendPrivateMessage(SelectedLocation, message); | |||
} | |||
} | |||
} | |||
@@ -343,7 +343,7 @@ namespace Interface.ViewModels | |||
Bot botInstance = CombotSessions.Find(bot => bot.ServerConfig.Name == SelectedServer); | |||
if (botInstance.IRC.Channels.Exists(chan => chan.Name == location)) | |||
{ | |||
botInstance.IRC.SendPart(location); | |||
botInstance.IRC.Command.SendPart(location); | |||
} | |||
} | |||
if (LocationList.Contains(location)) |
@@ -21,25 +21,25 @@ namespace Combot.Modules.Plugins | |||
switch (randNum) | |||
{ | |||
case 0: | |||
Bot.IRC.SendCTCPMessage(channel, "ACTION", string.Format("gently makes love to {0}", command.Arguments["Nickname"])); | |||
Bot.IRC.Command.SendCTCPMessage(channel, "ACTION", string.Format("gently makes love to {0}", command.Arguments["Nickname"])); | |||
break; | |||
case 1: | |||
Bot.IRC.SendCTCPMessage(channel, "ACTION", string.Format("sings a love ballad to {0}", command.Arguments["Nickname"])); | |||
Bot.IRC.Command.SendCTCPMessage(channel, "ACTION", string.Format("sings a love ballad to {0}", command.Arguments["Nickname"])); | |||
break; | |||
case 2: | |||
Bot.IRC.SendCTCPMessage(channel, "ACTION", string.Format("slowly sneaks up behind {0}", command.Arguments["Nickname"])); | |||
Bot.IRC.SendCTCPMessage(channel, "ACTION", string.Format("squeezes {0} tightly", command.Arguments["Nickname"])); | |||
Bot.IRC.Command.SendCTCPMessage(channel, "ACTION", string.Format("slowly sneaks up behind {0}", command.Arguments["Nickname"])); | |||
Bot.IRC.Command.SendCTCPMessage(channel, "ACTION", string.Format("squeezes {0} tightly", command.Arguments["Nickname"])); | |||
break; | |||
case 3: | |||
Bot.IRC.SendPrivateMessage(channel, string.Format("I love you {0}! Sooo much!", command.Arguments["Nickname"])); | |||
Bot.IRC.Command.SendPrivateMessage(channel, string.Format("I love you {0}! Sooo much!", command.Arguments["Nickname"])); | |||
break; | |||
} | |||
break; | |||
case "Hug": | |||
Bot.IRC.SendCTCPMessage(channel, "ACTION", string.Format("hugs {0}", command.Arguments["Nickname"])); | |||
Bot.IRC.Command.SendCTCPMessage(channel, "ACTION", string.Format("hugs {0}", command.Arguments["Nickname"])); | |||
break; | |||
case "Slap": | |||
Bot.IRC.SendCTCPMessage(channel, "ACTION", string.Format("slaps {0} with a large trout", command.Arguments["Nickname"])); | |||
Bot.IRC.Command.SendCTCPMessage(channel, "ACTION", string.Format("slaps {0} with a large trout", command.Arguments["Nickname"])); | |||
break; | |||
case "Brazilian Laugh": | |||
SendResponse(command.MessageType, command.Location, command.Nick.Nickname, "HUEHUEHUE"); |
@@ -30,10 +30,10 @@ namespace Combot.Modules.Plugins | |||
private void SendFullHelp(string recipient, List<AccessType> access) | |||
{ | |||
Bot.IRC.SendNotice(recipient, string.Format("You have the following commands available to use. " + | |||
Bot.IRC.Command.SendNotice(recipient, string.Format("You have the following commands available to use. " + | |||
"To use them either type \u0002{1}\u001Fcommand trigger\u001F\u0002 into a channel, send a private message by typing \u0002/msg {0} \u001Fcommand trigger\u001F\u0002, or send a notice by typing \u0002/notice {0} \u001Fcommand trigger\u001F\u0002.", | |||
Bot.IRC.Nickname, Bot.ServerConfig.CommandPrefix)); | |||
Bot.IRC.SendNotice(recipient, "\u200B"); | |||
Bot.IRC.Command.SendNotice(recipient, "\u200B"); | |||
List<string> commandList = new List<string>(); | |||
foreach (Module module in Bot.Modules) | |||
{ | |||
@@ -45,9 +45,9 @@ namespace Combot.Modules.Plugins | |||
} | |||
}); | |||
} | |||
Bot.IRC.SendNotice(recipient, string.Format("\u0002{0}\u0002", string.Join("\u0002, \u0002", commandList))); | |||
Bot.IRC.SendNotice(recipient, "\u200B"); | |||
Bot.IRC.SendNotice(recipient, string.Format("For more information on a specific command, including viewing the triggers, type \u0002{0}help \u001Fcommand\u001F\u0002.", Bot.ServerConfig.CommandPrefix)); | |||
Bot.IRC.Command.SendNotice(recipient, string.Format("\u0002{0}\u0002", string.Join("\u0002, \u0002", commandList))); | |||
Bot.IRC.Command.SendNotice(recipient, "\u200B"); | |||
Bot.IRC.Command.SendNotice(recipient, string.Format("For more information on a specific command, including viewing the triggers, type \u0002{0}help \u001Fcommand\u001F\u0002.", Bot.ServerConfig.CommandPrefix)); | |||
} | |||
private void SendCommandHelp(CommandMessage command) | |||
@@ -61,12 +61,12 @@ namespace Combot.Modules.Plugins | |||
{ | |||
if (foundCommand.AllowedAccess.Exists(allowed => command.Access.Contains(allowed))) | |||
{ | |||
Bot.IRC.SendNotice(command.Nick.Nickname, string.Format("Help information for \u0002{0}\u0002", foundCommand.Name)); | |||
Bot.IRC.Command.SendNotice(command.Nick.Nickname, string.Format("Help information for \u0002{0}\u0002", foundCommand.Name)); | |||
if (foundCommand.Description != string.Empty) | |||
{ | |||
Bot.IRC.SendNotice(command.Nick.Nickname, string.Format("{0}", foundCommand.Description)); | |||
Bot.IRC.Command.SendNotice(command.Nick.Nickname, string.Format("{0}", foundCommand.Description)); | |||
} | |||
Bot.IRC.SendNotice(command.Nick.Nickname, "\u200B"); | |||
Bot.IRC.Command.SendNotice(command.Nick.Nickname, "\u200B"); | |||
for (int i = 0; i < foundCommand.AllowedMessageTypes.Count; i++) | |||
{ | |||
MessageType messageType = foundCommand.AllowedMessageTypes[i]; | |||
@@ -114,7 +114,7 @@ namespace Combot.Modules.Plugins | |||
if (foundCommand.Triggers.Any()) | |||
{ | |||
string triggerString = (foundCommand.Triggers.Count > 1) ? string.Format("({0})", string.Join("|", foundCommand.Triggers)) : foundCommand.Triggers.First(); | |||
Bot.IRC.SendNotice(command.Nick.Nickname, string.Format("Syntax: {0} {1}\u0002{2}\u0002{3}", messageSyntax, Bot.ServerConfig.CommandPrefix, triggerString, argHelp)); | |||
Bot.IRC.Command.SendNotice(command.Nick.Nickname, string.Format("Syntax: {0} {1}\u0002{2}\u0002{3}", messageSyntax, Bot.ServerConfig.CommandPrefix, triggerString, argHelp)); | |||
} | |||
// Display argument help | |||
@@ -127,10 +127,10 @@ namespace Combot.Modules.Plugins | |||
{ | |||
commandDesc = string.Format(" - {0}", arg.Description); | |||
} | |||
Bot.IRC.SendNotice(command.Nick.Nickname, string.Format("\t\t\u0002{0}\u0002{1}", arg.Name, commandDesc)); | |||
Bot.IRC.Command.SendNotice(command.Nick.Nickname, string.Format("\t\t\u0002{0}\u0002{1}", arg.Name, commandDesc)); | |||
if (arg.AllowedValues.Count > 0) | |||
{ | |||
Bot.IRC.SendNotice(command.Nick.Nickname, string.Format("\t\t\t\tAllowed Values: \u0002{0}\u0002", string.Join(", ", arg.AllowedValues))); | |||
Bot.IRC.Command.SendNotice(command.Nick.Nickname, string.Format("\t\t\t\tAllowed Values: \u0002{0}\u0002", string.Join(", ", arg.AllowedValues))); | |||
} | |||
}); | |||
} | |||
@@ -138,17 +138,17 @@ namespace Combot.Modules.Plugins | |||
} | |||
else | |||
{ | |||
Bot.IRC.SendNotice(command.Nick.Nickname, string.Format("You do not have access to view help on \u0002{0}\u0002.", helpCommand)); | |||
Bot.IRC.Command.SendNotice(command.Nick.Nickname, string.Format("You do not have access to view help on \u0002{0}\u0002.", helpCommand)); | |||
} | |||
} | |||
else | |||
{ | |||
Bot.IRC.SendNotice(command.Nick.Nickname, string.Format("The command \u0002{0}\u0002 does not exist.", helpCommand)); | |||
Bot.IRC.Command.SendNotice(command.Nick.Nickname, string.Format("The command \u0002{0}\u0002 does not exist.", helpCommand)); | |||
} | |||
} | |||
else | |||
{ | |||
Bot.IRC.SendNotice(command.Nick.Nickname, string.Format("The command \u0002{0}\u0002 does not exist.", helpCommand)); | |||
Bot.IRC.Command.SendNotice(command.Nick.Nickname, string.Format("The command \u0002{0}\u0002 does not exist.", helpCommand)); | |||
} | |||
} | |||
} |
@@ -53,7 +53,7 @@ namespace Combot.Modules.Plugins | |||
Random randNum = new Random(); | |||
int index = randNum.Next(0, results.Count); | |||
Dictionary<string, object> intro = results[index]; | |||
Bot.IRC.SendPrivateMessage(info.Channel, string.Format("\u200B{0}", intro["message"])); | |||
Bot.IRC.Command.SendPrivateMessage(info.Channel, string.Format("\u200B{0}", intro["message"])); | |||
} | |||
} | |||
} |
@@ -16,17 +16,17 @@ namespace Combot.Modules.Plugins | |||
{ | |||
if (!Bot.ServerConfig.ChannelBlacklist.Contains(inviteInfo.Channel) && !ChannelBlacklist.Contains(inviteInfo.Channel)) | |||
{ | |||
Bot.IRC.SendJoin(inviteInfo.Channel); | |||
Bot.IRC.Command.SendJoin(inviteInfo.Channel); | |||
string helpMessage = string.Empty; | |||
if (Bot.Modules.Exists(module => module.Commands.Exists(cmd => cmd.Triggers.Contains("help") && cmd.Enabled))) | |||
{ | |||
helpMessage = string.Format(" For more information on what I can do, just type: {0}help", Bot.ServerConfig.CommandPrefix); | |||
} | |||
Bot.IRC.SendPrivateMessage(inviteInfo.Channel, string.Format("{0} has invited me to this channel. If you would like me to leave, just kick me.{1}", inviteInfo.Requester.Nickname, helpMessage)); | |||
Bot.IRC.Command.SendPrivateMessage(inviteInfo.Channel, string.Format("{0} has invited me to this channel. If you would like me to leave, just kick me.{1}", inviteInfo.Requester.Nickname, helpMessage)); | |||
} | |||
else | |||
{ | |||
Bot.IRC.SendNotice(inviteInfo.Requester.Nickname, "I am unable to join that channel."); | |||
Bot.IRC.Command.SendNotice(inviteInfo.Requester.Nickname, "I am unable to join that channel."); | |||
} | |||
} | |||
} |
@@ -89,15 +89,15 @@ namespace Combot.Modules.Plugins | |||
string message = receivedMessages[i]["message"].ToString(); | |||
if ((bool) receivedMessages[i]["anonymous"]) | |||
{ | |||
Bot.IRC.SendPrivateMessage(nickname, string.Format("An anonymous sender has left you a message on \u0002{0}\u0002", dateSent.ToString("MMMM d, yyyy h:mm:ss tt"))); | |||
Bot.IRC.SendPrivateMessage(nickname, string.Format("\"{0}\"", message)); | |||
Bot.IRC.Command.SendPrivateMessage(nickname, string.Format("An anonymous sender has left you a message on \u0002{0}\u0002", dateSent.ToString("MMMM d, yyyy h:mm:ss tt"))); | |||
Bot.IRC.Command.SendPrivateMessage(nickname, string.Format("\"{0}\"", message)); | |||
} | |||
else | |||
{ | |||
string sentNick = GetNickname((int) receivedMessages[i]["sender_nick_id"]); | |||
Bot.IRC.SendPrivateMessage(nickname, string.Format("\u0002{0}\u0002 has left you a message on \u0002{1}\u0002", sentNick, dateSent.ToString("MMMM d, yyyy h:mm:ss tt"))); | |||
Bot.IRC.SendPrivateMessage(nickname, string.Format("\"{0}\"", message)); | |||
Bot.IRC.SendPrivateMessage(nickname, string.Format("If you would like to reply to them, please type \u0002{0}{1} {2} \u001FMessage\u001F\u0002", Bot.ServerConfig.CommandPrefix, Commands.Find(cmd => cmd.Name == "Message").Triggers.First(), sentNick)); | |||
Bot.IRC.Command.SendPrivateMessage(nickname, string.Format("\u0002{0}\u0002 has left you a message on \u0002{1}\u0002", sentNick, dateSent.ToString("MMMM d, yyyy h:mm:ss tt"))); | |||
Bot.IRC.Command.SendPrivateMessage(nickname, string.Format("\"{0}\"", message)); | |||
Bot.IRC.Command.SendPrivateMessage(nickname, string.Format("If you would like to reply to them, please type \u0002{0}{1} {2} \u001FMessage\u001F\u0002", Bot.ServerConfig.CommandPrefix, Commands.Find(cmd => cmd.Name == "Message").Triggers.First(), sentNick)); | |||
} | |||
DeleteMessage((int) receivedMessages[i]["id"]); | |||
} |
@@ -110,8 +110,8 @@ namespace Combot.Modules.Plugins | |||
if (foundChannel != null) | |||
{ | |||
string rollCall = string.Join(", ", foundChannel.Nicks.Select(nick => nick.Nickname)); | |||
Bot.IRC.SendPrivateMessage(channel, "It's time for a Roll Call!"); | |||
Bot.IRC.SendPrivateMessage(channel, rollCall); | |||
Bot.IRC.Command.SendPrivateMessage(channel, "It's time for a Roll Call!"); | |||
Bot.IRC.Command.SendPrivateMessage(channel, rollCall); | |||
} | |||
else | |||
{ | |||
@@ -146,7 +146,7 @@ namespace Combot.Modules.Plugins | |||
if (Bot.CheckChannelAccess(channel, command.Nick.Nickname, Bot.ChannelModeMapping[mode])) | |||
{ | |||
SetMode(set, channel, mode, command.Arguments["Nickname"]); | |||
Bot.IRC.SendPrivateMessage("ChanServ", string.Format("{0} {1} {2} {3}", optionCommand, channel, command.Arguments["Option"], command.Arguments["Nickname"])); | |||
Bot.IRC.Command.SendPrivateMessage("ChanServ", string.Format("{0} {1} {2} {3}", optionCommand, channel, command.Arguments["Option"], command.Arguments["Nickname"])); | |||
} | |||
else | |||
{ | |||
@@ -192,7 +192,7 @@ namespace Combot.Modules.Plugins | |||
} | |||
if (allowedMode) | |||
{ | |||
Bot.IRC.SendMode(channel, modeList); | |||
Bot.IRC.Command.SendMode(channel, modeList); | |||
} | |||
else | |||
{ | |||
@@ -213,7 +213,7 @@ namespace Combot.Modules.Plugins | |||
modeInfo.Mode = mode; | |||
modeInfo.Parameter = nickname; | |||
modeInfo.Set = set; | |||
Bot.IRC.SendMode(channel, modeInfo); | |||
Bot.IRC.Command.SendMode(channel, modeInfo); | |||
} | |||
private void ModifyChannelTopic(Command curCommand, CommandMessage command) | |||
@@ -221,7 +221,7 @@ namespace Combot.Modules.Plugins | |||
string channel = command.Arguments.ContainsKey("Channel") ? command.Arguments["Channel"] : command.Location; | |||
if (Bot.CheckChannelAccess(channel, command.Nick.Nickname, curCommand.AllowedAccess)) | |||
{ | |||
Bot.IRC.SendTopic(channel, command.Arguments["Message"]); | |||
Bot.IRC.Command.SendTopic(channel, command.Arguments["Message"]); | |||
} | |||
else | |||
{ | |||
@@ -235,7 +235,7 @@ namespace Combot.Modules.Plugins | |||
string channel = command.Arguments.ContainsKey("Channel") ? command.Arguments["Channel"] : command.Location; | |||
if (Bot.CheckChannelAccess(channel, command.Nick.Nickname, curCommand.AllowedAccess)) | |||
{ | |||
Bot.IRC.SendInvite(channel, command.Arguments["Nickname"]); | |||
Bot.IRC.Command.SendInvite(channel, command.Arguments["Nickname"]); | |||
} | |||
else | |||
{ | |||
@@ -331,11 +331,11 @@ namespace Combot.Modules.Plugins | |||
{ | |||
if (command.Arguments.ContainsKey("Reason")) | |||
{ | |||
Bot.IRC.SendKick(channel, command.Arguments["Nickname"], command.Arguments["Reason"]); | |||
Bot.IRC.Command.SendKick(channel, command.Arguments["Nickname"], command.Arguments["Reason"]); | |||
} | |||
else | |||
{ | |||
Bot.IRC.SendKick(channel, command.Arguments["Nickname"]); | |||
Bot.IRC.Command.SendKick(channel, command.Arguments["Nickname"]); | |||
} | |||
} | |||
else | |||
@@ -348,7 +348,7 @@ namespace Combot.Modules.Plugins | |||
private void KickSelf(CommandMessage command) | |||
{ | |||
string channel = command.Arguments.ContainsKey("Channel") ? command.Arguments["Channel"] : command.Location; | |||
Bot.IRC.SendKick(channel, command.Nick.Nickname); | |||
Bot.IRC.Command.SendKick(channel, command.Nick.Nickname); | |||
} | |||
private void ClearChannel(Command curCommand, CommandMessage command) | |||
@@ -356,7 +356,7 @@ namespace Combot.Modules.Plugins | |||
string channel = command.Arguments.ContainsKey("Channel") ? command.Arguments["Channel"] : command.Location; | |||
if (Bot.CheckChannelAccess(channel, command.Nick.Nickname, curCommand.AllowedAccess)) | |||
{ | |||
Bot.IRC.SendPrivateMessage("ChanServ", string.Format("CLEAR {0} {1}", channel, command.Arguments["Target"])); | |||
Bot.IRC.Command.SendPrivateMessage("ChanServ", string.Format("CLEAR {0} {1}", channel, command.Arguments["Target"])); | |||
} | |||
else | |||
{ |
@@ -43,15 +43,15 @@ namespace Combot.Modules.Plugins | |||
} | |||
break; | |||
case "Change Nick": | |||
Bot.IRC.SendNick(command.Arguments["Nickname"]); | |||
Bot.IRC.Command.SendNick(command.Arguments["Nickname"]); | |||
break; | |||
case "Identify": | |||
Bot.IRC.SendPrivateMessage("NickServ", string.Format("Identify {0}", Bot.ServerConfig.Password)); | |||
Bot.IRC.Command.SendPrivateMessage("NickServ", string.Format("Identify {0}", Bot.ServerConfig.Password)); | |||
break; | |||
case "Join Channel": | |||
if (!Bot.IRC.Channels.Exists(chan => chan.Name == command.Arguments["Channel"])) | |||
{ | |||
Bot.IRC.SendJoin(command.Arguments["Channel"]); | |||
Bot.IRC.Command.SendJoin(command.Arguments["Channel"]); | |||
} | |||
else | |||
{ | |||
@@ -63,7 +63,7 @@ namespace Combot.Modules.Plugins | |||
string channel = command.Arguments.ContainsKey("Channel") ? command.Arguments["Channel"] : command.Location; | |||
if (Bot.IRC.Channels.Exists(chan => chan.Name == channel)) | |||
{ | |||
Bot.IRC.SendPart(channel); | |||
Bot.IRC.Command.SendPart(channel); | |||
} | |||
else | |||
{ | |||
@@ -73,11 +73,11 @@ namespace Combot.Modules.Plugins | |||
break; | |||
case "Speak": | |||
string location = command.Arguments.ContainsKey("Target") ? command.Arguments["Target"] : command.Location; | |||
Bot.IRC.SendPrivateMessage(location, command.Arguments["Message"]); | |||
Bot.IRC.Command.SendPrivateMessage(location, command.Arguments["Message"]); | |||
break; | |||
case "Action": | |||
string actionLocation = command.Arguments.ContainsKey("Channel") ? command.Arguments["Channel"] : command.Location; | |||
Bot.IRC.SendCTCPMessage(actionLocation, "ACTION", command.Arguments["Message"]); | |||
Bot.IRC.Command.SendCTCPMessage(actionLocation, "ACTION", command.Arguments["Message"]); | |||
break; | |||
case "Quit": | |||
string quitType = command.Arguments["Type"].ToString(); | |||
@@ -99,8 +99,8 @@ namespace Combot.Modules.Plugins | |||
string cycleChannel = command.Arguments.ContainsKey("Channel") ? command.Arguments["Channel"] : command.Location; | |||
if (Bot.IRC.Channels.Exists(chan => chan.Name == cycleChannel)) | |||
{ | |||
Bot.IRC.SendPart(cycleChannel); | |||
Bot.IRC.SendJoin(cycleChannel); | |||
Bot.IRC.Command.SendPart(cycleChannel); | |||
Bot.IRC.Command.SendJoin(cycleChannel); | |||
} | |||
else | |||
{ |
@@ -16,7 +16,7 @@ namespace Combot.Modules.Plugins | |||
{ | |||
listLock = new ReaderWriterLockSlim(); | |||
pingList = new List<PingItem>(); | |||
Bot.IRC.Message.CTCPNoticeRecievedEvent += HandlePingResponse; | |||
Bot.IRC.Message.CTCPNoticeReceivedEvent += HandlePingResponse; | |||
Bot.CommandReceivedEvent += HandleCommandEvent; | |||
} | |||
@@ -39,7 +39,7 @@ namespace Combot.Modules.Plugins | |||
} | |||
pingList.Add(tmpItem); | |||
listLock.ExitWriteLock(); | |||
Bot.IRC.SendCTCPMessage(command.Nick.Nickname, "PING", epoch.ToString()); | |||
Bot.IRC.Command.SendCTCPMessage(command.Nick.Nickname, "PING", epoch.ToString()); | |||
} | |||
} | |||
@@ -79,13 +79,13 @@ namespace Combot.Modules.Plugins | |||
switch (pingItem.MessageType) | |||
{ | |||
case MessageType.Channel: | |||
Bot.IRC.SendPrivateMessage(pingItem.Location, string.Format("{0}, your ping is {1}", pingItem.Nick, timeString)); | |||
Bot.IRC.Command.SendPrivateMessage(pingItem.Location, string.Format("{0}, your ping is {1}", pingItem.Nick, timeString)); | |||
break; | |||
case MessageType.Notice: | |||
Bot.IRC.SendNotice(pingItem.Nick, string.Format("Your ping is {0}", timeString)); | |||
Bot.IRC.Command.SendNotice(pingItem.Nick, string.Format("Your ping is {0}", timeString)); | |||
break; | |||
case MessageType.Query: | |||
Bot.IRC.SendPrivateMessage(pingItem.Nick, string.Format("Your ping is {0}", timeString)); | |||
Bot.IRC.Command.SendPrivateMessage(pingItem.Nick, string.Format("Your ping is {0}", timeString)); | |||
break; | |||
} | |||
listLock.EnterWriteLock(); |
@@ -42,7 +42,7 @@ namespace Combot.Modules.Plugins | |||
info.Lines++; | |||
if (info.Lines > maxMessages) | |||
{ | |||
Bot.IRC.SendKick(info.Channel, info.Nick, string.Format("Please do not spam. You have messaged {0} times within {1}ms.", info.Lines, timeThreshold)); | |||
Bot.IRC.Command.SendKick(info.Channel, info.Nick, string.Format("Please do not spam. You have messaged {0} times within {1}ms.", info.Lines, timeThreshold)); | |||
SpamMessageLock.EnterWriteLock(); | |||
SpamMessageList.Remove(info); | |||
SpamMessageLock.ExitWriteLock(); | |||
@@ -97,7 +97,7 @@ namespace Combot.Modules.Plugins | |||
info.Highlights += foundNicks.Count; | |||
if (info.Highlights > maxHighlights) | |||
{ | |||
Bot.IRC.SendKick(info.Channel, info.Nick, string.Format("Please do not highlight spam. You have highlighted {0} nicks within {1}ms.", info.Highlights, timeThreshold)); | |||
Bot.IRC.Command.SendKick(info.Channel, info.Nick, string.Format("Please do not highlight spam. You have highlighted {0} nicks within {1}ms.", info.Highlights, timeThreshold)); | |||
SpamHighlightLock.EnterWriteLock(); | |||
SpamHighlightList.Remove(info); | |||
SpamHighlightLock.ExitWriteLock(); |
@@ -55,26 +55,26 @@ namespace Combot.Modules.Plugins | |||
x.Encoding = Encoding.UTF8; | |||
string source = x.DownloadString(urlMatch.ToString()); | |||
string title = Regex.Match(source, @"\<title\b[^>]*\>\s*(?<Title>[\s\S]*?)\</title\>", RegexOptions.IgnoreCase).Groups["Title"].Value; | |||
Bot.IRC.SendPrivateMessage(message.Channel, string.Format("[URL] {0} ({1})", HttpUtility.HtmlDecode(HttpUtility.UrlDecode(StripTagsCharArray(title))), url.Host)); | |||
Bot.IRC.Command.SendPrivateMessage(message.Channel, string.Format("[URL] {0} ({1})", HttpUtility.HtmlDecode(HttpUtility.UrlDecode(StripTagsCharArray(title))), url.Host)); | |||
} | |||
break; | |||
case "image": | |||
Bot.IRC.SendPrivateMessage(message.Channel, string.Format("[{0}] Size: {1}", webResponse.ContentType, ToFileSize(contentLength))); | |||
Bot.IRC.Command.SendPrivateMessage(message.Channel, string.Format("[{0}] Size: {1}", webResponse.ContentType, ToFileSize(contentLength))); | |||
break; | |||
case "video": | |||
Bot.IRC.SendPrivateMessage(message.Channel, string.Format("[Video] Type: {0} | Size: {1}", webResponse.ContentType.Split('/')[1], ToFileSize(contentLength))); | |||
Bot.IRC.Command.SendPrivateMessage(message.Channel, string.Format("[Video] Type: {0} | Size: {1}", webResponse.ContentType.Split('/')[1], ToFileSize(contentLength))); | |||
break; | |||
case "application": | |||
Bot.IRC.SendPrivateMessage(message.Channel, string.Format("[Application] Type: {0} | Size: {1}", webResponse.ContentType.Split('/')[1], ToFileSize(contentLength))); | |||
Bot.IRC.Command.SendPrivateMessage(message.Channel, string.Format("[Application] Type: {0} | Size: {1}", webResponse.ContentType.Split('/')[1], ToFileSize(contentLength))); | |||
break; | |||
case "audio": | |||
Bot.IRC.SendPrivateMessage(message.Channel, string.Format("[Audio] Type: {0} | Size: {1}", webResponse.ContentType.Split('/')[1], ToFileSize(contentLength))); | |||
Bot.IRC.Command.SendPrivateMessage(message.Channel, string.Format("[Audio] Type: {0} | Size: {1}", webResponse.ContentType.Split('/')[1], ToFileSize(contentLength))); | |||
break; | |||
} | |||
} | |||
else | |||
{ | |||
Bot.IRC.SendPrivateMessage(message.Channel, string.Format("[URL] Returned Status Code \u0002{0}\u0002 ({1})", code, url.Host)); | |||
Bot.IRC.Command.SendPrivateMessage(message.Channel, string.Format("[URL] Returned Status Code \u0002{0}\u0002 ({1})", code, url.Host)); | |||
} | |||
} | |||
} | |||
@@ -83,7 +83,7 @@ namespace Combot.Modules.Plugins | |||
if (ex.Response != null) | |||
{ | |||
int code = (int) ((HttpWebResponse) ex.Response).StatusCode; | |||
Bot.IRC.SendPrivateMessage(message.Channel, string.Format("[URL] Response Code: \u0002{0}\u0002 ({1})", code, url.Host)); | |||
Bot.IRC.Command.SendPrivateMessage(message.Channel, string.Format("[URL] Response Code: \u0002{0}\u0002 ({1})", code, url.Host)); | |||
} | |||
} | |||
} |
@@ -16,8 +16,8 @@ namespace Combot.Modules.Plugins | |||
{ | |||
listLock = new ReaderWriterLockSlim(); | |||
versionList = new List<VersionItem>(); | |||
Bot.IRC.Message.CTCPMessageRecievedEvent += HandleVersionQuery; | |||
Bot.IRC.Message.CTCPNoticeRecievedEvent += HandleVersionResponse; | |||
Bot.IRC.Message.CTCPMessageReceivedEvent += HandleVersionQuery; | |||
Bot.IRC.Message.CTCPNoticeReceivedEvent += HandleVersionResponse; | |||
Bot.CommandReceivedEvent += HandleCommandEvent; | |||
} | |||
@@ -42,7 +42,7 @@ namespace Combot.Modules.Plugins | |||
} | |||
versionList.Add(tmpItem); | |||
listLock.ExitWriteLock(); | |||
Bot.IRC.SendCTCPMessage(nickList[i], "VERSION"); | |||
Bot.IRC.Command.SendCTCPMessage(nickList[i], "VERSION"); | |||
} | |||
} | |||
} | |||
@@ -51,7 +51,7 @@ namespace Combot.Modules.Plugins | |||
{ | |||
if (message.Command.ToLower() == "version") | |||
{ | |||
Bot.IRC.SendCTCPNotice(message.Sender.Nickname, "VERSION", string.Format("Combot v{0} on {1}", Assembly.GetExecutingAssembly().GetName().Version, GetOptionValue("Machine Reply"))); | |||
Bot.IRC.Command.SendCTCPNotice(message.Sender.Nickname, "VERSION", string.Format("Combot v{0} on {1}", Assembly.GetExecutingAssembly().GetName().Version, GetOptionValue("Machine Reply"))); | |||
} | |||
} | |||
@@ -75,11 +75,11 @@ namespace Combot.Modules.Plugins | |||
string startMsg = string.Format("{0} day forecast for {1}", days, command.Arguments["Location"]); | |||
if (command.MessageType == MessageType.Channel || command.MessageType == MessageType.Notice) | |||
{ | |||
Bot.IRC.SendNotice(command.Nick.Nickname, startMsg); | |||
Bot.IRC.Command.SendNotice(command.Nick.Nickname, startMsg); | |||
} | |||
else | |||
{ | |||
Bot.IRC.SendPrivateMessage(command.Nick.Nickname, startMsg); | |||
Bot.IRC.Command.SendPrivateMessage(command.Nick.Nickname, startMsg); | |||
} | |||
int index = 0; | |||
foreach (XmlNode node in nodes) | |||
@@ -97,11 +97,11 @@ namespace Combot.Modules.Plugins | |||
string forecastMsg = string.Format("{0}: {1} with a high of {2} F ({3} C) and a low of {4} F ({5} C).", weekday, conditions, highf, highc, lowf, lowc); | |||
if (command.MessageType == MessageType.Channel || command.MessageType == MessageType.Notice) | |||
{ | |||
Bot.IRC.SendNotice(command.Nick.Nickname, forecastMsg); | |||
Bot.IRC.Command.SendNotice(command.Nick.Nickname, forecastMsg); | |||
} | |||
else | |||
{ | |||
Bot.IRC.SendPrivateMessage(command.Nick.Nickname, forecastMsg); | |||
Bot.IRC.Command.SendPrivateMessage(command.Nick.Nickname, forecastMsg); | |||
} | |||
} | |||
index++; |
@@ -41,7 +41,7 @@ namespace Combot.Modules.Plugins | |||
{ | |||
Match urlMatch = urlRegex.Match(message.Message); | |||
string youtubeMessage = GetYoutubeDescription(urlMatch.Groups["ID"].Value); | |||
Bot.IRC.SendPrivateMessage(message.Channel, youtubeMessage); | |||
Bot.IRC.Command.SendPrivateMessage(message.Channel, youtubeMessage); | |||
} | |||
} | |||
} |