Schedule Twitter updates with easy

Overview

Logo

coo: schedule Twitter updates with easy

PyPI version Build Status codecov Docs License

Coo is an easy to use Python library for scheduling Twitter updates. To use it, you need to first apply for a developer account in the Twitter Developers Platform and generate the Keys and Access Tokens.

pip install coo

Initializing

from coo import Coo

at = Coo(
    "consumer_key",
    "consumer_secret",
    "access_token",
    "access_token_secret",
    preview=False
)

Alternatively, you can set preview=True and print your tweets in the terminal instead to post them on Twitter.

Scheduling Twitter updates:

from coo import Coo

at = Coo(
    "consumer_key",
    "consumer_secret",
    "access_token",
    "access_token_secret"
)

tweets = [
    ("2030-10-28 18:50", template, "My Twitter update with a template."),
    ("2030-10-29 18:15", template2, "Update with a different template."),
    ("2030-11-01 13:45", None, "Awesome Twitter update without a template."),
]

at.schedule(tweets, time_zone="America/Santiago")

Or you can use a list of strings and add a delay, interval and a template:

tweets = [
    "My first awesome Twitter Update",
    "My second awesome Twitter Update",
    "My third awesome Twitter Update",
    "My fourth awesome Twitter Update",
    "My fifth awesome Twitter Update",
    "My sixth awesome Twitter Update",
]

at.tweet(tweets, delay="13:45", interval="four_hours", template=my_template)

For more detailed options and usage, keep reading or check the documentation 📘 .

Scheduling Twitter Updates

Schedule updates with datetime strings or integers and use custom templates if needed.

Coo.schedule(updates, time_zone, media)

Full example:

from coo import Coo

at = Coo(
    "consumer_key",
    "consumer_secret",
    "access_token",
    "access_token_secret"
)

tweets = [
    # datetime with and without templates
    ("2030-10-28 18:50", template, "My Twitter update with a template."),
    ("2030-10-29 18:15", template2, "Update with a different template."),
    ("2030-11-01 13:45", None, "Awesome Twitter update without a template."),

    # date with and without templates
    ("2030-12-25", template3, "Merry christmas!"),
    ("2031-01-01", None, "And a happy new year!"),

    # time with and without templates
    ("18:46", template2, "Will be post today at 18:46."),
    ("23:00", None, "A tweet for today at 23:00."),

    # integer (seconds) with and without templates
    (3600, template, "This tweet will be posted in an hour."),
    (86400, None, "This one, tomorrow at the same hour."),
]

at.schedule(tweets, time_zone="America/Santiago")

Notes for parsing DateTime strings

  • If a time zone is not specified, it will set to local.
  • The time will be set to 00:00:00 if it's not specified.
  • When passing only time information the date will default to today.
  • A future date is needed, otherwise a ScheduleError is raised.

Here you can find all the Time Zones available.

Media files

There are two ways to add media files to your tweets. The first and easiest is to use one global file for all the updates:

at.schedule(tweets, time_zone="America/Santiago", media="path/to/file.png")

Also, an individual file can be set for each one of the updates:

tweets = [
    ("2030-10-28 18:50", template, "Update with an image.", "pics/owl.png"),
    ("2030-10-29 18:15", template, "Update with other media.", "videos/funny_video.mp4"),
    ("2030-11-01 13:45", template, "Tweet without media."),
]

Finally, it is possible to combine these to ways. For example, if most of the tweets are gonna use the same media and just a few will have a different or none:

tweets = [
    ("2030-11-01 13:45", template, "Tweet with global media."),
    ("2030-11-02 13:45", template, "Tweet with global media."),
    ("2030-11-03 13:45", template, "Tweet with global media."),
    ("2030-11-04 13:45", template, "Tweet with global media."),
    ("2030-11-05 13:45", template, "Tweet with global media."),
    ("2030-11-06 13:45", template, "Tweet with global media."),
    ("2030-11-07 13:45", template, "Tweet with global media."),
    ("2030-11-08 13:45", template, "Tweet without media.", None),
    ("2030-11-09 13:45", template, "Tweet without media.", None),
    ("2030-12-10 18:50", template, "Update with an image.", "pics/owl.png"),
    ("2030-12-11 18:15", template, "Update with other media.", "videos/funny_video.mp4"),
]

at.schedule(tweets, time_zone="America/Santiago", media="path/to/global_media.png")

Tweet a list of strings

Post ordered updates with delay, interval, and a template if needed.

Coo.tweet(updates, delay, interval, template, media, time_zone, aleatory)
from coo import Coo

at = Coo(
    "consumer_key",
    "consumer_secret",
    "access_token",
    "access_token_secret"
)

tweets = [
    "My first awesome Twitter Update",
    "My second awesome Twitter Update",
    "My third awesome Twitter Update",
    "My fourth awesome Twitter Update",
    "My fifth awesome Twitter Update",
    "My sixth awesome Twitter Update",
]

# post the twitter updates
at.tweet(tweets)

Delay

You can use datetime, date and time strings, integers as seconds and some strings as keywords: half_hour, one_hour, one_day and one_week between others to delay the post of your first update.

# datetime, date and time strings
at.tweet(tweets, delay="2030-11-24 13:45", time_zone="America/Santiago")
at.tweet(tweets, delay="2030-11-24", time_zone="Australia/Sydney")
at.tweet(tweets, delay="13:45", time_zone="America/New_York")

# "keywords"
at.tweet(tweets, delay="one_week")

# integer
at.tweet(tweets, delay=604800)

Remember to read the Notes for parsing DateTime strings.

Interval

Use integers as seconds or some strings as keywords: half_hour, one_hour, one_day and one_week between others.

# "keywords"
at.tweet(tweets, interval="four_hours")

# integers
at.tweet(tweets, interval=14400)

Template

And of course, you can also set one template for each one of the updates.

at.tweet(tweets, template=template)

Media files

Use one media file for all of your updates:

at.tweet(tweets, media="path/to/media.jpeg")

Random updates

To tweet your updates randomly:

at.tweet(tweets, aleatory=True)

Delay and Interval Keywords

Keyword Seconds
now 0
half_hour 1800
one_hour 3600
two_hours 7200
four_hours 14400
six_hours 21600
eight_hours 28800
ten_hours 36000
twelve_hours 43200
fourteen_hours 50400
sixteen_hours 57600
eighteen_hours 64800
twenty_hours 72000
twenty_two_hours 79200
one_day 86400
two_days 172800
three_days 259200
four_days 345600
five_days 432000
six_days 518400
one_week 604800

Templates

Templates are very simple, just use a multiline string and add a $message where you want your message to appear.

template = """My awesome header

$message

#python #coding #coo
"""

The Twitter API

Coo is written using the Python Twitter wrapper, and through Coo.api you gain access to all of his models:

# get your followers
followers = at.api.GetFollowers()

# get your direct messages
d_messages = at.api.GetDirectMessages()

# favorited tweets
favorites = at.api.GetFavorites()

# mentions
mentions = at.api.GetMentions()

# retweets
retweets = at.api.GetRetweets()

And a lot more. If you are interested, check their documentation.

TODO's

  • Add support for random updates.
  • Add support for media files.
  • Add support for multiple media files.
  • Add support for a history of tweets.
  • Add support for media files from URLs.
  • Add support for one template for all updates on Coo.schedule.
  • Support .toml files for configuration and tweets.
  • Support resume after a process restart (see apscheduler).
  • Add a CLI.

Documentation

Documentation available at coo.readthedocs.io.

You might also like...
Policy and data administration, distribution, and real-time updates on top of Open Policy Agent
Policy and data administration, distribution, and real-time updates on top of Open Policy Agent

⚡ OPAL ⚡ Open Policy Administration Layer OPAL is an administration layer for Open Policy Agent (OPA), detecting changes to both policy and policy dat

An App to get Ko-Fi payment updates on Telegram.
An App to get Ko-Fi payment updates on Telegram.

Deployments. Heroku.com 🚀 Replit.com 🌀 Make sure your app runs 24*7 Zeet.co 💪 Use this :~ Get Bot token from @botfather 🤖 Get ID where you want to

This is a simple bot that can be used to upload images to a third-party cloud (image hosting). Currently, only the imgbb.com website supports the bot. I Will do future updates

