summaryrefslogtreecommitdiff
path: root/plugins/rt.py
diff options
context:
space:
mode:
authorLivio Recchia <recchialivio@libero.it>2020-05-16 20:37:31 +0200
committerLivio Recchia <recchialivio@libero.it>2020-05-16 20:37:31 +0200
commitb1723c304ebe82ac00c674efd86dbe4a7c3f3300 (patch)
treef4096994a2dd86a9971b749cf1574795f56d38c5 /plugins/rt.py
parent49c13ccc556405915d7870ffb049b0b3dabf06ea (diff)
downloadmanachat-b1723c304ebe82ac00c674efd86dbe4a7c3f3300.tar.gz
manachat-b1723c304ebe82ac00c674efd86dbe4a7c3f3300.tar.bz2
manachat-b1723c304ebe82ac00c674efd86dbe4a7c3f3300.tar.xz
manachat-b1723c304ebe82ac00c674efd86dbe4a7c3f3300.zip
Update
Diffstat (limited to 'plugins/rt.py')
-rw-r--r--plugins/rt.py67
1 files changed, 67 insertions, 0 deletions
diff --git a/plugins/rt.py b/plugins/rt.py
new file mode 100644
index 0000000..600f6d5
--- /dev/null
+++ b/plugins/rt.py
@@ -0,0 +1,67 @@
+import time
+import net.mapserv as mapserv
+import net.charserv as charserv
+import net.stats as stats
+import commands
+import logicmanager
+import status
+import plugins
+import itemdb
+# ~ import random
+from collections import deque
+from net.inventory import get_item_index, get_storage_index
+from utils import extends
+from actor import find_nearest_being
+from chat import send_whisper as whisper
+
+from net.onlineusers import OnlineUsers
+
+__all__ = [ 'PLUGIN', 'init' ]
+
+PLUGIN = {
+ 'name': 'randomthings',
+ 'requires': ['chatbot'],
+ 'blocks': (),
+}
+
+#FIXME This must be in a library
+
+def preloadArray(nfile):
+ try:
+ file = open(nfile, "r")
+ array=[]
+ 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")
+
+def palDetect(nick, message, is_whisper, match):
+ outmsg = '' # We cannot use print nor whisper faster too many times (bad, ban!) so we have to "assemble" a single message to send
+ for element in message.split(' '): # Not 100% perfect since !<command> got included too
+ palindrome=0
+ i=0
+ # while I'm pointing at the element before the middle and that one is equal to the last one less it's position
+ while i < len(element)/2 and element[i]==element[len(element)-1-i]:
+ palindrome+=1
+ i+=1
+ # A palindrome has same number of occurrences as the amount of half the letters (usually when even in length)
+ if palindrome==len(element)/2:
+ #print element + " is a palindrome"
+ outmsg += element + " "
+ whisper(nick, outmsg) # We cannot use print since it will print messages on terminal not on whisper
+ time.sleep(3)
+
+rt_commands = {
+ '!pal (.*)' : palDetect,
+}
+
+def init(config):
+
+ for cmd, action in rt_commands.items():
+ plugins.chatbot.add_command(cmd, action)