def getSubscriptionsFromUser(screen_name=None, user_id=None, cursor=None, Access: _WeakAccess.WeakAccess = None): ''' Reference: https://dev.twitter.com/rest/reference/get/lists/subscriptions ''' if (Access == None): Access = defaultAccess api = tweepy.API(Access.auth) lista = list() resp = api.lists_subscriptions(screen_name=screen_name, user_id=user_id, cursor=cursor) for L in resp: lista.append(_List.List(dictionary=L.__dict__)) return lista
def getList(owner_screen_name=None, owner_id=None, slug=None, list_id=None, Access: _WeakAccess.WeakAccess = None): ''' Reference: https://dev.twitter.com/rest/reference/get/lists/show ''' if (Access == None): Access = defaultAccess api = tweepy.API(Access.auth) lista = list() resp = api.get_list(owner_screen_name=owner_screen_name, owner_id=owner_id, slug=slug, list_id=list_id) return _List.List(dictionary=resp.__dict__)
def postReply(id, msg, latitude=None, longitude=None, place_id=None, Access: _StrongAccess.StrongAccess = None): """ :reference: https://dev.twitter.com/rest/reference/post/statuses/update :allowed_param:'status', 'in_reply_to_status_id', 'lat', 'long', 'source', 'place_id', 'display_coordinates', 'media_ids' """ if (Access == None): Access = defaultAccess api = tweepy.API(Access.auth) resp = api.update_status(in_reply_to_status_id=id, lat=latitude, long=longitude, status=msg, place_id=place_id) return _Tweet.Tweet(dictionary=resp.__dictt__())
def getMyMessages(Access: _StrongAccess.StrongAccess = None, since_id=None, max_id=None, count=None, full_text=None): '''Reference: https://dev.twitter.com/rest/reference/get/direct_messages ''' if (Access == None): Access = defaultAccess api = tweepy.API(Access.auth) messages = api.direct_messages(since_id=since_id, max_id=max_id, count=count, full_text=full_text) lista = list() for m in messages: lista.append(_DirectMessage.DirectMessage(dictionary=m)) return lista
def getHomeTimelineFromUser(Access: _StrongAccess.StrongAccess = None, id=id, count=None, since_id=None, max_id=None): ''' Reference: https://dev.twitter.com/rest/reference/get/statuses/home_timeline ''' if (Access == None): Access = defaultAccess api = tweepy.API(Access.auth) tweets = api.home_timeline(user_id=id, count=count, since_id=since_id, max_id=max_id) lista = list() for tweet in tweets: lista.append(_Tweet.Tweet(dictionary=tweet)) return lista
def getOembedFromTweet(url, Access: _WeakAccess.WeakAccess = None, maxwidth=None, hide_media=None, omit_script=None, align=None, related=None, lang=None): '''Reference https://dev.twitter.com/rest/reference/get/statuses/oembed ''' if (Access == None): Access = defaultAccess api = tweepy.API(Access.auth) return api.get_oembed(url=url, maxwidth=maxwidth, hide_media=hide_media, omit_script=omit_script, align=align, related=related, lang=lang)
def getListsMembershipFromUser(screen_name, count=None, cursor=None, filter_to_owned_lists=None, Access: _WeakAccess.WeakAccess = None): """ :reference: https://dev.twitter.com/rest/reference/get/lists/memberships """ if (Access == None): Access = defaultAccess api = tweepy.API(Access.auth) lista = list() resp = api.lists_memberships( screen_name=screen_name, filter_to_owned_lists=filter_to_owned_lists, cursor=cursor, count=count) for l in resp: lista.append(_List.List(dictionary=l.__dict__)) return lista
def postTweet(msg, latitude=None, longitude=None, reply_to=None, place_id=None, Access: _StrongAccess.StrongAccess = None): '''Reference: https://dev.twitter.com/rest/reference/post/statuses/update ''' if (Access == None): Access = defaultAccess api = tweepy.API(Access.auth) try: api.update_status(lat=latitude, long=longitude, status=msg, in_reply_to_status_id=reply_to, place_id=place_id) return True except tweepy.TweepError: return False
def postSubscribeDestroy(owner_screen_name=None, slug=None, owner_id=None, list_id=None, Access: _StrongAccess.StrongAccess = None): ''' Reference: https://dev.twitter.com/rest/reference/post/lists/subscribers/create ''' if (Access == None): Access = defaultAccess api = tweepy.API(Access.auth) lista = list() try: resp = api.unsubscribe_list(owner_screen_name=owner_screen_name, slug=slug, owner_id=owner_id, list_id=list_id) return resp except tweepy.TweepError: return False
def getMultipleTweet(ids: list, Access: _WeakAccess.WeakAccess = None, include_entities=None, trim_user=None, map=None): '''https://dev.twitter.com/rest/reference/get/statuses/lookup ''' if (Access == None): Access = defaultAccess string = "" for id in ids: string += str(id) + "," api = tweepy.API(Access.auth) tweets = api._statuses_lookup(id=string, include_entities=include_entities, trim_user=trim_user, map=map) lista = list() for tweet in tweets: lista.append(_Tweet.Tweet(dictionary=tweet)) return lista
def getTimelineFromUser(username, Access: _WeakAccess.WeakAccess = None, count=None, since_id=None, max_id=None, include_rts=False): ''' Reference https://dev.twitter.com/rest/reference/get/statuses/user_timeline ''' if (Access == None): Access = defaultAccess api = tweepy.API(Access.auth) lista = list() tweets = api.user_timeline(screen_name=username, count=count, since_id=since_id, max_id=max_id, include_rts=include_rts) for tweet in tweets: lista.append(_Tweet.Tweet(dictionary=tweet)) return lista
def getMembersFromList(owner_screen_name=None, slug=None, list_id=None, owner_id=None, cursor=None, Access: _WeakAccess.WeakAccess = None): ''' Reference: https://dev.twitter.com/rest/reference/get/lists/members ''' if (Access == None): Access = defaultAccess api = tweepy.API(Access.auth) lista = list() resp = api.list_members(owner_screen_name=owner_screen_name, slug=slug, list_id=list_id, owner_id=owner_id, cursor=cursor) for L in resp: lista.append(_TwitterUser.TwitterUser(dictionary=L.__dict__)) return lista
def postRemoveMemberFromList(screen_name=None, user_id=None, owner_screen_name=None, owner_id=None, slug=None, list_id=None, Access: _WeakAccess.WeakAccess = None): '''Reference: https://dev.twitter.com/docs/api/1.1/post/lists/members/destroy ''' if (Access == None): Access = defaultAccess api = tweepy.API(Access.auth) try: resp = api.remove_list_member(screen_name=screen_name, user_id=user_id, owner_screen_name=owner_screen_name, owner_id=owner_id, slug=slug, list_id=list_id) return True except tweepy.TweepError: return False
def searchTweets(q, Access: _WeakAccess.WeakAccess = None, lang=None, locale=None, since_id=None, geocode=None, max_id=None, since=None, until=None, result_type=None, count=None, include_entities=None, from_=None, to=None, source=None): '''Reference: reference: https://dev.twitter.com/rest/reference/get/search/tweets ''' if (Access == None): Access = defaultAccess api = tweepy.API(Access.auth) messages = api.search(q=q, lang=lang, locale=locale, since_id=since_id, geocode=geocode, max_id=max_id, since=since, until=until, result_type=result_type, count=count, include_entities=include_entities, to=to, source=source) lista = list() for m in messages: lista.append(_Tweet.Tweet(dictionary=m)) return lista
def postListMemberCreate(screen_name=None, user_id=None, owner_screen_name=None, owner_id=None, slug=None, list_id=None, Access: _StrongAccess.StrongAccess = None): ''' Reference: https://dev.twitter.com/rest/reference/post/lists/members/create ''' if (Access == None): Access = defaultAccess api = tweepy.API(Access.auth) lista = list() try: resp = api.add_list_member(screen_name=screen_name, user_id=user_id, owner_screen_name=owner_screen_name, owner_id=owner_id, slug=slug, list_id=list_id) return True except tweepy.TweepError: return False
def getUserIsMember(list_id=None, slug=None, user_id=None, screen_name=None, owner_screen_name=None, owner_id=None, Access: _WeakAccess.WeakAccess = None): ''' Reference: https://dev.twitter.com/rest/reference/get/lists/members/show ''' if (Access == None): Access = defaultAccess api = tweepy.API(Access.auth) lista = list() try: resp = api.show_list_member(list_id=list_id, slug=slug, user_id=user_id, screen_name=screen_name, owner_screen_name=owner_screen_name, owner_id=owner_id) return True except tweepy.TweepError: return False
def rate_limit_status(self): api = tweepy.API(self.auth) return api.rate_limit_status()
def __init__(self, token: _StrongAccess.StrongAccess): dictionary = tweepy.API(token.auth).me() usuario = _TwitterUser.TwitterUser(dictionary=dictionary) for k in usuario.__dict__.keys(): self.__dict__[k] = usuario.__dict__[k] self.token = token