-
Notifications
You must be signed in to change notification settings - Fork 0
Home
This Python module is intended to simplify access to the Hackmud's chat API directly in Python.
It would be a great help in developing chat bots.
Just pip install hackmud_chat
As Hackmud's API is a HTTP/JSON API, this module will also install requests
to perform HTTP communications.
To use the Hackmud's API you need either a token or a password.
If you don't already have a token, you must log into the Hackmud's client and enter the command chat_pass
. You will get a 5 ASCII characters password which expires within 5 minutes.
If you already got a token and it is still valid (45 day expiracy) you can use it directly.
Once you have what you need, simply write:
from hackmud_chat import Account
account = Account(token='your_token')
# OR
account = Account(passwd='your_pass')
Then you'll need to get users from this account to interact with the chat.
print account.users
# [<hackmud_chat.User name='user1'>, <hackmud_chat.User name='user2'>, ...]
user1 = account.get_user('user1')
Finally you can interact with the chat:
user1.tell('other_user', 'Hello')
user1.say(user1.channels[0].name, 'Hi everyone')
user1.sayTo(user1.channels[0].name, 'other_user', 'Hello you!')
user1.update_history()