You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
957 B

import configparser
import sys
import tweepy
from twitivity import Twitivity, TwitivityError
config = configparser.ConfigParser()
config.read('settings.cfg')
consumer_key = config.get('Twitter', 'consumer_key')
consumer_secret = config.get('Twitter', 'consumer_secret')
environment_name = config.get('Twitter', 'environment_name')
def unsubscribe(access_token, access_token_secret):
handler = tweepy.OAuthHandler(consumer_key, consumer_secret)
handler.set_access_token(access_token, access_token_secret)
twitivity = Twitivity(tweepy.API(handler), environment_name)
try:
twitivity.check_subscription()
except TwitivityError:
return
twitivity.unsubscribe()
def main():
try:
unsubscribe(*sys.argv[1:3])
except TypeError:
print('Not enough arguments!')
except TwitivityError as e:
print(str(e))
else:
print('Success.')
if __name__ == '__main__':
main()