Tibia bot in python - python

I am trying to code a simple bot for 7.6 tibia private server. My problem is that I don't know how to get a packet responsible for some action and if I'll have one I don't know how to send it to server.
Can you give me some tips?

Related

Discord.py gateway connection and disconnects from the API

I've been hosting a discord bot on an online IDE but it happens to disconnect from the API after a while. The code on the IDE continues to run, but on discord, it is unable to respond to commands and essentially the entire bot is completely offline, while a running code is being executed. Even more suprising is a background task that I have assigned to run every minute continues to do it's job ( which is to edit a embed in a server with new information ). I've been going through the documentation and about the gateway kinda stuff but I'm utterly confused. It states that disconnections are regular but never teaches me how to actually connect again rather some snippets of JSON data. Documentation here : https://discord.com/developers/docs/topics/gateway#gateway-intents
I'm a bit new to this stuff but the documentation clearly doesn't talk anything about the way to connect to the gateway, and what to do during a op7 reconnect. How would I be able to incorperate this reconnection thing with my discord bot also?

Getting Started: How can I create a server-side application to decipher a code and take an action?

So, I have minimal experience with Python, but I am very eager to learn. At my university, I am working in a group research lab where we are expanding on some previous research. Our next task is to create 2 applications:
The Client to Server application needs to be able to take inputs from a 4X4 keypad and send them to the server.
The Server to Client application needs to be able to take the codes sent and perform actions from them. For example:
1: Sends a message to the First-Aid team nearest to the location
2: Sends a message to the Hospital service
3: Sends a message to ...
D: No action is performed as this only acknowledges the end of the message
I definitely do not want my project done for me, of course. I'm just not sure how to get started. If anybody could provide resources or a good starting point, I would appreciate it dearly.
Thanks!
You could easily do this using TCP socket programming.
Try setting up two servers. One will be a client and other can be a server (Proxy server if you want it to connect to another server). On receiving inputs from the client the server which is listening reads the data and performs the task.
You can get started with socket programming here:
Visit
https://docs.python.org/3/howto/sockets.html
or
https://realpython.com/python-sockets/

Controlling a robot from the web

I am trying to get an RPi3 robot to accept commands from both the Web and from a touchscreen/keyboard interface. I have a script that handles the keyboard and I am looking for that current script I have in Python to be expanded to accept real-time input from the web. As well as trying to figure out how to send the data to the script.
More detail is below but that is the basic question.
I created the robot using a raspberry pi and 3 arduinos controlling DC motors and servos to make the bot move. The program is written in Python and is run from the command line. when run it:
queries the active serial ports on the Raspberry
opens each available port
sends an integer to the receiving arduino
the arduino responds with an identifying integer so the RPI can name the port
then the script waits for user input like "Forward"
the command is translated and sent to the correct port
the robot moves
This all works perfect. Now I want to expand it. I want to keep this functionality intact and add in a web interface so I can control it from anywhere. I've tried a couple of different things with no success. I have installed apache and I am able to serve the pages with no problem, I can get the data on the page, but I can't figure out how to get the web page to send the data to the running arduino script. My issue stems from the fact that the bot control script needs to run independent of the web page. I want to still keep the same input now from the keyboard, but I also want it to accept the data from the web page. If I invoke the bot controller from the web page each time it will need to re-establish the port connections each time which takes up to 20 seconds...
I am thinking if I create a listening script I can have the website invoke the listener which will run only to receive the data from the web and pass it to the bot controller and back. But I am not sure how to do this or if this is even the best way.
I've looked at websockets, CGI/wsgi, Flask, writing a file, and JSON and I just can't seem to string it all together.
Thanks in advance and apologies if this is not in the right place or has been answered before. Also, I have not included any code as the only solid code is the bot controller. I am hoping someone with some real expertise can help me unravel this.
thanks in advance
KenV
I would say Flask is your best option. A simple example of how you could use it:
from my_robot_stuff import move_forward
#app.route('/move_forward')
def move_forward_flask():
move_forward()
return redirect('/')
Your html would then have a button that says move forward that directs to mysite.com/move_forward. flask would process it, run the code, then redirect back to the root.

Server-Client push notification with Python

I'm building an client application, which connect to a server and wait for signal from server to do something (think about chat app).
For example: user 1 has client 1 and 2, user 2 has client 3, the server would send the message to the channel "user 1" and only client 1 and 2 will have the message.
I know about Websocket and Long-polling, but can't find a server which is self-hosted and easy to test. Initially I want to make a proof-of-concept first before dive in later.
Nginx push stream seems to fit my need, I can create a channel, and notify all client connect to that channel, seem good enough to use, but I can't find any Python client implement
AutoBahn and some other Python server seem only create one channel and broadcast.
Can someone give me a correct direction.
have a look on Python tornado http://www.tornadoweb.org/.
It is in fact a non-blocking webserver and you have a WebSocketHandler object which might be very useful for what you want to do.
http://www.tornadoweb.org/en/stable/websocket.html
Regards
You can have a look at zeromq which implements a push-pull client server interface.

IRC msg to send to server to send a "whisper" message to a user in channel

I'm writing up an IRC bot from scratch in Python and it's coming along fine.
One thing I can't seem to track down is how to get the bot to send a message to a user that is private (only viewable to them) but within a channel and not a separate PM/conversation.
I know that it must be there somewhere but I can't find it in the docs.
I don't need the full function, just the command keyword to invoke the action from the server (eg PRIVMSG).
Thanks folks.
Are you looking for /notice ? (see irchelp.org/irchelp/misc/ccosmos.html#Heading227)

Categories

Resources