Client¶
Client is the bread and butter of the Shawk framework. You’ll use this to connect to a Gmail account in both SMTP and IMAP protocols.
Typically the workflow will resemble creating a Client, adding contacts, configuring an inbox for IMAP, and listening for messages.
shawk.Client¶
Define the Client interface in Shawk.
-
class
shawk.Client.
Client
(user, pwd, inbox=True, auto=True)[source]¶ Bases:
object
Define the main Shawk interface.
-
add_contact
(number, carrier, name=None)[source]¶ Create a new Contact instance and add to contacts.
You can also pass a list of numbers, carriers, and names to create multiple at once.
-
enable_auto_refresh
(start=True)[source]¶ Enable auto refresh of inbox.
Will also begin refreshing now, but can be disabled with start=False.
-
get_contact
(message)[source]¶ Return the Contact from a given message’s sender.
Returns None if sender not in contacts.
-
get_contact_from_address
(address)[source]¶ Return the Contact matching a given address.
Returns None if not in contacts.
-
send
(message, contact=None, address=None, number=None, name=None, carrier=None)[source]¶ Send a message.
Can determine a contact to use via a number of different specifications, but it is advised to specify a Contact object if possible.
However, passing a specific address takes precedence over any other input.
-
setup_inbox
(password, user=None, folder='INBOX', refresh=False, auto=False, ssl=True)[source]¶ Configure an IMAP connection for receiving SMS.
Optionally configure behaviours such as auto-refresh, refresh immediately once configured, or specify a folder.
Folder specifications are useful if you configure your Gmail account to filter messages from certain senders to be moved to a specific folder, that way they don’t clutter your Gmail Inbox folder.
-