Skip to content
Snippets Groups Projects
Commit 615abc0f authored by Svetlana Tkachenko's avatar Svetlana Tkachenko
Browse files

Added a broken ping_server plugin to extra

parent 1e3cc232
No related branches found
No related tags found
No related merge requests found
# guppy Copyright (C) 2010-2011 guppy team members.
#
# This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
# This is free software, and you are welcome to redistribute it
# under certain conditions; type `show c' for details.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
import time
import threading
@plugin
class Ping_server(object):
def __init__(self, server):
# Variables.
self.server = server
self.network = self.server.config["network"]
self.commands = []
self.loop = True
self.ponged = False
self.timeLoop = 10;
def loop(plugin,server):
timeWaited = 0
while self.loop:
if timeWaited >= self.timeLoop:
self.pingServer()
timeWaited = 0
time.sleep(5)
timeWaited += 5
self.t1 = threading.Thread(target=loop, args=(self,server,))
self.t1.daemon = True
self.t1.start()
server.handle("data", self.handle_data)
def pingServer(self):
self.server.prnt("Ponged? " + str(self.ponged))
if (self.ponged == False):
self.server.pluginManager.unloadAllPlugins()
self.server.pluginManager.event("disconnect", self.network)
self.server.__init__(self.server.config)
self.loop = False
self.server.prnt("Sending ping...")
self.server.sendLine('ping :0000')
self.ponged = False
self.server.prnt("Ping sent.")
def handle_data(self, network, data):
self.ponged = True
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment