Giter VIP home page Giter VIP logo

spockbot's People

Contributors

barneygale avatar beanthemoonman avatar gamingrobot avatar gjum avatar guineawheek avatar jasperbok avatar jerryhigarr avatar luken avatar nickelpro avatar nicoxxl avatar pickardjoe avatar smilechaser avatar txomon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spockbot's Issues

Vertical Vectors Not Applying Under Normal Conditions

Vectors that instruct the player to move up, i.e. the jump method (and manually applied vectors) only "Activate" when the player isn't on the ground.

def onTick(self,,_):
self.physics.jump()
The code above executes every tick, for instance. When I break the block under the player, they do a little hop before falling down.

Add a "task stack trace" to TaskFailed

Currently, only the last TaskFailed instance and message are given to the on_error method of task parents. This makes it hard/impossible to find the source of an error.

TaskFailed should have access to

  • all TaskFailed instances that were previously raised, and
  • all tasks that have failed due to the TaskFailed error, i.e. after it was raised.

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xde in position 0: invalid continuation byte

So I'm quite new to python and programming overall. I've managed to get example.py running. I tried it out in test.civcraft.co and it worked great. However, trying it out in the main civcraft server mc.civcraft.co causes this error. Let me know if there's anything else I can provide! BTW, I tried running python 3 on example.py with my login info in the blanks, but it kept throwing this error:

Traceback (most recent call last):
  File "example.py", line 26, in <module>
    from .example_plugin import ExamplePlugin
SystemError: Parent module '' not loaded, cannot perform relative import

So instead I've been running it as python3 -m basic.example ... Not sure if this is causing the problem or not!

Here is the full ouput!

hlprimm@apollo:~/Code/python/SpockBot/examples$ python3 -m basic.example
[INFO]: AUTHCORE: Attempting login with username: CENSORED
[INFO]: AUTHCORE: Logged in as: hlprimm
[INFO]: AUTHCORE: Selected Profile: {'id': '5505ae3e6d424a53ae059e19479d29e2', 'name': 'hlprimm'}
[INFO]: NETCORE: Attempting to connect to host: mc.civcraft.co port: 25565
[INFO]: NETCORE: Connected to host: mc.civcraft.co port: 25565
[INFO]: AUTHPLUGIN: Attempting to authenticate session with sessionserver.mojang.com
[INFO]: AUTHPLUGIN: Session authentication successful
Chat message received: [22:47:14] <<< (0x03, 0x02): Chat Message                  {'position': 1, 'json_data': {'extra': [{'color': 'white', 'text': ' '}, {'color': 'white', 'text': ' '}, {'color': 'dark_blue', 'text': ' '}, {'color': 'black', 'text': ' '}, {'color': 'dark_green', 'text': ' '}, {'color': 'white', 'text': ' '}, {'color': 'white', 'text': ' '}, {'color': 'dark_green', 'text': ' '}, {'color': 'black', 'text': ' '}, {'color': 'dark_red', 'text': ' '}, {'color': 'dark_aqua', 'text': ' '}, {'color': 'blue', 'text': ' '}, {'color': 'dark_green', 'text': ' '}, {'color': 'black', 'text': ' '}, {'color': 'black', 'text': ' '}, {'color': 'dark_aqua', 'text': ' '}, {'color': 'blue', 'text': ' '}, {'color': 'dark_green', 'text': ' '}, {'color': 'black', 'text': ' '}, {'color': 'black', 'text': ' '}, {'color': 'dark_aqua', 'text': ' '}, {'color': 'blue', 'text': ' '}, {'color': 'dark_green', 'text': ' '}, {'color': 'black', 'text': ' '}, {'color': 'black', 'text': ' '}, {'color': 'dark_aqua', 'text': ' '}, {'color': 'gold', 'text': ' '}, {'color': 'dark_aqua', 'text': ' '}, {'color': 'gold', 'text': ' '}, {'color': 'dark_aqua', 'text': ' '}, {'color': 'gold', 'text': ' '}, {'color': 'dark_aqua', 'text': ' '}, {'color': 'gold', 'text': ' '}, {'color': 'dark_aqua', 'text': ' '}, {'color': 'gold', 'text': ' '}, {'color': 'dark_aqua', 'text': ' '}, {'color': 'gold', 'text': ' '}], 'text': ''}}
Chat message received: [22:47:14] <<< (0x03, 0x02): Chat Message                  {'position': 1, 'json_data': {'extra': [{'color': 'gray', 'text': '[NSAccess] hlprimm: '}, {'color': 'white', 'text': 'Bot active.'}], 'text': ''}}
Chat message received: [22:47:15] <<< (0x03, 0x02): Chat Message                  {'position': 1, 'json_data': {'extra': [{'color': 'red', 'text': 'You have engaged in combat. Type '}, {'color': 'aqua', 'text': '/ct '}, {'color': 'red', 'text': 'to check your timer.'}], 'text': ''}}
Chat message received: [22:47:15] <<< (0x03, 0x02): Chat Message                  {'position': 1, 'json_data': {'extra': ['You have been Combat Tagged on Login'], 'text': ''}}
My position: (-1819.13, 67.22, -11004.61) pitch: 8.99999713897705 yaw: 96.29989624023438
Before changing the block, the type had id 0 and name air.
Chat message received: [22:47:18] <<< (0x03, 0x02): Chat Message                  {'position': 1, 'json_data': {'extra': [{'color': 'red', 'text': "I'm sorry, but you do not have permission to perform this command. Please contact the server administrators if you believe that this is in error."}], 'text': ''}}
Traceback (most recent call last):
  File "/usr/lib/python3.4/runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.4/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/hlprimm/Code/python/SpockBot/examples/basic/example.py", line 46, in <module>
    client.start(SERVER, 25565)
  File "/usr/local/lib/python3.4/dist-packages/spock-0.1.2-py3.4.egg/spock/plugins/helpers/start.py", line 37, in start
  File "/usr/local/lib/python3.4/dist-packages/spock-0.1.2-py3.4.egg/spock/plugins/core/event.py", line 23, in event_loop
  File "/usr/local/lib/python3.4/dist-packages/spock-0.1.2-py3.4.egg/spock/plugins/core/event.py", line 38, in emit
  File "/usr/local/lib/python3.4/dist-packages/spock-0.1.2-py3.4.egg/spock/plugins/core/net.py", line 189, in tick
  File "/usr/local/lib/python3.4/dist-packages/spock-0.1.2-py3.4.egg/spock/plugins/core/event.py", line 38, in emit
  File "/usr/local/lib/python3.4/dist-packages/spock-0.1.2-py3.4.egg/spock/plugins/core/net.py", line 205, in handle_recv
  File "/usr/local/lib/python3.4/dist-packages/spock-0.1.2-py3.4.egg/spock/plugins/core/net.py", line 129, in read_packet
  File "/usr/local/lib/python3.4/dist-packages/spock-0.1.2-py3.4.egg/spock/mcp/mcpacket.py", line 70, in decode
  File "/usr/local/lib/python3.4/dist-packages/spock-0.1.2-py3.4.egg/spock/mcp/datautils.py", line 220, in unpack
  File "/usr/local/lib/python3.4/dist-packages/spock-0.1.2-py3.4.egg/spock/mcp/datautils.py", line 162, in unpack_metadata
  File "/usr/local/lib/python3.4/dist-packages/spock-0.1.2-py3.4.egg/spock/mcp/datautils.py", line 214, in unpack
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xde in position 0: invalid continuation byte

Is there something I should change?

Thanks a bunch, spockbot is AWESOME!!

KeyError in handle_player_list

First: thank you for SpockBot - its awesome!

Second, on our server (freebuild.mineactivity.com) sometimes SpockBot crashes like so:

