Library wrapper for GroupMe API
Project description
LowerPines: GroupMe API Wrapper for Python
This library provides a Python wrapper around the GroupMe v3 API.
Installation
Use pip to install:
pip3 install lowerpines
Basic Usage
This requires a Access Token from the GroupMe developers site
The first step to doing anything with this library is to create a GMI object:
from lowerpines.gmi import get_gmi gmi = get_gmi(access_token='access token here')
A GMI object stores a copy of the Access Token and serves as a context for various functions. The get_gmi(access_token) method will get a GMI from the cache or create one if necessary. GMI objects also provide common functions:
for group in gmi.groups: print(group, group.name) for bot in gmi.bots: print(bot, bot.group) for chat in gmi.chats: print(chat, chat.other_user) test_group = gmi.groups.get(name='Testing Group') test_bot = gmi.bots.get(group_id=test_group.group_id) test_bot.post('Hello, world!')
GroupMe supports complex message structures, such as including GroupMe-specific emoji, pictures, etc. This information can be utilized through ComplexMessage objects:
from lowerpines.message import ImageAttach # This will dynamically create a ComplexMessage object: complex_message = ImageAttach('URL to GroupMe processed image here') + 'Look at my cool picture' test_bot.post(complex_message)
The various MessageAttach objects (such as ImageAttach, EmojiAttach, etc.) will automatically convert themselves into a ComplexMessage object when added to a str or to another MessageAttach object. However, a MessageAttach object is not a ComplexMessage object, so the following is not allowed:
test_bot.post(ImageAttach('URL here')) # This will trigger an exception
The correct way to do this is to create a ComplexMessage object manually:
from lowerpines.message import ComplexMessage complex_message = ComplexMessage(ImageAttach('URL here')) test_bot.post(complex_message)
Viewing messages for groups is also available:
for message in test_group.messages.recent(): print(message.text)
Each message’s text is also available as a ComplexMessage object through message.complex_text
Please see the docs directory for more information.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file lowerpines-0.6.0.tar.gz
.
File metadata
- Download URL: lowerpines-0.6.0.tar.gz
- Upload date:
- Size: 20.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 56bc490e2d8d7bb49d6e2722ac273ccbc412810947b01be3c8bf14021ba124a1 |
|
MD5 | c3ab40bb80289b9e5ba88bbcf7de7703 |
|
BLAKE2b-256 | 0397b3b884f82f090f955568b177d9473a13ccad13353196fe4797d5862ddb08 |
File details
Details for the file lowerpines-0.6.0-py3-none-any.whl
.
File metadata
- Download URL: lowerpines-0.6.0-py3-none-any.whl
- Upload date:
- Size: 26.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71f9893683452cdcb37d15156341a65308a8322ff3cb89c2ecaeee29b45d840e |
|
MD5 | 7db05e7e5854631afd58433410964ae5 |
|
BLAKE2b-256 | f9ae3cc7f9e9e5372da149199e305993e4566e26c2bfa3fb2dc9c0831f13a4ed |