Package: halcyon
HalcyonHalcyon is a Matrix bot library with the goal of being easy to install and use. The library takes inspiration from discord.py and the Slack libraries.
Encryption is on the roadmap, and with the goal of being transparent to the user. Check the roadmap innotes.md, and see information of the token format intokenFormat.mdAsk questions in the matrix chat#halcyon:blackline.xyzor in GitHub issues.Current featuresA nice CLI tool to generate Halcyon tokensLogin with token or username/passwordFetch for new messages every x seconds using awaitEvent hooks foron_ready()on_message(message)on_message_edit(message)on_room_invite(room)on_room_leave(roomID)Action hookssend_message(roomID, body, textFormat, replyTo, isNotice)send_typing(roomID, seconds)change_presence(presence, statusMessage)join_room(roomID)download_media(mxc)upload_media(fileBuffer, fileName)send_image(roomID, fileBuffer, fileName, generate_blurhash, generate_thumbnail)Room and message objects for incoming events eventsBasic documentation (Checkusage.md)Getting startedCreate a matrix account for the botInstall Halcyon usingpython3 -m pip install halcyonor download it from the Releases tab in GithubGenerate a token usingpython3 -m halcyon -s homeserver.xyz -u @user:homeserver.xyz -p yourP@$$w0rdStart with the demo code belowExample bot codeSee more example and message object info inusage.mdExample message bot, looks for a phrase and replies with a phraseExample image bot, looks for a phrase and replies with an imageImage Archive bot, looks for images, and saves themimporthalcyonimportrequests,jsonclient=halcyon.Client()@client.eventasyncdefon_room_invite(room):"""On room invite, autojoin and say hello"""print("Someone invited us to join "+room.name)awaitclient.join_room(room.id)awaitclient.send_message(room.id,body="Hello humans")@client.eventasyncdefon_message(message):"""If we see a message with the phrase 'give me random', do a reply message with 32 random characters"""print(message.event.id)if"give me random"inmessage.content.body:awaitclient.send_typing(message.room.id)# This typing notification will let the user know we've seen their messagebody="This looks random: "+requests.get("https://random.wesring.com").json()["value"]awaitclient.send_message(message.room.id,body=body,replyTo=message.event.id)@client.eventasyncdefon_ready():print("Online!")awaitclient.change_presence(statusMessage="indexing /dev/urandom")if__name__=='__main__':client.run(halcyonToken="eyJ0eXAiO...")CLI usagehalcyon can be called from the CLI to do some management of the account.See the help message withpython3 -m halcyon -hRight now it can be used togenerate a new tokendecode an existing tokenrevoke a single tokenrevoke all tokensusage: halcyon [-h] [-s SERVER] [-u USERNAME] [-p PASSWORD] [--include-password] [--decode DECODE] [--pretty] [--revoke REVOKE] [--revoke-all-tokens REVOKE_ALL_TOKENS]

By this, you can generate a halcyonToken for your project, for example python3 -m halcyon -s matrix.org -u @kevin:matrix.org -p on&on&on1337

optional arguments:
  -h, --help            show this help message and exit
  -s SERVER, --server SERVER
                        Homeserver the user belongs to ex: matrix.org
  -u USERNAME, --username USERNAME
                        Your full username ex: @kevin:matrix.org
  -p PASSWORD, --password PASSWORD
                        Your full password for your matrix account
  --include-password    Save your username and password in the token for reauth (Not required right now since matrix tokens do not expire)
  --decode DECODE       Decode an existing token that you pass in
  --pretty              Pretty print the decoded token
  --revoke REVOKE       Revoke an existing token
  --revoke-all-tokens REVOKE_ALL_TOKENS
                        Revoke an all existing token for the account

Have fun creating