[Plus Emulator] Add Wordfilter

MasterJiq

Member
Jul 8, 2016
385
23
Hello,

I would to release my second one command edit with Plus Emulator, just playing around with it.
So here is the code, it would be 'AddWordfilter.cs' or whatever do you want.
Code:
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

using Plus.Communication.Packets.Outgoing.Catalog;
using Plus.Core;
using Plus.Database.Interfaces;
using Plus.Communication.Packets.Outgoing.Notifications;
using Plus.HabboHotel.GameClients;
namespace Plus.HabboHotel.Rooms.Chat.Commands.Moderator
{
    class AddWordFilter: IChatCommand
    {
        public string PermissionRequired
        {
            get { return "command_update"; }
        }

        public string Parameters
        {
            get { return "%variable%"; }
        }

        public string Description
        {
            get { return "Add a restricted word"; }
        }

        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            if (!Session.GetHabbo().GetPermissions().HasCommand("command_update"))
            {
                Session.SendWhisper("Oops, you do not have the permission.");
            }
            if (Params.Length == 1)
            {
                Session.SendWhisper("Put the word to be blacklist.");
                return;
            }
            string word = Params[1];
            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("INSERT INTO `wordfilter` (word, replacement, strict, addedby, bannable) VALUES (@word, @replace, '1', @username, '0');");
                dbClient.AddParameter("word", word);
                dbClient.AddParameter("replace", "censored");
                dbClient.AddParameter("username", Session.GetHabbo().Username);
                dbClient.RunQuery();
                Session.SendWhisper("Added the word, please use :update filter to make the system worked.");
            }
        }
    }
}

Thanks.
 

SOUL

┼ ┼ ┼
Nov 10, 2015
224
45
Hello,

I would to release my second one command edit with Plus Emulator, just playing around with it.
So here is the code, it would be 'AddWordfilter.cs' or whatever do you want.
Code:
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

using Plus.Communication.Packets.Outgoing.Catalog;
using Plus.Core;
using Plus.Database.Interfaces;
using Plus.Communication.Packets.Outgoing.Notifications;
using Plus.HabboHotel.GameClients;
namespace Plus.HabboHotel.Rooms.Chat.Commands.Moderator
{
    class AddWordFilter: IChatCommand
    {
        public string PermissionRequired
        {
            get { return "command_update"; }
        }

        public string Parameters
        {
            get { return "%variable%"; }
        }

        public string Description
        {
            get { return "Add a restricted word"; }
        }

        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            if (!Session.GetHabbo().GetPermissions().HasCommand("command_update"))
            {
                Session.SendWhisper("Oops, you do not have the permission.");
            }
            if (Params.Length == 1)
            {
                Session.SendWhisper("Put the word to be blacklist.");
                return;
            }
            string word = Params[1];
            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("INSERT INTO `wordfilter` (word, replacement, strict, addedby, bannable) VALUES (@word, @replace, '1', @username, '0');");
                dbClient.AddParameter("word", word);
                dbClient.AddParameter("replace", "censored");
                dbClient.AddParameter("username", Session.GetHabbo().Username);
                dbClient.RunQuery();
                Session.SendWhisper("Added the word, please use :update filter to make the system worked.");
            }
        }
    }
}

Thanks.

Whats with variable and update?

And why is there a check to see if the user has permission when you set the subscription id in the db?
 
May 1, 2015
470
154
Decent for your second command.
No need to add the word variable, and why not just reset the filter so it can all be done in one command:
Code:
 dbClient.SetQuery("INSERT INTO `wordfilter` (word, replacement, strict, addedby, bannable) VALUES (@word, @replace, '1', @username, '0');");
 dbClient.AddParameter("word", Params[1]);
 dbClient.AddParameter("replace", "censored");
 dbClient.AddParameter("username", Session.GetHabbo().Username);
 PlusEnvironment.GetGame().GetChatManager().GetFilter().Init(); // reset filter
 dbClient.RunQuery();
No need for the permission check either, that's what the permissions table is for :up:
Good release nonetheless.
 

Users who are viewing this thread

Top