1 |
root |
1.1 |
# Script for say event of IPO message board |
2 |
|
|
# |
3 |
|
|
# Copyright (C) 2002 Joris Bontje |
4 |
|
|
# |
5 |
|
|
# This program is free software; you can redistribute it and/or modify |
6 |
|
|
# it under the terms of the GNU General Public License as published by |
7 |
|
|
# the Free Software Foundation; either version 2 of the License, or |
8 |
|
|
# (at your option) any later version. |
9 |
|
|
# |
10 |
|
|
# This program is distributed in the hope that it will be useful, |
11 |
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 |
|
|
# GNU General Public License for more details. |
14 |
|
|
# |
15 |
|
|
# You should have received a copy of the GNU General Public License |
16 |
|
|
# along with this program; if not, write to the Free Software |
17 |
|
|
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
18 |
|
|
# |
19 |
|
|
# The author can be reached via e-mail at jbontje@suespammers.org |
20 |
|
|
# |
21 |
|
|
# help - gives information about usage |
22 |
|
|
# |
23 |
|
|
#Updated to use new path functions in CFPython -Todd Mitchell |
24 |
|
|
|
25 |
|
|
import Crossfire |
26 |
|
|
import CFBoard |
27 |
|
|
import string |
28 |
|
|
|
29 |
|
|
board = CFBoard.CFBoard() |
30 |
|
|
|
31 |
|
|
activator = Crossfire.WhoIsActivator() |
32 |
|
|
activatorname = activator.Name |
33 |
|
|
whoami = Crossfire.WhoAmI() |
34 |
|
|
|
35 |
|
|
boardname = Crossfire.ScriptParameters() |
36 |
|
|
if boardname: |
37 |
|
|
|
38 |
|
|
text = string.split(Crossfire.WhatIsMessage(), ' ', 1) |
39 |
|
|
|
40 |
|
|
if text[0] == 'help' or text[0] == 'yes': |
41 |
|
|
message='Help for %s\nList of commands:\n\n- list\n- write <message>\n- remove <id>\n'%boardname |
42 |
|
|
activator.Write(message) |
43 |
|
|
|
44 |
|
|
elif text[0] == 'write': |
45 |
|
|
if len(text) == 2: |
46 |
|
|
board.write(boardname, activatorname, text[1]) |
47 |
|
|
activator.Write('Added to %s'%boardname) |
48 |
|
|
else: |
49 |
|
|
activator.Write('Usage "write <text>"') |
50 |
|
|
|
51 |
|
|
elif text[0] == 'list': |
52 |
|
|
total = board.countmsg(boardname) |
53 |
|
|
if total > 0: |
54 |
|
|
activator.Write('Content of %s:'%boardname) |
55 |
|
|
elements = board.list(boardname) |
56 |
|
|
element = [] |
57 |
|
|
id = 1 |
58 |
|
|
for element in elements: |
59 |
|
|
author, message = element |
60 |
|
|
activator.Write('<%d> (%s) %s'%(id, author, message)) |
61 |
|
|
id = id+1 |
62 |
|
|
else: |
63 |
|
|
activator.Write('%s is empty'%boardname) |
64 |
|
|
|
65 |
|
|
elif text[0] == 'remove': |
66 |
|
|
if len(text) == 2: |
67 |
|
|
index = int(text[1]) |
68 |
|
|
if board.getauthor(boardname, index) == activatorname or activator.DungeonMaster: |
69 |
|
|
if board.delete(boardname, index): |
70 |
|
|
activator.Write('Removed from %s'%boardname) |
71 |
|
|
else: |
72 |
|
|
activator.Write('Doesn\'t exist on %s'%boardname) |
73 |
|
|
else: |
74 |
|
|
activator.Write('Access denied') |
75 |
|
|
else: |
76 |
|
|
activator.Write('Usage "remove <id>"') |
77 |
|
|
|
78 |
|
|
else: |
79 |
|
|
activator.Write('Do you need help?') |
80 |
|
|
|
81 |
|
|
else: |
82 |
|
|
activator.Write('Board Error') |