Exemplo n.º 1
0
 def connect(self, serverConnectionID):
     print "Setting up server state"
     self.connection = TS3.Connection(serverConnectionID)
     if not self.find_parent_channel():
         print "Failed to find parent channel"
         return
     if not self.channel_factory_exists():
         self.create_channel_factory()
     self.dbid_manager = DatabaseIDManager(self.connection)
     self.owner_db = ChannelOwner()
        channel = me.get_channel()
        if len(channel.get_clients()) <= 1:
            stop()

    def onTextMessageEvent(self, connection, message, targetMode, toID, fromID,
                           **kwargs):
        response = self.parse_message(connection, message)
        if response == None:
            return

        if targetMode == constants.TextMessageTargetMode.TextMessageTarget_CLIENT:
            fromClient.send_private_message(response)
        elif targetMode == constants.TextMessageTargetMode.TextMessageTarget_CHANNEL:
            connection.requestSendChannelTextMsg(
                message=response,
                targetChannelID=Client.get_self(
                    connection).get_channel().channel_id,
                returnCode="")
        elif targetMode == constants.TextMessageTargetMode.TextMessageTarget_SERVER:
            connection.requestSendServerTextMsg(message=response,
                                                returnCode="")

    def onClientMoveEvent(self, connection, **kwargs):
        self.check_should_stop(connection)

    def onClientMoveMovedEvent(self, connection, **kwargs):
        self.check_should_stop(connection)


TS3.register_callback_handler(RadioHandler())
	def onNewChannelCreatedEvent(self, connection, **kwargs):
		self.ensure_channel_factory()

	def onClientMoveEvent(self,
		connection,
		clientID,
		oldChannelID,
		newChannelID,
		**kwargs):
		self.delete_empty_channels()
		if self.is_channel_factory(newChannelID):
			self.create_channel_for_user(clientID, newChannelID)

	def onClientMoveMovedEvent(self, connection, clientID, newChannelID, **kwargs):
		self.delete_empty_channels()
		if self.is_channel_factory(newChannelID):
			self.create_channel_for_user(clientID, newChannelID)

	def onTextMessageEvent(self, connection, targetMode, toID, fromID, fromName, fromUniqueIdentifier, message, ffIgnored, **kwargs):
		if message == "!test":
			print TS3.ConnectStatus.STATUS_CONNECTION_ESTABLISHED

	def onClientDBIDfromUIDEvent(self, connection, uniqueClientIdentifier, clientDatabaseID, **kwargs):
		self.dbid_manager.update(uniqueClientIdentifier, clientDatabaseID)

	def onUpdateChannelEditedEvent(self, connection, channelID, **kwargs):
		self.store_channel_name(channelID)

TS3.register_callback_handler(ServerState())
Exemplo n.º 4
0
            if parts[0] == "!nerf":
                randint.nerf = True
                return "Rolls have been nerfed"
            if parts[0] == "!balance":
                randint.nerf = False
                randint.buff = False
                return "Rolls have been balanced"

    def onTextMessageEvent(self, connection, message, targetMode, toID, fromID,
                           **kwargs):
        fromClient = Client(connection, fromID)
        self.connection = connection
        message = self.parse_message(
            message, fromClient,
            fromClient.get_unique_identifier() == PRIVLAGED_ID)
        if message == None:
            return
        if targetMode == constants.TextMessageTargetMode.TextMessageTarget_CLIENT:
            fromClient.send_private_message(message)
        elif targetMode == constants.TextMessageTargetMode.TextMessageTarget_CHANNEL:
            connection.requestSendChannelTextMsg(
                message=message,
                targetChannelID=Client.get_self(
                    connection).get_channel().channel_id,
                returnCode="")
        elif targetMode == constants.TextMessageTargetMode.TextMessageTarget_SERVER:
            connection.requestSendServerTextMsg(message=message, returnCode="")


TS3.register_callback_handler(RandomHandler())
import TS3


class TenhouModuleHandler(TS3.ClientEventHandler):
    def onTextMessageEvent(self, connection, message, **kwargs):
        if message.lower() == "!t":
            connection.requestSendServerTextMsg(
                message="[url=http://tenhou.net/0/?3362]Tenhou[/url]",
                returnCode="")


TS3.register_callback_handler(TenhouModuleHandler())
Exemplo n.º 6
0
 def __init__(self):
     self.connection = TS3.Connection()
     self.parent_channel = None
     handles = self.connection.getServerConnectionHandlerList()
     if len(handles) > 0:
         self.connect(handles[0])
