Cosmicray-Rocketchat
====================
-----------------------------------------
Implementation of Rocket.Chat restful api
-----------------------------------------
.. warning::
Cosmicray-Rocketchat is under development
Install
-------
.. code::
$ pip install cosmicray-rocketchat
Quick start
-----------
CLI
===
Cosmicray-Rocketchat ships with a simple commandline interface.
.. code::
$ rocketchat --help
Configuration: Credentials
==========================
Credentials are stored in a file called `~/.cosmicray/rocketchat/creds`. The following snippet of code creates it:
.. code:: python
>>> import rocketchat
>>> rocketchat.create_creds_file('myusername', 'mypassword')
Configuration: Domain and other settings
========================================
The following code will configure cosmicray-rocketchat client with the domain to use and save the configuration to file
.. code:: python
>>> import rocketchat
>>> rocketchat.configure(domain='http://myrocketchatdomain.com')
>>> rocketchat.store_config()
When importing cosmicray-rocketchat, the config will be automatically loaded. If you need to disable ssl verification
.. code:: python
>>> rocketchat.configure(
... monkey_patch=True,
... verify=False)
>>> rocketchat.store_config()
The `monkey_patch` flag disable SSL warnings.
Alternatively, the above configurations can be changed using the cli:
.. code::
$ rocketchat configure password --username myusername
Promp password:
$ rocketchat configure domain "http://myrocketchatdomain.com" --no-verify
Configuration: Debugging
========================
If there are any issues with making the requests, debugging can be enabled:
.. code:: python
>>> import rocketchat
>>> rocketchat.configure(config={'debug': True})
Or via command line:
.. code::
$ rocketchat configure domain --verbose
API
===
Cosmicray-Rocketchat defines endpoints from https://rocket.chat/docs/developer-guides/rest-api in `rocketchat.v1` module. For example, to get the server api version, you would make the following request:
.. code:: python
>>> import rocketchat
>>> rocketchat.v1.info().get()
The preferred way to interact with the Rocket.Chat api is to use models defined in `rocketchat.models` module.
.. code:: python
>>> rocketchat.models.User.me
<User(_id='CA9t5phAAaLcN9sdZ', type=None, status='offline', active=True, name='bot'...)>
>>> foo = rocketchat.models.User(username='foo').get()
>>> foo.send('Hello foo')
To list public, groups, direct message rooms
.. code:: python
>>> rooms = rocketchat.models.Channel.channels
>>> groups = rocketchat.models.Channel.groups
>>> direct = rocketchat.models.Channel.direct
For convenience, one could access users and rooms via mappings:
.. code:: python
>>> users = rocketchat.users()
>>> channels = rocketchat.channels()
>>> groups = rocketchat.groups()
>>> foo = users['foo']
>>> foo.send('Hello Foo!')
>>> messages = channels['mychannel'].messages.unread
>>> channels['mychannel'].send('Hey!')
To list/send messages for a channel (direct, group, or public/private channel):
.. code:: python
>>> myroom = rocketchat.channels()['myroom']
>>> print(myroom.messages.unread)
>>> messages = myroom.messages.by_daterange('2018-01-01', '2018-01-02').count(100).get()
>>> myroom.send('hello')
To update/delete messages:
.. code:: python
>>> message = myroom.messages.last[0]
>>> message.msg = 'changed message'
>>> message.update()
>>> message.pin()
>>> message.delete()
Metadata
Release files for cosmicray-rocketchat 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cosmicray-rocketchat-0.0.3.tar.gz | 12.9 kB | Without provenance | Details for cosmicray-rocketchat-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cosmicray_rocketchat-0.0.3-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for cosmicray_rocketchat-0.0.3-py2.py3-none-any.whl |
Total release size: 27.2 kB
Release files / cosmicray-rocketchat-0.0.3.tar.gz
| Download URL | cosmicray-rocketchat-0.0.3.tar.gz |
|---|---|
| Size | 12.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b49af5c61105560150c0310b0dbb738dc5f49ce95b868e81b24d8fd6a9b11b67
|
|
BLAKE2b-256 checksum How to use checksums |
02d629ec40b9bd366984529a0442da82fec3d1243d92cf9334ccf506fc58d2b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / cosmicray_rocketchat-0.0.3-py2.py3-none-any.whl
| Download URL | cosmicray_rocketchat-0.0.3-py2.py3-none-any.whl |
|---|---|
| Size | 14.3 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
ca96d1826bf82ae67cf5a18291986da497824e249e3d1c58a286465e50e27d61
|
|
BLAKE2b-256 checksum How to use checksums |
6e6cf731c3b89bfab69802f95359ac14aa93c4eb233e068377796e96b80f8b4c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for cosmicray-rocketchat 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.