Traceback (most recent call last):
  File "main.py", line 16, in <module>
    client.start('freebuild.mineactivity.com', 25565)
  File "/usr/lib/python2.7/site-packages/spock/plugins/helpers/start.py", line 37, in start
    self.event.event_loop()
  File "/usr/lib/python2.7/site-packages/spock/plugins/core/event.py", line 22, in event_loop
    self.emit('event_tick')
  File "/usr/lib/python2.7/site-packages/spock/plugins/core/event.py", line 36, in emit
    else copy.deepcopy(data)
  File "/usr/lib/python2.7/site-packages/spock/plugins/core/net.py", line 185, in tick
    self.event.emit(flag)
  File "/usr/lib/python2.7/site-packages/spock/plugins/core/event.py", line 36, in emit
    else copy.deepcopy(data)
  File "/usr/lib/python2.7/site-packages/spock/plugins/core/net.py", line 203, in handleRECV
    self.net.read_packet(data)
  File "/usr/lib/python2.7/site-packages/spock/plugins/core/net.py", line 133, in read_packet
    self.event.emit(packet.str_ident, packet)
  File "/usr/lib/python2.7/site-packages/spock/plugins/core/event.py", line 36, in emit
    else copy.deepcopy(data)
  File "/usr/lib/python2.7/site-packages/spock/plugins/helpers/clientinfo.py", line 161, in handle_player_list
    item = self.uuids[pl['uuid']]
KeyError: 237771049331261779340081663972802975458L

It might be because another player left because the only other event happening at that time was a player going offline:

[14:30:12 INFO]: ljhodge lost connection: Disconnected
[14:30:12 INFO]: ItHurtsWhenIP lost connection: Disconnected

(ItHurtsWhenIP is my 'amusing' bot name)

This would seem to be the case since the 128-bit integer 237771049331261779340081663972802975458 matches ljhodge's UUID.

Failed plugin loading results in inconsistent behavior

If a plugin fails to load multiple things can happen depending on how that plugin was loaded and what actions the plugin took before it crashed.

For example, if a plugin fails to load during normal activation but registered event handlers before it failed, the bot will crash if that event fires. If that same plugin was activated by a PluginLoader.requires(), the bot will crash upon trying to activate the plugin because of inconsistencies in exception handling by PluginLoader.

Personally I think the answer to this is just to log something useful + the error stacktrace and then shutdown whenever a plugin fails to load.

Depends not found in installing

In my Ubuntu 14.04 LTS server, I accidentally encountered the error that shows depends libraries not found. It shows that the package 'openssl/aes.h', 'ffi.h', 'Python.h' not found, which leads to the following packages in Ubuntu apt-get: libssl-dev, libffi-dev, and python-dev. I am wondering that should we add them into installation script. Maybe I'll open a pull request.

Documentation and a Tutorial

Exactly what it says on the tin, documentation and a setup tutorial would make Spock a much friendly platform for development.

timers start stop

thats' not really a issue, but I have seen that you made your own implementation of the timers, and I see you cant start a timer with "self.timers.reg_event_timer" but I haven't found a simple solution to stop them, did I missed it? I have made a small patch, if you interested I can submit the pull request
https://github.com/zezadas/spock/commit/a59f048a0f0360782a529dbc78b8bed6215cb476

and then you can make something like

start

t=self.timers.reg_event_timer(0.05, self.derp)

stop

self.timers.timers.remove(self.timers.timers[t])

Packet en/decoder needs to use extensions

Packets with extensions need to have this extra data accounted for when decoding and decoding. The packet module should use the extensions module to account for this extra information

inventory.py not Python 2.7.6 compatible

super().__init__() cannot be called this way in Python 2.7. Calling the super class by name, e.g. Slot.__init__ seems to do the trick, but this may not be a correct way to handle it.

Possible to qualify the event that activates a plugin?

In particular I'm looking at the chat plugin here:

https://github.com/SpockBotMC/SpockBot-Extra/blob/master/plugins/Chat.py#L18

I'm trying to get a Slack <-> Minecraft relay going and it's almost done. I've gotten spockbot to send messages to my Slack channel. Now I just need to get the messages to send from Slack to spockbot.

My problem is my the chat plugin handles both listening for new messages and sending new messages. Is there any way I can keep the plugin from calling itself when the the bot sends a message?

