Skip to content
This repository was archived by the owner on Apr 27, 2019. It is now read-only.

Commit 1938b0f

Browse files
committed
Merge branch 'master' of github.com:8r2y5/StarryPy into feature/142
2 parents f0c3150 + 839834e commit 1938b0f

File tree

15 files changed

+50
-335
lines changed

15 files changed

+50
-335
lines changed

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
.cache
21
*.py[cod]
32

43
# C extensions
@@ -52,5 +51,4 @@ nosetests.xml
5251
# Mac cleanup
5352
.DS_Store
5453

55-
cover
56-
.noseids
54+
cover

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ With the built-in plugins (which are removable):
1414
* Join/quit announcements.
1515
* And more.
1616

17-
## Version 1.7 is here!
17+
## Version 1.7.1 is here!
1818

19-
With this most recent release, we are compatible with the current release of Starbound (Pleased Giraffe - Protocol 691). Any bugs found in the process, please open an issue ticket, so we can squash them as quickly as possible.
19+
With this most recent release, we are compatible with the current release of Starbound (Glad Giraffe - Protocol 710). Any bugs found in the process, please open an issue ticket, so we can squash them as quickly as possible.
2020

2121
## Upgrading from older versions of StarryPy
2222

base_plugin.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,11 @@ class BasePlugin(object):
5959
active = False
6060

6161
def __init__(self, *args, **kwargs):
62-
self.overridden_methods = {}
6362
super(BasePlugin, self).__init__(*args, **kwargs)
6463
if self.__class__.__name__ != 'BasePlugin':
6564
for packet, when_dict in self.overridden_packets.iteritems():
66-
self.overridden_methods.setdefault(packet, {})
6765
for when, packet_name in when_dict.iteritems():
68-
self.overridden_methods[packet][when] = getattr(
66+
self.overridden_packets[packet][when] = getattr(
6967
self, packet_name
7068
)
7169

plugin_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ def map_plugin_packets(self, plugin):
276276
"""
277277
Maps plugin overridden packets ready to use in do method.
278278
"""
279-
for packet_id, when_dict in plugin.overridden_methods.iteritems():
279+
for packet_id, when_dict in plugin.overridden_packets.iteritems():
280280
for when, packet_method in when_dict.iteritems():
281281
self.packets.setdefault(
282282
packet_id, {}

plugins/admin_messenger/admin_messenger.py

Lines changed: 25 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class AdminMessenger(BasePlugin):
99
"""
1010
Adds support to message moderators/admins/owner with a @@ prefixed message.
1111
"""
12-
name = 'admin_messenger'
12+
name = "admin_messenger"
1313
depends = ['player_manager_plugin']
1414

1515
def activate(self):
@@ -26,56 +26,48 @@ def on_chat_sent(self, data):
2626
return False
2727
return True
2828

29-
def add_timestamp(self, add_normalizer=False):
29+
def message_admins(self, message):
30+
now = datetime.now()
3031
if self.config.chattimestamps:
31-
now = datetime.now()
32-
timestamp = '^red;<{}> '.format(now.strftime('%H:%M'))
33-
if add_normalizer:
34-
return '{}^yellow;'.format(timestamp)
35-
return timestamp
32+
timestamp = "^red;<{}> ^yellow;".format(now.strftime("%H:%M"))
3633
else:
37-
return ''
38-
39-
def message_admins(self, message):
40-
timestamp = self.add_timestamp(add_normalizer=True)
41-
message = message.message[2:].decode('utf-8')
42-
34+
timestamp = ""
4335
for protocol in self.factory.protocols.itervalues():
4436
if protocol.player.access_level >= UserLevels.MODERATOR:
4537
protocol.send_chat_message(
46-
'{timestamp}{moderator_colors}'
47-
'ADMIN: ^yellow;<{player_colors}^yellow;> '
48-
'{moderator_colors}{message}'.format(
49-
timestamp=timestamp,
50-
moderator_colors=self.config.colors['moderator'],
51-
player_colors=(
52-
self.protocol.player.colored_name(
53-
self.config.colors
54-
)
55-
),
56-
message=message
38+
"{}{}ADMIN: ^yellow;<{}^yellow;> {}{}".format(
39+
timestamp,
40+
self.config.colors["moderator"],
41+
self.protocol.player.colored_name(self.config.colors),
42+
self.config.colors["moderator"],
43+
message.message[2:].decode("utf-8")
5744
)
5845
)
5946
self.logger.info(
60-
'Received an admin message from %s. Message: %s',
61-
self.protocol.player.name, message
47+
"Received an admin message from %s. Message: %s",
48+
self.protocol.player.name,
49+
message.message[2:].decode("utf-8")
6250
)
6351

6452
@permissions(UserLevels.ADMIN)
6553
def broadcast_message(self, message):
66-
timestamp = self.add_timestamp()
54+
now = datetime.now()
55+
if self.config.chattimestamps:
56+
timestamp = "^red;<{}> ".format(now.strftime("%H:%M"))
57+
else:
58+
timestamp = ""
6759

6860
for protocol in self.factory.protocols.itervalues():
6961
protocol.send_chat_message(
70-
'{}{}BROADCAST: ^red;{}{}'.format(
62+
"{}{}BROADCAST: ^red;{}{}".format(
7163
timestamp,
72-
self.config.colors['admin'],
73-
message.message[3:].decode('utf-8').upper(),
74-
self.config.colors['default']
64+
self.config.colors["admin"],
65+
message.message[3:].decode("utf-8").upper(),
66+
self.config.colors["default"]
7567
)
7668
)
7769
self.logger.info(
78-
'Broadcast from %s. Message: %s',
70+
"Broadcast from %s. Message: %s",
7971
self.protocol.player.name,
80-
message.message[3:].decode('utf-8').upper()
72+
message.message[3:].decode("utf-8").upper()
8173
)

plugins/admin_messenger/test_admin_messenger.py

Lines changed: 0 additions & 195 deletions
This file was deleted.

plugins/announcer_plugin/announcer_plugin.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22

33

44
class Announcer(BasePlugin):
5-
"""
5+
'''
66
Broadcasts a message whenever a player joins or leaves the server.
7-
"""
7+
'''
88
name = 'announcer_plugin'
99

10+
def activate(self):
11+
super(Announcer, self).activate()
12+
1013
def after_connect_success(self, data):
1114
self.factory.broadcast(
1215
'{} logged in.'.format(

0 commit comments

Comments
 (0)