Exemplo n.º 7
0
    def onNewChannelCreatedEvent(self, connection, **kwargs):
        self.ensure_channel_factory()

    def onClientMoveEvent(self, connection, clientID, oldChannelID,
                          newChannelID, **kwargs):
        self.delete_empty_channels()
        if self.is_channel_factory(newChannelID):
            self.create_channel_for_user(clientID, newChannelID)

    def onClientMoveMovedEvent(self, connection, clientID, newChannelID,
                               **kwargs):
        self.delete_empty_channels()
        if self.is_channel_factory(newChannelID):
            self.create_channel_for_user(clientID, newChannelID)

    def onTextMessageEvent(self, connection, targetMode, toID, fromID,
                           fromName, fromUniqueIdentifier, message, ffIgnored,
                           **kwargs):
        if message == "!test":
            print TS3.ConnectStatus.STATUS_CONNECTION_ESTABLISHED

    def onClientDBIDfromUIDEvent(self, connection, uniqueClientIdentifier,
                                 clientDatabaseID, **kwargs):
        self.dbid_manager.update(uniqueClientIdentifier, clientDatabaseID)

    def onUpdateChannelEditedEvent(self, connection, channelID, **kwargs):
        self.store_channel_name(channelID)


TS3.register_callback_handler(ServerState())
Exemplo n.º 8
0
import TS3

# Redirects print to the ts3 window
# Note that calling print too early will cause output to be ignored
TS3.redirect_output()

# loads all modules in the current directory
import os

current_dir = os.path.dirname(os.path.realpath(__file__))
for item in os.listdir(current_dir):
	path = os.path.join(current_dir, item)
	if os.path.isdir(path):
		module = os.path.split(path)[1]
		init_file = os.path.join(path, "__init__.py")
		if os.path.isfile(init_file):
			print "Importing %s" % module
			__import__(module)
			else:
				Channel(connection, LOBBY_CHANNEL_ID).move_to_channel()
		elif parts[1] == "return" or parts[1] == "radio":
			self.goto(connection, "Channel Factory")

	def check_should_stop(self, connection):
		me = Client.get_self(connection)
		channel = me.get_channel()
		if len(channel.get_clients()) <= 1:
			stop()

	def onTextMessageEvent(self, connection, message, targetMode, toID, fromID, **kwargs):
		response = self.parse_message(connection, message)
		if response == None:
			return

		if targetMode == constants.TextMessageTargetMode.TextMessageTarget_CLIENT:
			fromClient.send_private_message(response)
		elif targetMode == constants.TextMessageTargetMode.TextMessageTarget_CHANNEL:
			connection.requestSendChannelTextMsg(message = response, targetChannelID = Client.get_self(connection).get_channel().channel_id, returnCode = "")
		elif targetMode == constants.TextMessageTargetMode.TextMessageTarget_SERVER:
			connection.requestSendServerTextMsg(message = response, returnCode = "")

	def onClientMoveEvent(self, connection, **kwargs):
		self.check_should_stop(connection)
	def onClientMoveMovedEvent(self, connection, **kwargs):
		self.check_should_stop(connection)


TS3.register_callback_handler(RadioHandler())
import TS3

class TenhouModuleHandler(TS3.ClientEventHandler):
	def onTextMessageEvent(self, connection, message, **kwargs):
		if message.lower() == "!t":
			connection.requestSendServerTextMsg(message = "[url=http://tenhou.net/0/?3362]Tenhou[/url]", returnCode = "")

TS3.register_callback_handler(TenhouModuleHandler())
Exemplo n.º 11
0
import TS3

class MyHandler(TS3.ClientEventHandler):
	def onTextMessageEvent(self, connection = None, **kwargs):
		message = kwargs['message']
		connection.printMessageToCurrentTab(message = message)

TS3.register_callback_handler(MyHandler())
		if privlaged:
			if parts[0] == "!buff":
				randint.buff = True
				return "Rolls have been buffed"
			if parts[0] == "!nerf":
				randint.nerf = True
				return "Rolls have been nerfed"
			if parts[0] == "!balance":
				randint.nerf = False
				randint.buff = False
				return "Rolls have been balanced"

	def onTextMessageEvent(self, connection, message, targetMode, toID, fromID, **kwargs):
		fromClient = Client(connection, fromID)
		self.connection = connection
		message = self.parse_message(message, fromClient, fromClient.get_unique_identifier() == PRIVLAGED_ID)
		if message == None:
			return
		if targetMode == constants.TextMessageTargetMode.TextMessageTarget_CLIENT:
			fromClient.send_private_message(message)
		elif targetMode == constants.TextMessageTargetMode.TextMessageTarget_CHANNEL:
			connection.requestSendChannelTextMsg(message = message, targetChannelID = Client.get_self(connection).get_channel().channel_id, returnCode = "")
		elif targetMode == constants.TextMessageTargetMode.TextMessageTarget_SERVER:
			connection.requestSendServerTextMsg(message = message, returnCode = "")

		
		
TS3.register_callback_handler(RandomHandler())