When I run what I have, it looks like this kicks me out of minecraft. When I comment out the self.emit_chat_message from my relay function, I don't get kicked (which is why I think it has to deal with the plugin calling itself).

hlprimm@apollo:~/Code/python/SlackMCRelay$ python slackmcrelay.py 
[INFO]: AUTHCORE: Attempting login with username: EMAIL
[INFO]: AUTHCORE: Logged in as: htownJD
[INFO]: AUTHCORE: Selected Profile: {u'id': u'44c37ed8d3584de2873ec179c0409ab0', u'name': u'htownJD'}
[INFO]: NETCORE: Attempting to connect to host: mc.civcraft.co port: 25565
[INFO]: NETCORE: Connected to host: mc.civcraft.co port: 25565
msg: slack msg received
hlprimm : IT WORKS

spock tries to forward the message but... gets this:

[INFO]: AUTHPLUGIN: Attempting to authenticate session with sessionserver.mojang.com
[INFO]: AUTHPLUGIN: Session authentication successful
[ERROR]: NETPLUGIN: Socket has hung up
[INFO]: EVENTCORE: Kill called, shutting down
[INFO]: NETPLUGIN: Kill event recieved, shutting down socket

Thanks :)

Crash when trying to place block on invalid y coord

When attempting to place a block at a location with a y value that's too large, Spock crashes

e.g. l place 5 254345 29

Entering a y value โ‰ฅ 255 causes the crash, but absurdly large x and z values do not seem to break it

Traceback (most recent call last):
File "run.py", line 19, in
client.start('obfuscated.url', 12345)
File "/Library/Python/2.7/site-packages/spock/plugins/helpers/start.py", line 37, in start
self.event.event_loop()
File "/Library/Python/2.7/site-packages/spock/plugins/core/event.py", line 22, in event_loop
self.emit('event_tick')
File "/Library/Python/2.7/site-packages/spock/plugins/core/event.py", line 36, in emit
else copy.deepcopy(data)
File "/Library/Python/2.7/site-packages/spock/plugins/core/net.py", line 184, in tick
self.event.emit(flag)
File "/Library/Python/2.7/site-packages/spock/plugins/core/event.py", line 36, in emit
else copy.deepcopy(data)
File "/Library/Python/2.7/site-packages/spock/plugins/core/net.py", line 202, in handleRECV
self.net.read_packet(data)
File "/Library/Python/2.7/site-packages/spock/plugins/core/net.py", line 130, in read_packet
self.event.emit(packet.ident, packet)
File "/Library/Python/2.7/site-packages/spock/plugins/core/event.py", line 36, in emit
else copy.deepcopy(data)
File "/Library/Python/2.7/site-packages/spock/plugins/helpers/world.py", line 83, in handle23
self.world.set_block(p['x'], p['y'], p['z'], data = block_data)
File "/Library/Python/2.7/site-packages/spock/mcmap/smpmap.py", line 204, in set_block
chunk = column.chunks[y]
IndexError: list index out of range

Python 3 support

It would be nice to be Python 3 compatible, since Spock doesn't rely on any wildly incompatible behavior it should be mostly switching print statements around.

Can't launch

I can't manage to start the client, is there something I'm missing? I've installed all the required libraries, yet still it won't start cleanly.

Gracefully Disconnect

SpockBot should, if possible, gracefully disconnect when its killed rather than just dying. Not 100% sure how this works, see this PR: #37

Event loop timers

Event loop needs some sort of timer mechanisms to support position updates, should probably be tied to a position update flag

Incorrect Player Positions - Coordinates, Yaw & Pitch

I believe that there is an error with the logging of player positions. I haven't tested any other entities but it certainly looks like the case with players. I have tried to collect as much information as possible for you.

My logging code is shown below.

def onTick(self,_,__): #Only one player online (apart from the bot)
for eid in self.entities.players:
p = self.entities.players[eid]
logger.info(str(p))

The printed results is shown below. At first, the first of these is printed every tick but then it switches to the second result.