TGImageHosting This is a simple bot that can be used to upload images to a third party cloud (image hosting). Currently, only the imgbb.com website su

Send GitHub Issues, PRs or Discussions Updates to Wechat
Send GitHub Issues, PRs or Discussions Updates to Wechat

Send GitHub Issues, PRs or Discussions Updates to Wechat

Live Weather Updates using Flask and OpenWeather

AuraX Live Weather Updates using Flask and OpenWeather Installation To setup this project on your local machine, first clone this repository and insta

A bot that updates about the most subscribed artist' channels on YouTube
A bot that updates about the most subscribed artist' channels on YouTube

A bot that updates about the most subscribed artist' channels on YouTube. A weekly top chart report is provided every Monday. It posts updates on Twitter

Battle.net and PlayStation title watcher that reports updates via Discord.
Battle.net and PlayStation title watcher that reports updates via Discord.

Renovate Renovate is a Battle.net and PlayStation title watcher that reports updates via Discord. Usage Open config_example.json and provide the confi

 A bot to view Garfield comics directly from Discord and get updates of the comics automatically
A bot to view Garfield comics directly from Discord and get updates of the comics automatically

Garfield-Bot A bot to view Garfield comics directly from Discord and get updates of the comics automatically. Instructions to use the bot: Invite the

Program that uses Python to monitor grade updates in the Genesis Platform

Genesis-Grade-Monitor Program that uses Python to monitor grade updates in the Genesis Platform Guide: Install by either cloning the repo or downloadi

Comments
  • Preventing Runtime Error caused by

    Preventing Runtime Error caused by "Event loop is closed"

    This PR aims to improve test reliability by initializing coo_preview_instance.loop before executing asyncio.run_until_complete by calling method asyncio.new_event_loop in order to prevent Runtime Error caused by "Event loop is closed".

    The test can fail in the following way if coo_preview_instance.loop is not initialized:

    >       coo_preview_instance.schedule(updates, time_zone="Canada/Yukon", media="../coo.png")
    
    tests/test_coo.py:149: 
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    coo/coo.py:228: in schedule
        self.loop.run_until_complete(self._async_tasks(updates))
    /usr/lib/python3.8/asyncio/base_events.py:591: in run_until_complete
        self._check_closed()
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    
    self = <_UnixSelectorEventLoop running=False closed=True debug=False>
    
        def _check_closed(self):
            if self._closed:
    >           raise RuntimeError('Event loop is closed')
    E           RuntimeError: Event loop is closed
    
    opened by sturmianseq 0
Releases(0.1.3)
  • 0.1.3(Dec 13, 2018)

    Added

    • Added support to post updates randomly on Coo.tweet(aleartory=True).
    • Added support for updates with a single media file for all tweets on Coo.tweet().
    • Added support for updates with a single media file for all tweets on Coo.schedule().
    • Added support for updates with a different media file for each tweet on Coo.schedule().
    Source code(tar.gz)
    Source code(zip)
  • 0.1.2(Nov 29, 2018)

    Added

    • Added changes to CHANGELOG.md.
    • Added changes to the documentation.
    • Added releases.

    Fixed

    • Fixed template overwriting the tweets when $message is not provided.
    • Fixed lots of typos.
    Source code(tar.gz)
    Source code(zip)
  • 0.1.1(Nov 29, 2018)

You cant check for conflicts until course enrolment actually opens. I wanted to do it earlier.

AcornICS I noticed that Acorn it does not let you check if a timetable is valid based on the enrollment cart, it also does not let you visualize it ea

Isidor Kaplan 2 Sep 16, 2021
Step by Step Guide To Install Discord Py Master Branch on Replit

Guide to Install Discord Py Master Branch on Replit Step 1 Create an empty repl on replit Step 2 Add this Basic Code to the file main.py so as to chec

Pranav Saxena 7 Nov 18, 2022
An advanced QR Code telegram bot with more features.

QR Code Bot A telegram qr code encode and decode bot Advanced Features 1. Database ( MongoDB ) Support 2. Broadcast Support 3. Status Command 4. Setti

Fayas Noushad 16 Nov 12, 2022
Properly-formatted dynamic timestamps for Discord messages

