Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Property changes on: .
- ___________________________________________________________________
- Modified: svn:ignore
- - obj
- WCell.IRCAddon.suo
- + obj
- WCell.IRCAddon.suo
- IRCAddon.4.1.resharper.user
- IRCAddon.suo
- _ReSharper.IRCAddon
- Index: ChannelInfo.cs
- ===================================================================
- --- ChannelInfo.cs (revision 0)
- +++ ChannelInfo.cs (revision 0)
- @@ -0,0 +1,13 @@
- +using System;
- +using System.Collections.Generic;
- +using System.Linq;
- +using System.Text;
- +
- +namespace IRCAddon
- +{
- + public class ChannelInfo
- + {
- + public string ChannelName;
- + public string Password;
- + }
- +}
- Index: IRCAddon.csproj
- ===================================================================
- --- IRCAddon.csproj (revision 46)
- +++ IRCAddon.csproj (working copy)
- @@ -3,7 +3,7 @@
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- - <ProductVersion>9.0.30729</ProductVersion>
- + <ProductVersion>9.0.21022</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{E8F36B44-3596-42A5-9380-4386CF04EDD6}</ProjectGuid>
- <OutputType>Library</OutputType>
- @@ -64,6 +64,7 @@
- -->
- <ItemGroup>
- <Compile Include="AccountAssociationsList.cs" />
- + <Compile Include="ChannelInfo.cs" />
- <Compile Include="Commands\AccountAssociationsCommand.cs" />
- <Compile Include="Commands\IrcCommands.cs" />
- <Compile Include="Commands\RealmServerCommands.cs" />
- Index: IrcAddonConfig.cs
- ===================================================================
- --- IrcAddonConfig.cs (revision 46)
- +++ IrcAddonConfig.cs (working copy)
- @@ -1,39 +1,65 @@
- using System.Collections.Generic;
- using Squishy.Irc;
- using WCell.RealmServer;
- +using WCell.Util.Variables;
- +using System;
- namespace IRCAddon
- {
- - public class IrcAddonConfig
- - {
- - public static string[] ChannelList = {"#ChannelName,ChannelKey"};
- - // Note: All the channels you want the client to connect to, key being the channel's key.
- - // Note: If the key is empty (""), it will presume there is no key and connect normally
- - // Note: Example 1) "#WCell," (will join the channel #WCell without a key)
- - // NOTE: Example 2) "#WCell,password12" (will join the channel #WCell with the key "password12" (no spaces)
- - /// <summary>
- - /// Channels you want to keep updated according to the latest server status
- - /// Broadcasts are also posted in these channels.
- - /// </summary>
- - public static string[] UpdatedChannels = {"#ChannelName"};
- + public class IrcAddonConfig
- + {
- + public static string[] ChannelList = { "#ChannelName,ChannelKey" };
- + // Note: All the channels you want the client to connect to, key being the channel's key.
- + // Note: If the key is empty (""), it will presume there is no key and connect normally
- + // Note: Example 1) "#WCell," (will join the channel #WCell without a key)
- + // NOTE: Example 2) "#WCell,password12" (will join the channel #WCell with the key "password12" (no spaces)
- - public static string[] ExceptionChan = {"#ExceptionChannel,ChannelKey"};
- - public static string Info = "ChangeMe";
- - public static string Network = "euroserv.fr.quakenet.org"; //The network the client will connect to.
- - public static string[] Nicks = new[] { RealmServerConfiguration.RealmName, RealmServerConfiguration.RealmName + "2", RealmServerConfiguration.RealmName + "3"}; //The nicks the client will try and use.
- - public static int Port = 6667; //The port the client will connect to.
- + private static string[] updatedChannelNames = { "#ChannelName" };
- - public static Privilege RequiredStaffPriv = Privilege.HalfOp;
- - public static string UserName = "Mokbot";
- + /// <summary>
- + /// Channels you want to keep updated according to the latest server status
- + /// Broadcasts are also posted in these channels.
- + /// </summary>
- + [Variable("UpdatedChannels")]
- + public static string[] UpdatedChannelNames
- + {
- + get { return updatedChannelNames; }
- + set
- + {
- + updatedChannelNames = value;
- + UpdatedChannels = new ChannelInfo[value.Length];
- + for (var i = 0; i < value.Length; i++)
- + {
- + var chan = value[i].Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
- - public static bool PerformOnConnect = true;
- - public static string[] PerformMethods = {"!msg #asda Just testing Perform"};
- + UpdatedChannels[i] = new ChannelInfo
- + {
- + ChannelName = chan[0].Trim(),
- + Password = chan.Length > 1 ? chan[1] : ""
- + };
- + }
- + }
- + }
- - public static bool CallOnChannelJoin = true;
- + public static ChannelInfo[] UpdatedChannels = new ChannelInfo[0];
- - public static string[] CallOnJoin = {
- + public static string[] ExceptionChan = { "#ExceptionChannel,ChannelKey" };
- + public static string Info = "ChangeMe";
- + public static string Network = "euroserv.fr.quakenet.org"; //The network the client will connect to.
- + public static string[] Nicks = new[] { RealmServerConfiguration.RealmName, RealmServerConfiguration.RealmName + "2", RealmServerConfiguration.RealmName + "3" }; //The nicks the client will try and use.
- + public static int Port = 6667; //The port the client will connect to.
- +
- + public static Privilege RequiredStaffPriv = Privilege.HalfOp;
- + public static string UserName = "Mokbot";
- +
- + public static bool PerformOnConnect = true;
- + public static string[] PerformMethods = { "!msg #asda Just testing Perform" };
- +
- + public static bool CallOnChannelJoin = true;
- +
- + public static string[] CallOnJoin = {
- "#asda:!someCommand;!AnotherCommand arg1 arg2;#WCellCommand arg1 arg2",
- "#chan2:!someCommand;!AnotherCommand arg1 arg2;#WCellCommand arg1 arg2"
- };
- - }
- + }
- }
- \ No newline at end of file
- Index: IrcConnection.cs
- ===================================================================
- --- IrcConnection.cs (revision 46)
- +++ IrcConnection.cs (working copy)
- @@ -81,30 +81,32 @@
- ProtocolHandler.PacketReceived += OnReceive;
- RealmServer.Shutdown += OnShutdown;
- RealmServer.Instance.StatusChanged += OnStatusNameChange;
- - World.Broadcasted += World_Broadcasted;
- + World.Broadcasted += OnBroadcast;
- _maintainConnTimer = new Timer(MaintainCallback);
- LogUtil.ExceptionRaised += LogUtilExceptionRaised;
- - Client.Disconnected += Client_Disconnected;
- + Client.Disconnected += OnDisconnect;
- }
- - void World_Broadcasted(IChatter sender, string message)
- + void OnBroadcast(IChatter sender, string message)
- {
- if (EchoBroadcasts)
- {
- - foreach (var chan in IrcAddonConfig.UpdatedChannels)
- + foreach (var chanInfo in IrcAddonConfig.UpdatedChannels)
- {
- + var chan = GetChannel(chanInfo.ChannelName);
- + if (chan == null) continue;
- if(sender != null)
- {
- - GetChannel(chan).Msg(sender.Name + ": " + ChatUtility.Strip(message));
- + chan.Msg(sender.Name + ": " + ChatUtility.Strip(message));
- }
- else
- {
- - GetChannel(chan).Msg(ChatUtility.Strip(message));
- + chan.Msg(ChatUtility.Strip(message));
- }
- }
- }
- }
- - void Client_Disconnected(Connection con, bool connectionLost)
- + void OnDisconnect(Connection con, bool connectionLost)
- {
- if(connectionLost && ReConnectOnDisconnect)
- {
- @@ -141,10 +143,10 @@
- WCellUtil.Init(client);
- client.BeginConnect(IrcAddonConfig.Network, IrcAddonConfig.Port);
- }
- -
- catch (Exception e)
- {
- - Console.WriteLine("Exception: {0}", e);
- + //Console.WriteLine("Exception: {0}", e);
- + LogUtil.ErrorException(e, "[IRCAddon] Unable to connect to {0}", IrcAddonConfig.Network);
- }
- }
- @@ -195,11 +197,11 @@
- // We want the bot to join each channel that the user wants updated,
- // just in case s/he forgot to put them on ChannelList
- - foreach(var chan in IrcAddonConfig.UpdatedChannels)
- + foreach(var info in IrcAddonConfig.UpdatedChannels)
- {
- - if(!Channels.Keys.Contains(chan))
- + if(!Channels.Keys.Contains(info.ChannelName))
- {
- - CommandHandler.Join(chan);
- + CommandHandler.Join(info.ChannelName, info.Password);
- }
- }
- @@ -384,33 +386,31 @@
- protected override void OnUsersAdded(IrcChannel chan, IrcUser[] users)
- {
- - Console.WriteLine("Topic was set {0} by {1}", chan.TopicSetTime, chan.TopicSetter);
- - Console.WriteLine("Topic is: {0}", chan.Topic);
- - if (IrcAddonConfig.UpdatedChannels.Length != 0)
- - {
- - foreach (var channel in IrcAddonConfig.UpdatedChannels)
- - {
- - if (chan.Name == channel)
- - {
- - UpdateTopic(chan, chan.Topic);
- - }
- - }
- - }
- - if (AutoAuth)
- - {
- - if (AuthAllUsersOnJoin)
- - foreach (var usr in users)
- - {
- - if (AnnounceAuthToUser)
- - {
- - usr.Msg("Resolving User...".Colorize(IrcColorCode.Red));
- - }
- - AuthMgr.ResolveAuth(usr);
- - }
- - }
- + Console.WriteLine("Topic was set {0} by {1}", chan.TopicSetTime, chan.TopicSetter);
- + Console.WriteLine("Topic is: {0}", chan.Topic);
- + foreach (var channel in IrcAddonConfig.UpdatedChannels)
- + {
- + if (chan.Name == channel.ChannelName)
- + {
- + UpdateTopic(chan, chan.Topic);
- + }
- + }
- +
- + if (AutoAuth)
- + {
- + if (AuthAllUsersOnJoin)
- + foreach (var usr in users)
- + {
- + if (AnnounceAuthToUser)
- + {
- + usr.Msg("Resolving User...".Colorize(IrcColorCode.Red));
- + }
- + AuthMgr.ResolveAuth(usr);
- + }
- + }
- }
- - // Try and update the topic of the channel after the bot has been privileged
- + // Try and update the topic of the channel after the bot has been privileged
- // Useful when the bot joined and wasn't privileged to change the topic and if
- // afterwards a user/network service/bot opped the bot, it will try and update the topic
- // Bear in mind this will update the status of *any* channel he is given op or higher priv
- @@ -702,20 +702,17 @@
- private void UpdateImportantChannels()
- {
- - if (IrcAddonConfig.UpdatedChannels.Length != 0)
- - {
- - foreach (var chan in IrcAddonConfig.UpdatedChannels)
- - {
- - if (_watchedChannels.Contains(chan))
- - {
- - var channel = GetChannel(chan);
- - UpdateTopic(channel, channel.Topic);
- - }
- - }
- - }
- + foreach (var chan in IrcAddonConfig.UpdatedChannels)
- + {
- + if (_watchedChannels.Contains(chan.ChannelName))
- + {
- + var channel = GetChannel(chan.ChannelName);
- + UpdateTopic(channel, channel.Topic);
- + }
- + }
- }
- - /// <summary>
- + /// <summary>
- /// Formats the channel's topic and adds server status
- /// Only used in OnTopic
- /// </summary>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement