barneygale / quarry

Python library that implements the Minecraft network protocol and data types
Other
527 stars 75 forks source link

Sending messages doesn't work #127

Closed Daddy-Talpapa closed 10 months ago

Daddy-Talpapa commented 2 years ago

I'm probably doing something very stupid here, this is my code:

from quarry.net.client import ClientFactory, ClientProtocol, SpawningClientProtocol
from quarry.net.auth import OfflineProfile, ProfileCLI
from twisted.protocols import basic
import quarry

class ExampleClientProtocol(ClientProtocol):
    pass

class ExampleClientFactory(ClientFactory):
    protocol = ExampleClientProtocol

@defer.inlineCallbacks

def send(msg):
    self.send_packet("chat_message", self.buff_type.pack_string(msg))

def main():
    profile = OfflineProfile("user")
    factory = ExampleClientFactory(profile)
    factory = yield factory.connect("x.x.x.x", 24589)
    send("hello world")
if __name__ == "__main__":
    main()
    reactor.run()

It should send a chat message saying "hello world" but it doesnt. What am I doing wrong?

Thanks.

adsgniD commented 2 years ago

i think you forgot to import defer and reactor from twisted.internet

MajliTech commented 1 year ago

This issue is resolved and should be closed.