Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Irc notifications: add support for ssl and password protected servers

  • Loading branch information...
commit 313946a0ef50ff79320997b00d184053737665da 1 parent f27f302
@rolfbjarne rolfbjarne authored
View
8 MonkeyWrench.DataClasses/Database/DBIrcIdentity.generated.cs
@@ -32,13 +32,19 @@ public partial class DBIrcIdentity : DBRecord
{
private string _name;
private string _servers;
+ private string _password;
private string _channels;
private string _nicks;
+ private bool _use_ssl;
+ private bool _join_channels;
public string @name { get { return _name; } set { _name = value; } }
public string @servers { get { return _servers; } set { _servers = value; } }
+ public string @password { get { return _password; } set { _password = value; } }
public string @channels { get { return _channels; } set { _channels = value; } }
public string @nicks { get { return _nicks; } set { _nicks = value; } }
+ public bool @use_ssl { get { return _use_ssl; } set { _use_ssl = value; } }
+ public bool @join_channels { get { return _join_channels; } set { _join_channels = value; } }
public override string Table
@@ -51,7 +57,7 @@ public override string Table
{
get
{
- return new string [] { "name", "servers", "channels", "nicks" };
+ return new string [] { "name", "servers", "password", "channels", "nicks", "use_ssl", "join_channels" };
}
}
View
15 MonkeyWrench.Web.UI/Identities.aspx
@@ -2,17 +2,21 @@
CodeBehind="Identities.aspx.cs" EnableViewState="false" %>
<asp:Content ID="Content2" ContentPlaceHolderID="content" runat="Server">
+ <script type="text/javascript" src="Identities.js"></script>
<asp:Table runat="server" CssClass="center">
<asp:TableRow>
<asp:TableCell HorizontalAlign="Center">
<asp:Table ID="tblIrcIdentities" runat="server" CssClass="buildstatus identity">
<asp:TableHeaderRow>
- <asp:TableHeaderCell ColumnSpan="5">IRC Identities</asp:TableHeaderCell>
+ <asp:TableHeaderCell ColumnSpan="8">IRC Identities</asp:TableHeaderCell>
</asp:TableHeaderRow>
<asp:TableHeaderRow>
<asp:TableHeaderCell>Name</asp:TableHeaderCell>
<asp:TableHeaderCell>Servers</asp:TableHeaderCell>
+ <asp:TableHeaderCell>Password</asp:TableHeaderCell>
+ <asp:TableHeaderCell>Use SSL</asp:TableHeaderCell>
<asp:TableHeaderCell>Channels</asp:TableHeaderCell>
+ <asp:TableHeaderCell>Join Channels</asp:TableHeaderCell>
<asp:TableHeaderCell>Nicks</asp:TableHeaderCell>
<asp:TableHeaderCell>Actions</asp:TableHeaderCell>
</asp:TableHeaderRow>
@@ -24,9 +28,18 @@
<asp:TextBox ID="txtIrcServers" runat="server" ToolTip="A comma separated list of irc servers" />
</asp:TableCell>
<asp:TableCell>
+ <asp:TextBox ID="txtPassword" runat="server" ToolTip="The password for the server(s) (if any)" />
+ </asp:TableCell>
+ <asp:TableCell>
+ <asp:CheckBox ID="chkUseSsl" Text="" runat="server" ToolTip="If the server(s) require SSL" />
+ </asp:TableCell>
+ <asp:TableCell>
<asp:TextBox ID="txtIrcChannels" runat="server" ToolTip="A comma separated list of irc channels to join" />
</asp:TableCell>
<asp:TableCell>
+ <asp:CheckBox ID="chkJoinChannels" Text="" runat="server" ToolTip="If monkeywrench should join the channels." />
+ </asp:TableCell>
+ <asp:TableCell>
<asp:TextBox ID="txtIrcNicks" runat="server" ToolTip="A comma separated list of irc nicks to use" />
</asp:TableCell>
<asp:TableCell>
View
122 MonkeyWrench.Web.UI/Identities.aspx.cs
@@ -36,6 +36,8 @@ protected void Page_Load (object sender, EventArgs e)
TableRow row;
try {
+ string action = Request ["action"];
+ int id;
foreach (TextBox tb in new TextBox [] { txtEmailEmail, txtEmailName, txtEmailPassword }) {
tb.Attributes.Add ("onfocus", "javascript: document.getElementById ('lblEmailHelp').innerHTML = '" + tb.ToolTip + "';");
@@ -50,13 +52,122 @@ protected void Page_Load (object sender, EventArgs e)
if (response.Exception != null) {
lblMessage.Text = response.Exception.Message;
} else {
+ if (!string.IsNullOrEmpty (action)) {
+ WebServiceResponse rsp;
+
+ switch (action) {
+ case "changeircname":
+ string name = Request ["name"];
+ if (!string.IsNullOrEmpty (name) && int.TryParse (Request ["id"], out id)) {
+ DBIrcIdentity identity = response.IrcIdentities.Find ((v1) => v1.id == id);
+ if (identity != null) {
+ identity.name = name;
+ rsp = Master.WebService.EditIdentity (Master.WebServiceLogin, identity, null);
+ if (rsp.Exception != null) {
+ lblMessage.Text = response.Exception.Message;
+ return;
+ }
+ }
+ }
+ break;
+ case "switchircssl":
+ if (int.TryParse (Request ["id"], out id)) {
+ DBIrcIdentity identity = response.IrcIdentities.Find ((v2) => v2.id == id);
+ if (identity != null) {
+ identity.use_ssl = !identity.use_ssl;
+ rsp = Master.WebService.EditIdentity (Master.WebServiceLogin, identity, null);
+ if (rsp.Exception != null) {
+ lblMessage.Text = response.Exception.Message;
+ return;
+ }
+ }
+ }
+ break;
+ case "changeircchannels":
+ string channels = Request ["channels"];
+ if (!string.IsNullOrEmpty (channels) && int.TryParse (Request ["id"], out id)) {
+ DBIrcIdentity identity = response.IrcIdentities.Find ((v3) => v3.id == id);
+ if (identity != null) {
+ identity.channels = channels;
+ rsp = Master.WebService.EditIdentity (Master.WebServiceLogin, identity, null);
+ if (rsp.Exception != null) {
+ lblMessage.Text = response.Exception.Message;
+ return;
+ }
+ }
+ }
+ break;
+ case "switchjoinchannels":
+ if (int.TryParse (Request ["id"], out id)) {
+ DBIrcIdentity identity = response.IrcIdentities.Find ((v4) => v4.id == id);
+ if (identity != null) {
+ identity.join_channels = !identity.join_channels;
+ rsp = Master.WebService.EditIdentity (Master.WebServiceLogin, identity, null);
+ if (rsp.Exception != null) {
+ lblMessage.Text = response.Exception.Message;
+ return;
+ }
+ }
+ }
+ break;
+ case "changeircnicks":
+ string nicks = Request ["nicks"];
+ if (!string.IsNullOrEmpty (nicks) && int.TryParse (Request ["id"], out id)) {
+ DBIrcIdentity identity = response.IrcIdentities.Find ((v5) => v5.id == id);
+ if (identity != null) {
+ identity.nicks = nicks;
+ rsp = Master.WebService.EditIdentity (Master.WebServiceLogin, identity, null);
+ if (rsp.Exception != null) {
+ lblMessage.Text = response.Exception.Message;
+ return;
+ }
+ }
+ }
+ break;
+ case "changeircservers":
+ string servers = Request ["servers"];
+ if (!string.IsNullOrEmpty (servers) && int.TryParse (Request ["id"], out id)) {
+ DBIrcIdentity identity = response.IrcIdentities.Find ((v6) => v6.id == id);
+ if (identity != null) {
+ identity.servers = servers;
+ rsp = Master.WebService.EditIdentity (Master.WebServiceLogin, identity, null);
+ if (rsp.Exception != null) {
+ lblMessage.Text = response.Exception.Message;
+ return;
+ }
+ }
+ }
+ break;
+ case "changeircpassword":
+ string password = Request ["password"];
+ if (int.TryParse (Request ["id"], out id)) {
+ DBIrcIdentity identity = response.IrcIdentities.Find ((v6) => v6.id == id);
+ if (identity != null) {
+ identity.password = password;
+ rsp = Master.WebService.EditIdentity (Master.WebServiceLogin, identity, null);
+ if (rsp.Exception != null) {
+ lblMessage.Text = response.Exception.Message;
+ return;
+ }
+ }
+ }
+ break;
+ }
+
+ Response.Redirect ("Identities.aspx", false);
+ return;
+ }
+
if (response.IrcIdentities != null) {
foreach (DBIrcIdentity irc in response.IrcIdentities) {
row = new TableRow ();
- row.Cells.Add (Utils.CreateTableCell (irc.name));
- row.Cells.Add (Utils.CreateTableCell (irc.servers));
- row.Cells.Add (Utils.CreateTableCell (irc.channels));
- row.Cells.Add (Utils.CreateTableCell (irc.nicks));
+ row.Cells.Add (Utils.CreateTableCell (string.Format ("<a href='javascript:changeircname ({2}, \"{0}\");'>{1}</a>", HttpUtility.UrlEncode (irc.name), HttpUtility.HtmlEncode (irc.name), irc.id)));
+ row.Cells.Add (Utils.CreateTableCell (string.Format ("<a href='javascript:changeircservers ({2}, \"{0}\");'>{1}</a>", HttpUtility.UrlEncode (irc.servers), HttpUtility.HtmlEncode (irc.servers), irc.id)));
+ row.Cells.Add (Utils.CreateTableCell (string.Format ("<a href='javascript:changeircpassword ({2}, \"{0}\");'>{1}</a>", HttpUtility.UrlEncode (irc.password), string.IsNullOrEmpty (irc.password) ? "(none)" : HttpUtility.HtmlEncode (irc.password), irc.id)));
+ row.Cells.Add (Utils.CreateTableCell (string.Format ("<a href='Identities.aspx?action=switchircssl&id={1}'>{0}</a>", irc.use_ssl ? "Yes" : "No", irc.id)));
+ row.Cells.Add (Utils.CreateTableCell (string.Format ("<a href='javascript:changeircchannels ({2}, \"{0}\");'>{1}</a>", HttpUtility.UrlEncode (irc.channels), HttpUtility.HtmlEncode (irc.channels), irc.id)));
+ row.Cells.Add (Utils.CreateTableCell (string.Format ("<a href='Identities.aspx?action=switchjoinchannels&id={1}'>{0}</a>", irc.join_channels ? "Yes" : "No", irc.id)));
+ row.Cells.Add (Utils.CreateTableCell (string.Format ("<a href='javascript:changeircnicks ({2}, \"{0}\");'>{1}</a>", HttpUtility.UrlEncode (irc.nicks), HttpUtility.HtmlEncode (irc.nicks), irc.id)));
row.Cells.Add (Utils.CreateTableCell (Utils.CreateLinkButton ("remove_irc_" + irc.id.ToString (), "Remove", "RemoveIrcIdentity", irc.id.ToString (), OnLinkButtonCommand)));
tblIrcIdentities.Rows.AddAt (tblIrcIdentities.Rows.Count - 1, row);
}
@@ -111,7 +222,10 @@ protected void lnkIrcAdd_Click (object sender, EventArgs e)
irc_identity.name = txtIrcName.Text;
irc_identity.nicks = txtIrcNicks.Text;
irc_identity.servers = txtIrcServers.Text;
+ irc_identity.join_channels = chkJoinChannels.Checked;
+ irc_identity.use_ssl = chkUseSsl.Checked;
irc_identity.channels = txtIrcChannels.Text;
+ irc_identity.password = txtPassword.Text ?? string.Empty;
if (string.IsNullOrEmpty (irc_identity.name))
throw new Exception ("You need to specify the name of the irc identity");
View
27 MonkeyWrench.Web.UI/Identities.aspx.designer.cs
@@ -39,6 +39,24 @@ public partial class Identities {
protected global::System.Web.UI.WebControls.TextBox txtIrcServers;
/// <summary>
+ /// txtPassword control.
+ /// </summary>
+ /// <remarks>
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ /// </remarks>
+ protected global::System.Web.UI.WebControls.TextBox txtPassword;
+
+ /// <summary>
+ /// chkUseSsl control.
+ /// </summary>
+ /// <remarks>
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ /// </remarks>
+ protected global::System.Web.UI.WebControls.CheckBox chkUseSsl;
+
+ /// <summary>
/// txtIrcChannels control.
/// </summary>
/// <remarks>
@@ -48,6 +66,15 @@ public partial class Identities {
protected global::System.Web.UI.WebControls.TextBox txtIrcChannels;
/// <summary>
+ /// chkJoinChannels control.
+ /// </summary>
+ /// <remarks>
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ /// </remarks>
+ protected global::System.Web.UI.WebControls.CheckBox chkJoinChannels;
+
+ /// <summary>
/// txtIrcNicks control.
/// </summary>
/// <remarks>
View
30 MonkeyWrench.Web.UI/Identities.js
@@ -0,0 +1,30 @@
+function changeircservers (id, current) {
+ var servers = prompt("Enter servers:", current);
+ if (servers != null && servers != "" && servers != current)
+ window.location = window.location.pathname + "?action=changeircservers&id=" + id + "&servers=" + encodeURIComponent(servers);
+}
+
+function changeircname(id, current) {
+ var newvalue = prompt("Enter name:", current);
+ if (newvalue != null && newvalue != "" && newvalue != current)
+ window.location = window.location.pathname + "?action=changeircname&id=" + id + "&name=" + encodeURIComponent(newvalue);
+}
+
+function changeircchannels(id, current) {
+ var newvalue = prompt("Enter channels:", current);
+ if (newvalue != null && newvalue != "" && newvalue != current)
+ window.location = window.location.pathname + "?action=changeircchannels&id=" + id + "&channels=" + encodeURIComponent(newvalue);
+}
+
+function changeircnicks(id, current) {
+ var newvalue = prompt("Enter nicks:", current);
+ if (newvalue != null && newvalue != "" && newvalue != current)
+ window.location = window.location.pathname + "?action=changeircnicks&id=" + id + "&nicks=" + encodeURIComponent(newvalue);
+}
+
+function changeircpassword(id, current) {
+ var newvalue = prompt("Enter password:", current);
+ if (newvalue != null && newvalue != "" && newvalue != current)
+ window.location = window.location.pathname + "?action=changeircpassword&id=" + id + "&password=" + encodeURIComponent(newvalue);
+}
+
View
1  MonkeyWrench.Web.UI/MonkeyWrench.Web.UI.csproj
@@ -54,6 +54,7 @@
<Content Include="BuildBotStatus.aspx" />
<Content Include="BuildBotStatus.js" />
<Content Include="clientaccesspolicy.xml" />
+ <Content Include="Identities.js" />
<Content Include="DownloadLatestFile.aspx" />
<Content Include="Identities.aspx" />
<Content Include="Master.js" />
View
2  MonkeyWrench.Web.WebService/MonkeyWrench.Web.WebService.csproj
@@ -62,7 +62,7 @@
<Project>{EBFBC3BF-10E1-4482-B9BE-A516934C099A}</Project>
<Name>MonkeyWrench</Name>
</ProjectReference>
- <ProjectReference Include="..\SmartIrc4net\SmartIrc4net-0.4.0-src\VisualStudio\2010\SmartIrc4net.csproj">
+ <ProjectReference Include="..\SmartIrc4net\smartirc4net-0.4.5.1\SmartIrc4net.csproj">
<Project>{19607F57-B521-4477-9DE0-F0D9B1A68BC7}</Project>
<Name>SmartIrc4net</Name>
</ProjectReference>
View
269 MonkeyWrench.Web.WebService/Notifications.cs
@@ -280,11 +280,153 @@ private void FindPerson (DBPerson person, List<DBPerson> people)
public class IrcNotification : NotificationBase
{
- Thread thread;
- IrcClient irc;
+ IrcState joined_state;
DBIrcIdentity identity;
+ string [] channels;
bool enabled = true;
+ class IrcState
+ {
+ public IrcNotification Notification;
+ public IrcClient Client;
+ public Thread Thread;
+ public ManualResetEvent Connected = new ManualResetEvent (false);
+
+ public IrcState (IrcNotification notification)
+ {
+ this.Notification = notification;
+ }
+
+ public bool WaitForConnected (TimeSpan timeout)
+ {
+ return Connected.WaitOne (timeout);
+ }
+
+ public bool WaitForEmptySendBuffer (TimeSpan timeout)
+ {
+ DateTime start = DateTime.Now;
+
+ while (!Client.IsSendBufferEmpty) {
+ Thread.Sleep (10);
+ if (start.Add (timeout) > DateTime.Now)
+ return false;
+ }
+
+ return true;
+ }
+
+ public void Start ()
+ {
+ Client = new IrcClient ();
+ Thread = new Thread (Loop);
+ Thread.Start ();
+ }
+
+ private void Loop (object obj)
+ {
+ try {
+ IrcClient irc = Client;
+
+ string [] servers;
+ string [] nicks;
+ int port = 6667;
+
+ Logger.Log ("Connecting to irc: {0} joining {1} as {2} using ssl: {3}", Notification.identity.servers, Notification.identity.channels, Notification.identity.nicks, Notification.identity.use_ssl);
+
+ servers = Notification.identity.servers.Split (',', ' ');
+ Notification.channels = Notification.identity.channels.Split (',', ' ');
+ nicks = Notification.identity.nicks.Split (',', ' ');
+
+ for (int i = 0; i < servers.Length; i++) {
+ int colon = servers [i].IndexOf (':');
+ if (colon > 0) {
+ int.TryParse (servers [i].Substring (colon + 1), out port);
+ servers [i] = servers [i].Substring (0, colon);
+ break;
+ }
+ }
+
+ //irc.AutoRetry = true;
+ irc.SendDelay = 200;
+ irc.UseSsl = Notification.identity.use_ssl;
+
+ irc.OnAutoConnectError += new AutoConnectErrorEventHandler (irc_OnAutoConnectError);
+ irc.OnQueryMessage += new IrcEventHandler (irc_OnQueryMessage);
+ irc.OnConnected += new EventHandler (irc_OnConnected);
+ irc.OnDisconnected += new EventHandler (irc_OnDisconnected);
+ irc.OnRawMessage += new IrcEventHandler (irc_OnRawMessage);
+ Logger.Log ("Connecting to servers: {0} : {1}", string.Join (";", servers), port);
+ irc.Connect (servers, port);
+ irc.Login (nicks, "MonkeyWrench", 0, "MonkeyWrench", Notification.identity.password);
+
+ if (Notification.identity.join_channels)
+ irc.RfcJoin (Notification.channels);
+
+ Logger.Log ("Connected to irc: {0} joined {1} as {2}", Notification.identity.servers, Notification.identity.channels, Notification.identity.nicks);
+ Connected.Set ();
+ irc.Listen ();
+ } catch (Exception ex) {
+ Logger.Log ("Exception while connecting to irc: {0}", ex);
+ }
+
+ }
+
+ void irc_OnRawMessage (object sender, IrcEventArgs e)
+ {
+ IrcClient irc = Client;
+
+ switch (e.Data.Type) {
+ case ReceiveType.ChannelMessage:
+ if (e.Data.Message.StartsWith (irc.Nickname)) {
+ string cmd = e.Data.Message.Substring (irc.Nickname.Length).TrimStart (':', ' ', ',');
+ switch (cmd.ToLowerInvariant ()) {
+ case "enable":
+ Notification.enabled = true;
+ break;
+ case "disable":
+ Notification.enabled = false;
+ break;
+ case "state":
+ irc.SendMessage (SendType.Message, e.Data.Channel, e.Data.Nick + ": " + (Notification.enabled ? "enabled" : "disabled"));
+ break;
+ case "help":
+ case "h":
+ case "?":
+ case "/?":
+ case "-?":
+ irc.SendMessage (SendType.Message, e.Data.Channel, e.Data.Nick + ": enable|disable: enable or disable irc notifications temporarily.");
+ break;
+ default:
+ irc.SendMessage (SendType.Message, e.Data.Channel, e.Data.Nick + ": Don't know how to '" + cmd + "'");
+ break;
+ }
+ }
+ break;
+ }
+ Console.WriteLine ("OnRawMessage");
+ }
+
+ void irc_OnQueryMessage (object sender, IrcEventArgs e)
+ {
+ Console.WriteLine ("OnQueryMessage");
+ }
+
+ void irc_OnAutoConnectError (object sender, AutoConnectErrorEventArgs e)
+ {
+ Console.WriteLine ("irc_OnAutoConnectError");
+ }
+
+ void irc_OnDisconnected (object sender, EventArgs e)
+ {
+ Console.WriteLine ("irc_OnDisconnected");
+ }
+
+ void irc_OnConnected (object sender, EventArgs e)
+ {
+ Console.WriteLine ("irc_OnConnected");
+ }
+ }
+
public IrcNotification (DBNotification notification)
: base (notification)
{
@@ -302,7 +444,8 @@ public IrcNotification (DBNotification notification)
}
}
- Connect ();
+ if (identity.join_channels)
+ joined_state = Connect ();
}
public override void Stop ()
@@ -310,19 +453,25 @@ public override void Stop ()
Disconnect ();
}
- private void Connect ()
+ private IrcState Connect ()
{
- irc = new IrcClient ();
-
- thread = new Thread (Loop);
- thread.Start ();
+ IrcState state = new IrcState (this);
+ state.Start ();
+ return state;
}
private void Disconnect ()
{
+ if (identity.join_channels) {
+ Disconnect (joined_state);
+ joined_state = null;
+ }
+ }
+
+ private void Disconnect (IrcState state)
+ {
try {
- irc.Disconnect ();
- irc = null;
+ state.Client.Disconnect ();
} catch (Exception ex) {
Logger.Log ("Exception while disconnecting from irc: {0}", ex.Message);
}
@@ -330,6 +479,8 @@ private void Disconnect ()
protected override void Notify (DBWork work, DBRevisionWork revision_work, List<DBPerson> people, string message)
{
+ IrcState state;
+
Logger.Log ("IrcNotification.Notify (lane_id: {1} revision_id: {2} host_id: {3} State: {0}) enabled: {4}", work.State, revision_work.lane_id, revision_work.revision_id, revision_work.host_id, enabled);
if (!enabled)
@@ -365,96 +516,28 @@ protected override void Notify (DBWork work, DBRevisionWork revision_work, List<
message = message.Replace ("{red}", "\u00034").Replace ("{bold}", "\u0002").Replace ("{default}", "\u000F");
+ if (!identity.join_channels) {
+ state = Connect ();
+ if (!state.WaitForConnected (TimeSpan.FromSeconds (30))) {
+ Logger.Log ("IrcNotification: could not connect to server in 30 seconds.");
+ continue;
+ }
+ } else {
+ state = joined_state;
+ }
foreach (var nick in person.irc_nicknames.Split (',')) {
- foreach (var channel in irc.GetChannels ()) {
- irc.SendMessage (SendType.Message, channel, nick + ": " + message);
+ foreach (var channel in channels) {
+ state.Client.SendMessage (SendType.Message, channel, nick + ": " + message);
}
}
- }
- }
-
- private void Loop ()
- {
- try {
- string [] servers;
- string [] channels;
- string [] nicks;
-
- servers = identity.servers.Split (',', ' ');
- channels = identity.channels.Split (',', ' ');
- nicks = identity.nicks.Split (',', ' ');
-
- irc.AutoRetry = true;
- irc.ActiveChannelSyncing = true;
- irc.SendDelay = 200;
-
- irc.OnAutoConnectError += new AutoConnectErrorEventHandler (irc_OnAutoConnectError);
- irc.OnQueryMessage += new IrcEventHandler (irc_OnQueryMessage);
- irc.OnConnected += new EventHandler (irc_OnConnected);
- irc.OnDisconnected += new EventHandler (irc_OnDisconnected);
- irc.OnRawMessage += new IrcEventHandler (irc_OnRawMessage);
- irc.Connect (servers, 6667);
- irc.Login (nicks, "MonkeyWrench");
- irc.RfcJoin (channels);
- Logger.Log ("Connected to irc: {0} joined {1} as {2}", identity.servers, identity.channels, identity.nicks);
- irc.Listen ();
- } catch (Exception ex) {
- Logger.Log ("Exception while connecting to irc: {0}", ex.Message);
- }
-
- }
-
- void irc_OnRawMessage (object sender, IrcEventArgs e)
- {
- switch (e.Data.Type) {
- case ReceiveType.ChannelMessage:
- if (e.Data.Message.StartsWith (irc.Nickname)) {
- string cmd = e.Data.Message.Substring (irc.Nickname.Length).TrimStart (':', ' ', ',');
- switch (cmd.ToLowerInvariant ()) {
- case "enable":
- enabled = true;
- break;
- case "disable":
- enabled = false;
- break;
- case "state":
- irc.SendMessage (SendType.Message, e.Data.Channel, e.Data.Nick + ": " + (enabled ? "enabled" : "disabled"));
- break;
- case "help":
- case "h":
- case "?":
- case "/?":
- case "-?":
- irc.SendMessage (SendType.Message, e.Data.Channel, e.Data.Nick + ": enable|disable: enable or disable irc notifications temporarily.");
- break;
- default:
- irc.SendMessage (SendType.Message, e.Data.Channel, e.Data.Nick + ": Don't know how to '" + cmd + "'");
+ if (!identity.join_channels) {
+ while (!state.WaitForEmptySendBuffer (TimeSpan.FromSeconds (30))) {
+ Logger.Log ("IrcNotification: waited for 30 seconds for messages to be sent, disconnecting now");
break;
}
+ Disconnect ();
}
- break;
}
- Console.WriteLine ("OnRawMessage");
- }
-
- void irc_OnQueryMessage (object sender, IrcEventArgs e)
- {
- Console.WriteLine ("OnQueryMessage");
- }
-
- void irc_OnAutoConnectError (object sender, AutoConnectErrorEventArgs e)
- {
- Console.WriteLine ("irc_OnAutoConnectError");
- }
-
- void irc_OnDisconnected (object sender, EventArgs e)
- {
- Console.WriteLine ("irc_OnDisconnected");
- }
-
- void irc_OnConnected (object sender, EventArgs e)
- {
- Console.WriteLine ("irc_OnConnected");
}
}
View
2  MonkeyWrench.sln
@@ -19,7 +19,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonkeyWrench.Database.Manag
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonkeyWrench.Test", "MonkeyWrench.Test\MonkeyWrench.Test.csproj", "{3737EDC2-5785-424C-92BC-7013B931AF21}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SmartIrc4net", "SmartIrc4net\SmartIrc4net-0.4.0-src\VisualStudio\2010\SmartIrc4net.csproj", "{19607F57-B521-4477-9DE0-F0D9B1A68BC7}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SmartIrc4net", "SmartIrc4net\smartirc4net-0.4.5.1\SmartIrc4net.csproj", "{19607F57-B521-4477-9DE0-F0D9B1A68BC7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
View
4 SmartIrc4net/Makefile
@@ -1,4 +1,4 @@
-DIR = SmartIrc4net-0.4.0-src
+DIR = SmartIrc4net-0.4.5.1
SOURCES = \
$(wildcard $(DIR)/src/*.cs) \
$(wildcard $(DIR)/src/*/*.cs)
@@ -11,7 +11,7 @@ OUT = $(OUT_DIR)/$(LIBRARY)
$(OUT): $(SOURCES) $(BUILDABLE_REFS)
@echo " GMCS $(LIBRARY)"
- @gmcs -target:library -debug:full -out:$@ $(SOURCES) -warn:0
+ @gmcs -target:library -debug:full -out:$@ $(SOURCES) -warn:0 -D:NET_2_0
all: $(OUT)
View
4 SmartIrc4net/SmartIrc4net-0.4.5.1/SmartIrc4net.csproj
@@ -93,10 +93,6 @@
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
- <Reference Include="log4net, Version=1.2.0.30714, Culture=neutral">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\bin\log4net.dll</HintPath>
- </Reference>
<Reference Include="System">
<Name>System</Name>
</Reference>
View
11 SmartIrc4net/SmartIrc4net-0.4.5.1/src/IrcConnection/IrcConnection.cs
@@ -262,6 +262,17 @@ public class IrcConnection
}
}
+ public bool IsSendBufferEmpty {
+ get {
+ return (((Queue) _SendBuffer [Priority.AboveMedium]).Count +
+ ((Queue) _SendBuffer [Priority.BelowMedium]).Count +
+ ((Queue) _SendBuffer [Priority.Critical]).Count +
+ ((Queue) _SendBuffer [Priority.High]).Count +
+ ((Queue) _SendBuffer [Priority.Low]).Count +
+ ((Queue) _SendBuffer [Priority.Medium]).Count) == 0;
+ }
+ }
+
/// <summary>
/// Gets the SmartIrc4net version number
/// </summary>
View
6 scripts/database.sql
@@ -320,9 +320,15 @@ CREATE TABLE IrcIdentity (
id serial PRIMARY KEY,
name text NOT NULL DEFAULT '',
servers text NOT NULL DEFAULT '', -- a comma separated list of irc servers.
+ password text NOT NULL DEFAULT '', -- the password for the irc server
channels text NOT NULL DEFAULT '', -- a comma separated list of irc channels to join.
nicks text NOT NULL DEFAULT 'monkeywrench' -- a comma separated list of irc nicks to use
+ use_ssl boolean NOT NULL DEFAULT FALSE, -- if the server requires ssl
+ join_channels boolean NOT NULL DEFAULT TRUE, -- if the channel(s) should be joined, or just /msg'ed
);
+-- alter table ircidentity add column use_ssl boolean not null default false;
+-- alter table ircidentity add column join_channels boolean not null default true;
+-- alter table ircidentity add column password text not null default '';
CREATE TABLE EmailIdentity (
id serial PRIMARY KEY,
Please sign in to comment.
Something went wrong with that request. Please try again.