summaryrefslogtreecommitdiff
path: root/plugins/manaboy.py
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/manaboy.py')
-rwxr-xr-x[-rw-r--r--]plugins/manaboy.py121
1 files changed, 86 insertions, 35 deletions
diff --git a/plugins/manaboy.py b/plugins/manaboy.py
index 127ddd0..c5480b6 100644..100755
--- a/plugins/manaboy.py
+++ b/plugins/manaboy.py
@@ -39,6 +39,35 @@ disliked_players = preloadArray("bot/disliked.txt")
admins = preloadArray("bot/admins.txt")
friends = preloadArray("bot/friends.txt")
+# ====================== XECUTE =============
+
+def XECUTE(nick, is_whisper, command, args=""):
+ try:
+ import subprocess
+ if args=="":
+ s = subprocess.check_output([command])
+ else:
+ s = subprocess.check_output([command, args])
+ except:
+ s=("Damn! " +match.group(1)+" + has failed!").strip()
+ if is_whisper:
+ whisper(nick,(s))
+ else:
+ mapserv.cmsg_chat_message(s)
+
+# ====================== XCAL =============
+
+def XCAL(nick, message, is_whisper, match):
+ if nick in ignored_players:
+ return
+ XECUTE(nick, is_whisper, "/home/livio/Nextcloud/mcu/prj/test_cparse/a.out",match.group(1))
+
+# === eXecute on Unix ===========
+
+def XUfortune(nick, message, is_whisper, match): XECUTE(nick, is_whisper, "fortune", "-s")
+def XUdate(nick, message, is_whisper, match): XECUTE(nick, is_whisper, "/bin/date")
+def XUpom(nick, message, is_whisper, match): XECUTE(nick, is_whisper, "/usr/games/pom")
+
# ====================== XCOM =============
XCOMList = preloadArray("bot/XCOM.txt")
XCOMServerStatInterested = [] #List of nicks interested in server status change
@@ -147,16 +176,37 @@ def XCOMInvite(nick, message, is_whisper, match):
return
if nick in ignored_players:
return #or say something
- if nick in admins:
+ if nick in admins: # FIXME Do not add if already there!!!
XCOMList.append(match.group(1))
XCOMBroadcast("##W--- " + nick + " (Admin) invited " + match.group(1) + " on XCOM ---" + XCOMBroadcastPrefix + match.group(1) + " XCOM enabled! Use !xcoff to disable, use !xclist to see XCOM online list")
else:
if nick in ignored_players:
whisper(nick, "You cannot invite banned players.")
else:
- whisper(match.group(1), "##W--- " + nick + " invited you on XCOM --- Answer !xcon to join.")
+ whisper(match.group(1), "##W--- " + nick + " invited you to chat on XCOM --- Answer !xcon to join.")
XCOMDelay()
- whisper(nick, "Invited " + match.group(1) + " to join XCOM. Waiting for his/her reply...")
+ whisper(nick, "Invited " + match.group(1) + " to join XCOM. Waiting for his/her reply...")
+
+XCOMServerInvited = []
+def XCOMInviteAll(nick, message, is_whisper, match):
+ XCOMDelay()
+ if not is_whisper:
+ return
+ if nick in ignored_players:
+ return #or say something
+ if nick in admins: # FIXME Do not add if already there!!!
+ for invn in online_users.online_users:
+ if invn in XCOMList:
+ pass
+ elif invn in ignored_players:
+ pass
+ elif invn in XCOMServerInvited:
+ pass
+ else:
+ XCOMServerInvited.append(invn)
+ whisper(invn, "##W--- " + nick + " invited you to chat on XCOM --- Answer !xcon to join.")
+ XCOMDelay()
+
def XCOMEnable(nick, message, is_whisper, match):
XCOMDelay()
@@ -247,22 +297,22 @@ def XCOMUnBan(nick, message, is_whisper, match):
# =============================================
-greetings = {
- "Hi {0}!" : 4,
- "Hey {0}" : 3,
- "Yo {0}" : 2,
- "{0}!!!!" : 1,
- "{0}!!!" : 1,
- "{0}!!" : 1,
- "Hello {0}!!!" : 5,
- "Hello {0}!" : 5,
- "Welcome back {0}!" : 3,
- "Hello {0}! You are looking lovely today!" : 1,
- "Hello {0}! I'm the bot that you can trust: I want your money!" : 1,
- "{0} is back!!" : 1,
+greetings = [
+ "Hi {0}!",
+ "Hey {0}",
+ "Yo {0}",
+ "{0}!!!!",
+ "{0}!!!",
+ "{0}!!",
+ "Hello {0}!!!",
+ "Hello {0}!",
+ "Welcome back {0}!",
+ "Hello {0}! You are looking lovely today!",
+ "Hello {0}! I'm the bot that you can trust: I want your money!",
+ "{0} is back!!",
"Hello and welcome to the Aperture Science \
-computer-aided enrichment center." : 1,
-}
+computer-aided enrichment center.",
+]
drop_items = [
"a bomb", "a bowl of petunias", "a cake", "a candy", "a chocobo",
@@ -397,7 +447,8 @@ dislikebye_answers = [
"Go away!!!",
"Don't come back!",
"Whew...",
- "I need another drink…"
+ "I need another drink…",
+ "*picking my nose*"
]
attack_answers = [
@@ -418,6 +469,7 @@ attack_answers = [
"I will burn you down.",
"The show begins...",
"I'm better than makeup artists, prepare yourself!!!",
+ "Yeah! A challenge!",
]
notattack_answers = [
@@ -440,6 +492,7 @@ story_action_fail = [
"stomped on the soul menhir",
"slipped on a terranite ore",
"got interrupted by phone call",
+ "got disconnected",
]
# FIXME Unused
@@ -453,28 +506,19 @@ story_actions = [
# -----------------------------------------------------------------------------
def say_greeting(nick, _, is_whisper, match):
+ if nick == "Liviobot" :
+ return
if is_whisper:
return
if nick in ignored_players:
return
- total_weight = 0
- for w in greetings.itervalues():
- total_weight += w
-
- random_weight = random.randint(0, total_weight)
- total_weight = 0
- random_greeting = 'Hi {0}'
- for g, w in greetings.iteritems():
- if total_weight >= random_weight:
- random_greeting = g
- break
- total_weight += w
if nick in disliked_players:
mapserv.cmsg_chat_message(random.choice(dislike_answers))
else:
- mapserv.cmsg_chat_message(random_greeting.format(nick))
+ answer = random.choice(greetings)
+ mapserv.cmsg_chat_message(answer.format(nick))
time.sleep(1)
def say_goodbye(nick, _, is_whisper, match):
@@ -485,13 +529,13 @@ def say_goodbye(nick, _, is_whisper, match):
return
total_weight = 0
- for w in greetings.itervalues():
+ for w in bye_answers.itervalues():
total_weight += w
random_weight = random.randint(0, total_weight)
total_weight = 0
random_greeting = 'Hi {0}'
- for g, w in greetings.iteritems():
+ for g, w in bye_answers.iteritems():
if total_weight >= random_weight:
random_greeting = g
break
@@ -970,7 +1014,7 @@ def cmd_say(nick, message, is_whisper, match):
return
if nick not in admins:
return
- set_npc_owner(nick)
+ # ~ set_npc_owner(nick)
msg = message.group(1)
mapserv.cmsg_chat_message(msg)
@@ -1337,18 +1381,25 @@ manaboy_commands = {
'!history' : cmd_history,
'!bug (.+)' : cmd_report_bug,
'!bugs' : cmd_check_bugs,
+
+ '!xcal (.*)' : XCAL,
+ '!xuf': XUfortune,
+ '!xudate': XUdate,
+ '!xupom': XUpom,
'!xcon' : XCOMEnable,
'!xcom' : XCOMEnable,
'!xcoff' : XCOMDisable,
'!xcom off' : XCOMDisable,
'!xclist' : XCOMOnlineList,
'!xci (.*)' : XCOMInvite,
+ '!xcia' : XCOMInviteAll,
'!xcsi (.*)' : XCOMSilentInvite,
'!xcb (.*)' : XCOMBan,
'!xcu (.*)' : XCOMUnBan,
'!xcsion' : XCOMServerInterestEnable,
'!xcsioff' : XCOMServerInterestDisable,
r'(.*)' : XCOMCommunicate,
+
r'^(?i)explain (.*)': say_explain,
r'^(?i)(hello|hi|hey|heya|hiya|yo) (?i)(livio|liviobot)' : say_greeting,
r'^(?i)(hello|hi|hey|heya|hiya) (?i)(all|everybody|everyone)(.*)' : say_greeting,