From 8d97382f5eae70938dbeb490679114c8b85e5991 Mon Sep 17 00:00:00 2001 From: HoraK-FDF Date: Fri, 4 Mar 2022 13:34:46 +0100 Subject: chat ignore and some fixes --- chat.py | 13 ++++++++++++- config/chat_beings_ignored.nfo | 1 + config/chat_wisper_ignored.nfo | 2 ++ plugins/shop.py | 18 +----------------- utils.py | 13 +++++++++++++ 5 files changed, 29 insertions(+), 18 deletions(-) create mode 100644 config/chat_beings_ignored.nfo create mode 100644 config/chat_wisper_ignored.nfo diff --git a/chat.py b/chat.py index 5fecb51..73a4ae4 100755 --- a/chat.py +++ b/chat.py @@ -3,7 +3,7 @@ from collections import deque import net.mapserv as mapserv import badge from loggers import debuglog -from utils import extends +from utils import extends, preloadArray from textutils import preprocess as pp from textutils import (simplify_links, remove_formatting, replace_emotes) @@ -15,6 +15,8 @@ afk_message = '*AFK* I am away from keyboard' afk_ts = 0 chat_bots = ["guild", "_IRC_"] +chat_beings_ignored = preloadArray("config/chat_beings_ignored.txt") +chat_wisper_ignored = preloadArray("config/chat_wisper_ignored.txt") def send_whisper(nick, message): badge.is_afk = False @@ -48,6 +50,11 @@ def send_whisper_result(data): @extends('smsg_being_chat') def being_chat(data): + if '*' in chat_beings_ignored: + return + real_name, _ = data.message.split(' : ', 1) + if real_name in chat_beings_ignored: + return message = pp(data.message, pp_actions) debuglog.info(message) @@ -61,6 +68,10 @@ def player_chat(data): @extends('smsg_whisper') def got_whisper(data): nick, message = data.nick, data.message + if '*' in chat_wisper_ignored: + return + if nick in chat_wisper_ignored: + return message = pp(message, pp_actions) m = "[{} ->] {}".format(nick, message) debuglog.info(m) diff --git a/config/chat_beings_ignored.nfo b/config/chat_beings_ignored.nfo new file mode 100644 index 0000000..8a161ca --- /dev/null +++ b/config/chat_beings_ignored.nfo @@ -0,0 +1 @@ +Characters that chat in visible range and are specified in this file will be ignored a * will ignore all. diff --git a/config/chat_wisper_ignored.nfo b/config/chat_wisper_ignored.nfo new file mode 100644 index 0000000..377a268 --- /dev/null +++ b/config/chat_wisper_ignored.nfo @@ -0,0 +1,2 @@ +Characters that wisper the bot and are specified in this file will be ignored a * will ignore all. +For the guildbot put guild in this file. diff --git a/plugins/shop.py b/plugins/shop.py index 7e0f5f1..5e3bf24 100755 --- a/plugins/shop.py +++ b/plugins/shop.py @@ -10,12 +10,11 @@ import badge import random from net.inventory import get_item_index from net.trade import reset_trade_state -from utils import encode_str, extends +from utils import encode_str, extends, preloadArray from itemdb import item_name from playerlist import PlayerList from chat import send_whisper as whisper - __all__ = [ 'PLUGIN', 'init', 'shoplog', 'buying', 'selling' ] nobuy = [] @@ -34,21 +33,6 @@ shoplog = logging.getLogger('ManaChat.Shop') trade_timeout = 60 shop_admins = None -# Commented due to player abusing trade commands too many times per minute -# FIXME Put on a specified library -def preloadArray(nfile): - try: - array=[] - file = open(nfile, "r") - for x in file.readlines(): - x = x.replace("\n", "") - x = x.replace("\r", "") - array.append(x) - file.close() - return array - except: - print "preloadArray: File " + nfile + " not found!" - ignored_players = preloadArray("config/ignored.txt") # ~ sell_greetings = [ diff --git a/utils.py b/utils.py index 0416a90..f05ece5 100755 --- a/utils.py +++ b/utils.py @@ -148,3 +148,16 @@ def encode_str(value, size): output += chr(start) return output + +def preloadArray(nfile): + try: + array=[] + file = open(nfile, "r") + for x in file.readlines(): + x = x.replace("\n", "") + x = x.replace("\r", "") + array.append(x) + file.close() + return array + except: + print "preloadArray: File " + nfile + " not found!" -- cgit v1.2.3-70-g09d2 From d60a13c21c5a2d22e7090dce6ecd74db5038f7d8 Mon Sep 17 00:00:00 2001 From: HoraK-FDF Date: Fri, 4 Mar 2022 20:26:26 +0100 Subject: added empty files --- config/chat_wisper_ignored.txt | 0 config/ignored.txt | 0 config/shopAdmins.txt | 0 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 config/chat_wisper_ignored.txt create mode 100644 config/ignored.txt create mode 100644 config/shopAdmins.txt diff --git a/config/chat_wisper_ignored.txt b/config/chat_wisper_ignored.txt new file mode 100644 index 0000000..e69de29 diff --git a/config/ignored.txt b/config/ignored.txt new file mode 100644 index 0000000..e69de29 diff --git a/config/shopAdmins.txt b/config/shopAdmins.txt new file mode 100644 index 0000000..e69de29 -- cgit v1.2.3-70-g09d2