summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHoraK-FDF <horak-fdf@web.de>2022-03-04 13:34:46 +0100
committerHoraK-FDF <horak-fdf@web.de>2022-03-04 13:34:46 +0100
commit8d97382f5eae70938dbeb490679114c8b85e5991 (patch)
treeb33d855366dd1c0a5fda926e5664a7e5e6d0ca10
parent728ba8aa6255fa2b8be2cfc759ba202a1a712504 (diff)
downloadmanachat-8d97382f5eae70938dbeb490679114c8b85e5991.tar.gz
manachat-8d97382f5eae70938dbeb490679114c8b85e5991.tar.bz2
manachat-8d97382f5eae70938dbeb490679114c8b85e5991.tar.xz
manachat-8d97382f5eae70938dbeb490679114c8b85e5991.zip
chat ignore and some fixes
-rwxr-xr-xchat.py13
-rw-r--r--config/chat_beings_ignored.nfo1
-rw-r--r--config/chat_wisper_ignored.nfo2
-rwxr-xr-xplugins/shop.py18
-rwxr-xr-xutils.py13
5 files changed, 29 insertions, 18 deletions
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!"