Пример #1
0
        public void Setup(string ServerName, bool LoadConfig = false)
        {
            _servername      = ServerName;
            sCalendarCommand = new CalendarCommand(ServerName);
            sBirthdayCommand = new BirthdayCommand(ServerName);
            sBanCommand      = new BanCommand(ServerName);
            sBan             = new Ban(ServerName);

            if (IRCConfig.List[ServerName].ServerId == 1 || LoadConfig)
            {
                _config = new AddonConfig(Name, ".yml");
            }

            _calendar = new Calendar(ServerName);
            _calendar.Start();

            sIrcBase.Networks[ServerName].IrcRegisterHandler("PRIVMSG", HandlePrivmsg);
            InitIrcCommand();
            SchumixBase.DManager.Update("banned", string.Format("ServerName = '{0}'", ServerName), string.Format("ServerId = '{0}'", IRCConfig.List[ServerName].ServerId));
            SchumixBase.DManager.Update("birthday", string.Format("ServerName = '{0}'", ServerName), string.Format("ServerId = '{0}'", IRCConfig.List[ServerName].ServerId));
            SchumixBase.DManager.Update("calendar", string.Format("ServerName = '{0}'", ServerName), string.Format("ServerId = '{0}'", IRCConfig.List[ServerName].ServerId));

            if (CleanConfig.Database)
            {
                SchumixBase.sCleanManager.CDatabase.CleanTable("banned");
                SchumixBase.sCleanManager.CDatabase.CleanTable("birthday");
                SchumixBase.sCleanManager.CDatabase.CleanTable("calendar");
            }
        }
Пример #2
0
        public override void Initialize()
        {
            _announcementChannel = GetConfigCache("AnnouncementChannel", x => x.GetGuild().TextChannels.FirstOrDefault(y => y.Name == "general" || y.Name == "main" || y.Name == "chat").ZeroIfNull());
            _announcementMessage = GetConfigCache("AnnouncementMessage", x => "Congratulations to **[USERNAME]** as today they celebrate their [AGE] birthday!");

            // TODO: Implement some basic error handling, such as what happens if you provide it with a non-existing channel.
            AddConfigInfo("Set Birthday Channel", "Set announcement channel.", new Action <string>(x => _announcementChannel.SetValue(GuildHandler.FindTextChannel(x).Id)), () => $"Channel channel set to {GuildHandler.GetTextChannel(_announcementChannel.GetValue()).Mention}.", "Channel Name");
            AddConfigInfo("Set Birthday Channel", "Set announcement channel.", new Action <ulong>(x => _announcementChannel.SetValue(x)), () => $"Channel channel set to {GuildHandler.GetTextChannel(_announcementChannel.GetValue()).Mention}.", "Channel Id");
            AddConfigInfo("Set Birthday Channel", "Set announcement channel.", new Action <SocketTextChannel>(x => _announcementChannel.SetValue(x.Id)), () => $"Channel channel set to {GuildHandler.GetTextChannel(_announcementChannel.GetValue()).Mention}.", "Channel");
            AddConfigInfo("Set Birthday Channel", "Get announcement channel.", () => $"Current announcement channel is {GuildHandler.GetTextChannel(_announcementChannel.GetValue()).Mention}.");

            AddConfigInfo("Set Birthday Message", "Set birthday message.", new Action <string>(x => _announcementMessage.SetValue(x)), () => $"New announcement message: '{_announcementMessage.GetValue()}'.", "Message");
            AddConfigInfo("Set Birthday Message", "Get birthday message.", () => $"Current announcement message: '{_announcementMessage.GetValue()}'.");

            _command = new BirthdayCommand()
            {
                ParentPlugin = this
            };
            _allBirthdays = GetDataCache("Birthdays", x => new Dictionary <ulong, BirthdayDate>());

            GuildHandler.Clock.OnHourPassed += Clock_OnHourPassed;

            SendMessage("Lomztein-CommandRoot", "AddCommand", _command);
        }
Пример #3
0
        public override void Initialize()
        {
            _announcementChannel = GetConfigCache("AnnouncementChannel", x => x.GetGuild().TextChannels.FirstOrDefault(y => y.Name == "general" || y.Name == "main" || y.Name == "chat").ZeroIfNull());
            _announcementMessage = GetConfigCache("AnnouncementMessage", x => "Congratulations to **[USERNAME]** as today they celebrate their [AGE] birthday!");

            AddConfigInfo <string>("Set Birthday Channel", "Set announcement channel.", x => _announcementChannel.SetValue(GuildHandler.GetVoiceChannel(x).Id), x => $"Channel channel set to {GuildHandler.GetTextChannel(x).Mention}.", "Channel Name");
            AddConfigInfo <ulong>("Set Birthday Channel", "Set announcement channel.", x => _announcementChannel.SetValue(GuildHandler.GetVoiceChannel(x).Id), x => $"Channel channel set to {GuildHandler.GetTextChannel(x).Mention}.", "Channel Id");
            AddConfigInfo <SocketTextChannel>("Set Birthday Channel", "Set announcement channel.", x => _announcementChannel.SetValue(x.Id), x => $"Channel channel set to {x.Name}", "Channel");
            AddConfigInfo("Set Birthday Channel", "Get announcement channel.", () => $"Current announcement channel is {GuildHandler.GetTextChannel(_announcementChannel.GetValue()).Mention}.");

            AddConfigInfo <string>("Set Birthday Message", "Set birthday message.", x => _announcementMessage.SetValue(x), x => $"New announcement message: '{x}'.", "Message");
            AddConfigInfo("Set Birthday Message", "Get birthday message.", () => $"Current announcement message: '{_announcementMessage.GetValue()}'.");

            _command = new BirthdayCommand {
                ParentPlugin = this
            };
            _allBirthdays = GetDataCache("Birthdays", x => new Dictionary <ulong, BirthdayDate>());

            GuildHandler.Clock.OnHourPassed += Clock_OnHourPassed;

            SendMessage("Moduthulhu-Command Root", "AddCommand", _command);

            AddGeneralFeaturesStateAttribute("BirthdayGreetings", "Automatic birthday wishing if desired.");
        }