{'yaw': 12, 'current_item': 137, 'eid': 221, 'pitch': 22, 'y': 3200, 'x': -1786, 'z': -55769, 'metadata': [(18, (2, 0)), (17, (3, 0.0)), (16, (0, 0)), (10, (0, 127)), (9, (0, 0)), (8, (0, 0)), (7, (2, 0)), (6, (3, 20.0)), (4, (0, 0)), (3, (0, 0)), (2, (4, u'')), (1, (1, 300)), (0, (0, 0))]}

{'on_ground': True, 'yaw': 12, 'current_item': 137, 'eid': 221, 'pitch': 22, 'y': 3200, 'x': -1786, 'z': -55769, 'metadata': [(18, (2, 0)), (17, (3, 0.0)), (16, (0, 0)), (10, (0, 127)), (9, (0, 0)), (8, (0, 0)), (7, (2, 0)), (6, (3, 20.0)), (4, (0, 0)), (3, (0, 0)), (2, (4, u'')), (1, (1, 300)), (0, (0, 0))]}

Below is an image with the exact position etc of the player (with 'eid' 221).

I have checked that I was logging the correct player by making them hold a command block (137); the bot player was not holding one. The player that I logged was perfectly still whilst the logs were being collected.

Chat plugin not reading correctly the messages

When running chat plugin, I only had some output like "chat: myname"
I guess the bug comes from "if type(text) is str: "
I have fixed it on my code, but I only started to develop in python, today, so my approach may be not the best way to fix it.
BTW, great project!! ;)

Smart protocol support

Spock should support arbitrary protocol versions, and intelligently pick the correct protocol version when connecting to a server unless otherwise specified

Anti-AFK v2.0

Anti-AFK is currently entirely chat based, it should be timer and movement based instead. That is, a timer should trigger the bot to spin in place (thus avoiding AFK while not consuming hunger)

SyntaxError: invalid syntax (mcdata.py)

CentOS 6.5

CPU Model: Intel(R) Xeon(R) CPU E3-1230 V2 @ 3.30GHz

[root@server SpockBot-master]# python demo.py
Traceback (most recent call last):
File "demo.py", line 5, in
from spock import Client
File "/home/SpockBot-master/spock/init.py", line 1, in
from spock.plugins.pluginloader import PluginLoader
File "/home/SpockBot-master/spock/plugins/init.py", line 1, in
from spock.plugins.core import event, net, auth, timer, ticker
File "/home/SpockBot-master/spock/plugins/core/event.py", line 7, in
from spock.mcp import mcdata
File "/home/SpockBot-master/spock/mcp/mcdata.py", line 1133
for state in packet_structs
^
SyntaxError: invalid syntax

(None of the files were modified.)

Reorganize spock.utils

spock.utils is made up by lots of collected code from many independent use cases:

  • plugin loading, event registration, settings
  • object serialization
  • buffer stuff
  • vectors
  • collision boxes

Some stuff is not even used anymore. Definitely needs to be cleaned up, probably by splitting into several spock.utils.* and/or moving classes/methods closer to where they are actually used.

Session keep-alive timer

Spock needs to send keep-alives for its session once every 6000 ticks (~5m) to prevent session kicks after the client as already logged in

Windows support (Again?)

I'm probably missing something here, but hear me out. I installed the dependencies as instructed, and got to the point where I should be able to run the demo, but I got this:

File "C:\Python34\lib\site-packages\spock\plugins\core\net.py", line 55, in
rmask = select.POLLIN|select.POLLERR|select.POLLHUP
AttributeError: 'module' object has no attribute 'POLLIN'

I did a bit of googling and came up with this post:

http://stackoverflow.com/questions/22923063/cant-access-constant-pollin-from-select-module-with-python-2-7-or-3-3-on-windows

Which lead me back here, but before I posted I doubble checked other tickers and someone has also posted about windows support here:
#8
The last post implies that windows support has been added, but It isn't working for me on windows 7? Is there a step I'm missing to enable windows support? Or was I mistaken?

My goal is to try and run this on a raspberry pi, but use windows for most my testing and whatnaught.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.