discord-timestamps discord-timestamps generates properly-formatted dynamic timestamps for Discord messages, with support for Arrow objects. format

Ben Soyka 2 Mar 10, 2022
Discord-Token-Formatter - A simple script to convert discord tokens from email token to token only format

Discord-Token-Formatter A simple script to convert discord tokens from email:pas

2 Oct 23, 2022
WeChat SDK for Python

___ __ _______ ________ ___ ___ ________ _________ ________ ___ ___ |\ \ |\ \|\ ___ \ |\ ____\|\ \|\ \|\ __ \|\___

wechatpy 3.3k Dec 26, 2022
Fastest Tiktok Username checker on site.

Tiktok Username Checker Fastest Tiktok Username checker on site

sql 3 Jun 19, 2021
Finds Jobs on LinkedIn using web-scraping

Find Jobs on LinkedIn 📔 This program finds jobs by scraping on LinkedIn 👨‍💻 Relies on User Input. Accepts: Country, City, State 📑 Data about jobs

Matt 44 Dec 27, 2022
An advanced crypto trading bot written in Python

Jesse Jesse is an advanced crypto trading framework which aims to simplify researching and defining trading strategies. Why Jesse? In short, Jesse is

Jesse 4.4k Jan 09, 2023
Based on nonebot, a common bot framework for maimai.

mai bot 使用指南 此 README 提供了最低程度的 mai bot 教程与支持。 Step 1. 安装 Python 请自行前往 https://www.python.org/ 下载 Python 3 版本( 3.7)并将其添加到环境变量(在安装过程中勾选 Add to system P

Diving-Fish 150 Jan 01, 2023
Clubhouse API written in Python. Standalone client included. For reference and education purposes only.

clubhouse-py is originally developed for the sake of interoperability. Standalone client is also created with very basic features, including but not limited to the audio-chat

1.7k Jan 05, 2023
Kali Kush - Account Nuker Tool

Kali Kush - Account Nuker Tool This is a discord tool made by me, and SSL :) antho#1731 How to use? pip3 install -r requirements.txt -py kalikush.py -

ryan 3 Dec 21, 2021
KaydyPurge - Python Purge Script for Discord made by Kaydy Cain#0001

How to Install Open terminal Execute "git clone https://github.com/apolo1337/Kay

apolo 5 Jan 27, 2022
Nasdaq Cloud Data Service (NCDS) provides a modern and efficient method of delivery for realtime exchange data and other financial information. This repository provides an SDK for developing applications to access the NCDS.

Nasdaq Cloud Data Service (NCDS) Nasdaq Cloud Data Service (NCDS) provides a modern and efficient method of delivery for realtime exchange data and ot

Nasdaq 8 Dec 01, 2022
ABACUS Aroio API for Webinterfaces and App-Connections

ABACUS Aroio API for Webinterfaces and App-Connections Setup Start virtual python environment if you don't have python3 running setup: $ python3 -m ve

Abacus Aroio Developer Team 1 Apr 01, 2021
This is Source Code of PdiskUploaderBot

PdiskUploaderBot This is the source code of PdiskUploaderBot. And the developer of this bot is AJTimePyro, His Telegram Channel & Group. You can use t

Abhijeet 8 Oct 20, 2022
PancakeTrade - Limit orders and more for PancakeSwap on Binance Smart Chain

PancakeTrade helps you create limit orders and more for your BEP-20 tokens that swap against BNB on PancakeSwap. The bot is controlled by Telegram so you can interact from anywhere.

Valentin Bersier 187 Dec 20, 2022
GTK3-based panel for sway window manager

nwg-panel I have been using sway since 2019 and find it the most comfortable working environment, but... Have you ever missed all the graphical bells

Piotr Miller 290 Jan 07, 2023
Slash util - A simple script to add application command support to discord.py v2.0

slash_util is a simple wrapper around slash commands for discord.py This is writ

Maya 28 Nov 16, 2022
An open source development framework to help you build data workflows and modern data architecture on AWS.

AWS DataOps Development Kit (DDK) The AWS DataOps Development Kit is an open source development framework for customers that build data workflows and

Amazon Web Services - Labs 111 Dec 23, 2022