diff options
-rwxr-xr-x | chat.py | 13 | ||||
-rw-r--r-- | config/chat_beings_ignored.nfo | 1 | ||||
-rw-r--r-- | config/chat_wisper_ignored.nfo | 2 | ||||
-rw-r--r-- | config/chat_wisper_ignored.txt | 0 | ||||
-rw-r--r-- | config/ignored.txt | 0 | ||||
-rw-r--r-- | config/shopAdmins.txt | 0 | ||||
-rwxr-xr-x | plugins/shop.py | 18 | ||||
-rwxr-xr-x | utils.py | 13 |
8 files changed, 29 insertions, 18 deletions
@@ -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/config/chat_wisper_ignored.txt b/config/chat_wisper_ignored.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/config/chat_wisper_ignored.txt diff --git a/config/ignored.txt b/config/ignored.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/config/ignored.txt diff --git a/config/shopAdmins.txt b/config/shopAdmins.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/config/shopAdmins.txt 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 = [ @@ -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!" |