| 1 |
# Script for say event of guild member board |
| 2 |
# |
| 3 |
# This program is free software; you can redistribute it and/or modify |
| 4 |
# it under the terms of the GNU General Public License as published by |
| 5 |
# the Free Software Foundation; either version 2 of the License, or |
| 6 |
# (at your option) any later version. |
| 7 |
# |
| 8 |
# This program is distributed in the hope that it will be useful, |
| 9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 |
# GNU General Public License for more details. |
| 12 |
# |
| 13 |
# You should have received a copy of the GNU General Public License |
| 14 |
# along with this program; if not, write to the Free Software |
| 15 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 16 |
# |
| 17 |
# authors: majorwoo josh@woosworld.net, Avion temitchell@sourceforge.net |
| 18 |
|
| 19 |
import Crossfire |
| 20 |
import CFGuilds |
| 21 |
import CFLog |
| 22 |
|
| 23 |
import sys |
| 24 |
import string |
| 25 |
|
| 26 |
activator=Crossfire.WhoIsActivator() |
| 27 |
activatorname=activator.Name |
| 28 |
whoami=Crossfire.WhoAmI() |
| 29 |
isDM=activator.IsDungeonMaster |
| 30 |
|
| 31 |
log=CFLog.CFLog() |
| 32 |
guildname=Crossfire.ScriptParameters() # 6 is say event |
| 33 |
print "Activated %s" %guildname |
| 34 |
|
| 35 |
if (guildname): |
| 36 |
guild = CFGuilds.CFGuild(guildname) |
| 37 |
guildhouse = CFGuilds.CFGuildHouses() |
| 38 |
text = string.split(Crossfire.WhatIsMessage()) |
| 39 |
|
| 40 |
if text[0] == 'help' or text[0] == 'yes': |
| 41 |
if isDM: |
| 42 |
message = '\nList of commands:\n-list\n-add <name>\n-remove <member>\n-info <member>\n-promote <member>\n-demote <member>\n-status <member> <status>\n-guildstatus <status>' |
| 43 |
else: |
| 44 |
message='\nList of commands:\n-list\n-remove <member>\n-info <member>\n-promote <member>\n-demote <member>\n-status <member> <status>' |
| 45 |
|
| 46 |
elif text[0] == 'info': |
| 47 |
if len(text)==2: |
| 48 |
record = guild.info(text[1]) |
| 49 |
if record: |
| 50 |
message = '%s' %record |
| 51 |
else: |
| 52 |
message = '%s is not a member' %text[1] |
| 53 |
else: |
| 54 |
message = 'Usage "info <member_name>"' |
| 55 |
|
| 56 |
elif text[0] == 'remove': |
| 57 |
if len(text)==2: |
| 58 |
if guild.info(text[1]): |
| 59 |
message = 'Removed %s from the guild' %text[1] |
| 60 |
#delete them |
| 61 |
guild.remove_member(text[1]) |
| 62 |
else: |
| 63 |
#if we didn't find them on the board |
| 64 |
message = '%s was not a member' %text[1] |
| 65 |
else: |
| 66 |
message = 'Usage "remove <member_name>"' |
| 67 |
|
| 68 |
elif text[0] == 'list': |
| 69 |
list = guild.list_members() |
| 70 |
for member in list: |
| 71 |
activator.Write(member) |
| 72 |
message = 'Total members = ' + str(len(list)) |
| 73 |
|
| 74 |
elif text[0] == 'promote': |
| 75 |
if len(text)==2: |
| 76 |
record = guild.info(text[1]) |
| 77 |
if record: |
| 78 |
if guild.promote_member(text[1]): |
| 79 |
record = guild.info(text[1]) #refresh record |
| 80 |
message = '%s promoted to %s' %(text[1], record['Rank']) |
| 81 |
else: |
| 82 |
message = 'You cannot promote %s' %text[1] |
| 83 |
else: |
| 84 |
message = '%s is not a member' %text[1] |
| 85 |
else: |
| 86 |
message = 'Usage "promote <member_name>"' |
| 87 |
|
| 88 |
elif text[0] == 'demote': |
| 89 |
if len(text)==2: |
| 90 |
record = guild.info(text[1]) |
| 91 |
if record: |
| 92 |
if guild.demote_member(text[1]): |
| 93 |
record = guild.info(text[1]) #refresh record |
| 94 |
message = '%s demoted to %s' %(text[1], record['Rank']) |
| 95 |
else: |
| 96 |
message = 'You cannot demote %s' %text[1] |
| 97 |
else: |
| 98 |
message = '%s is not a member' %text[1] |
| 99 |
else: |
| 100 |
message = 'Usage "demote <member_name>"' |
| 101 |
|
| 102 |
elif text[0] == 'status': |
| 103 |
if len(text)==3: |
| 104 |
record = guild.info(text[1]) |
| 105 |
if record: |
| 106 |
if guild.change_status(text[1],text[2]): |
| 107 |
record = guild.info(text[1]) #refresh record |
| 108 |
message = '%s now has status of %s' %(text[1], record['Status']) |
| 109 |
else: |
| 110 |
message = '%s is not a valid status' %text[2] |
| 111 |
else: |
| 112 |
message = '%s is not a member' %text[1] |
| 113 |
else: |
| 114 |
message = 'Usage "status <member_name> <status>\n%s"' %str(guild.status) |
| 115 |
|
| 116 |
# DM commands |
| 117 |
#add user directly |
| 118 |
elif text[0] == 'add' and isDM: |
| 119 |
if len(text)==2: |
| 120 |
#check if they are a player |
| 121 |
if log.info(text[1]): |
| 122 |
#see if they are on the board already |
| 123 |
if guild.info(text[1]): |
| 124 |
#already a member |
| 125 |
message = '%s is already a member.' %text[1] |
| 126 |
else: |
| 127 |
guild.add_member(text[1], 'Initiate') |
| 128 |
message = 'Added %s to the guild' %text[1] |
| 129 |
else: |
| 130 |
message = 'Sorry, I don\'t know any %s' %text[1] |
| 131 |
else: |
| 132 |
message = 'Usage "add <membername>"' |
| 133 |
|
| 134 |
#change guild status |
| 135 |
elif text[0] == 'guildstatus' and isDM: |
| 136 |
if len(text)==2: |
| 137 |
record = guildhouse.info(guildname) |
| 138 |
if record: |
| 139 |
if guildhouse.change_status(guildname,text[1]): |
| 140 |
record = guildhouse.info(text[1]) #refresh record |
| 141 |
message = '%s now has status of %s' %(guildname, record['Status']) |
| 142 |
else: |
| 143 |
message = '%s is not a valid status' %text[1] |
| 144 |
else: |
| 145 |
message = '%s is not a guild' %guildname |
| 146 |
else: |
| 147 |
message = 'Usage "guildstatus <status>\n%s"' %str(guildhouse.status) |
| 148 |
|
| 149 |
else: |
| 150 |
message = 'What did you need?' |
| 151 |
|
| 152 |
else: |
| 153 |
message = 'Board Error' |
| 154 |
whoami.Say(message) |