TheNinth

Untitled

Aug 6th, 2013
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.23 KB | None | 0 0
  1. # Copyright (c) Mathias Kaerlev 2013.
  2. #
  3. # This file is part of cuwo.
  4. #
  5. # cuwo 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 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # cuwo 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 cuwo.  If not, see <http://www.gnu.org/licenses/>.
  17.  
  18. """
  19. Rotating auto announcements
  20. """
  21.  
  22. from cuwo.script import ServerScript
  23. from twisted.internet import task, reactor
  24. import random
  25. import sys
  26.  
  27. class Announcer(ServerScript):
  28.     def on_load(self):
  29.         self.auto_announce_timer = task.LoopingCall(self.auto_announce)
  30.         self.auto_announce_timer.start(300, True)
  31.  
  32.     def auto_announce(self):
  33.         message = getattr(self.server.config, 'announcement', '"Welcome to the server!"')
  34.         self.server.send_chat(message)
  35.         print message
  36.  
  37. def get_class():
  38.     return Announcer
Advertisement
Add Comment
Please, Sign In to add comment