def verify_credentials(self): from SolTw import _TwitterUser api = tweepy.API(self.auth) resp = api.verify_credentials() if resp != False: resp = _TwitterUser.TwitterUser(dictionary=resp.__dict__) return resp
def getUser(UsernameOrId, Access: _WeakAccess.WeakAccess = None): """ :reference: https://dev.twitter.com/rest/reference/get/users/show """ if (Access == None): Access = defaultAccess api = tweepy.API(Access.auth) user = api.get_user(UsernameOrId) return _TwitterUser.TwitterUser(dictionary=user)
def __init__(self, id=None, dictionary=dict()): dictionary = _Utils.CastToDictionary(dictionary) dictionary = _Utils.removeEmptyFields(dictionary) self.recipient_screen_name = "" self._api = "" self.id = id self.recipient = "" self.recipient_id = "" self.entities = "" self.recipient_id_str = "" self.sender_screen_name = "" self.id_str = "" self.sender_id = "" self.text = "" self.created_at = "" self.sender = "" self.sender_id_str = "" if ("recipient_screen_name" in dictionary): self.recipient_screen_name = dictionary["recipient_screen_name"] if ("id" in dictionary): self.id = dictionary["id"] if ("recipient" in dictionary): self.recipient = _TwitterUser.TwitterUser( dictionary=dictionary["recipient"]) if ("recipient_id" in dictionary): self.recipient_id = dictionary["recipient_id"] if ("entities" in dictionary): self.entities = _Entity.Entity(dictionary=dictionary["entities"]) if ("recipient_id_str" in dictionary): self.recipient_id_str = dictionary["recipient_id_str"] if ("sender_screen_name" in dictionary): self.sender_screen_name = dictionary["sender_screen_name"] if ("id_str" in dictionary): self.id_str = dictionary["id_str"] if ("sender_id" in dictionary): self.sender_id = dictionary["sender_id"] if ("text" in dictionary): self.text = dictionary["text"] if ("created_at" in dictionary): self.created_at = dictionary["created_at"] if ("sender" in dictionary): self.sender = _TwitterUser.TwitterUser( dictionary=dictionary["sender"]) if ("sender_id_str" in dictionary): self.sender_id_str = dictionary["sender_id_str"]
def postBlockDestroy(user, Access: _StrongAccess.StrongAccess = None): """ :reference: https://dev.twitter.com/rest/reference/post/blocks/destroy :allowed_param:'id', 'user_id', 'screen_name' """ if (Access == None): Access = defaultAccess api = tweepy.API(Access.auth) resp = api.destroy_block(id=user) return _TwitterUser.TwitterUser(dictionary=resp)
def postFriendshipDestroy(user, Access: _StrongAccess.StrongAccess = None): """ :reference: https://dev.twitter.com/rest/reference/post/friendships/destroy """ from SolTw import _TwitterUser if (Access == None): Access = defaultAccess api = tweepy.API(Access.auth) return _TwitterUser.TwitterUser(dictionary=api.destroy_friendship( id=user))
def getMultipleUsers(Ids_List, Access: _WeakAccess.WeakAccess = None): """:reference: https://dev.twitter.com/rest/reference/get/users/show """ if (Access == None): Access = defaultAccess api = tweepy.API(Access.auth) users = api.lookup_users(Ids_List) lista = list() for user in users: lista.append(_TwitterUser.TwitterUser(dictionary=user)) return lista
def getBlocks(Access: _StrongAccess.StrongAccess = None): """ :reference: https://dev.twitter.com/rest/reference/get/blocks/list :allowed_param:'cursor' """ if (Access == None): Access = defaultAccess api = tweepy.API(Access.auth) users = api.blocks() lista = list() for u in users: lista.append(_TwitterUser.TwitterUser(dictionary=u)) return lista
def postFriendshipCreate(user, follow: bool = None, Access: _StrongAccess.StrongAccess = None): """ :reference: https://dev.twitter.com/rest/reference/post/friendships/create """ from SolTw import _TwitterUser if (Access == None): Access = defaultAccess api = tweepy.API(Access.auth) return _TwitterUser.TwitterUser( dictionary=api.create_friendship(id=user, follow=follow))
def getFriendshipOutgoingFromUser( Access: _StrongAccess.StrongAccess = None, cursor=None): '''Pega requisições de amizade feita pelo usuario Documentado em https://dev.twitter.com/rest/reference/get/friendships/outgoing ''' from SolTw import _TwitterUser if (Access == None): Access = defaultAccess api = tweepy.API(Access.auth) friends = api.friendships_outgoing(cursor=cursor) lista = list() for f in friends: lista.append(_TwitterUser.TwitterUser(id=f)) return lista
def getSuggestedUsersWithTweetBySlug(slug, lang=None, Access: _StrongAccess. StrongAccess = None): """ :reference: https://dev.twitter.com/rest/reference/get/users/suggestions/%3Aslug/members """ if (Access == None): Access = defaultAccess api = tweepy.API(Access.auth) resp = api.suggested_users_tweets(slug=slug, lang=lang) lista = list() for u in resp: lista.append(_TwitterUser.TwitterUser(dictionary=u)) return lista
def postUpdateProfile(name=None, url=None, location=None, description=None, Access: _StrongAccess.StrongAccess = None): """ :reference: https://dev.twitter.com/rest/reference/post/account/update_profile """ if (Access == None): Access = defaultAccess api = tweepy.API(Access.auth) resp = api.update_profile(name=name, url=url, location=location, description=description) return _TwitterUser.TwitterUser(dictionary=resp)
def getFriendsFromUser(id, Access: _WeakAccess.WeakAccess = None, cursor=None): '''Pega os amigos do usuario Documentado em https://dev.twitter.com/rest/reference/get/friends/list ''' from SolTw import _TwitterUser if (Access == None): Access = defaultAccess api = tweepy.API(Access.auth) friends = api.friends(user_id=id, cursor=cursor) lista = list() for f in friends: lista.append(_TwitterUser.TwitterUser(dictionary=f)) return lista
def getRetweetersFromTweet(id, Access: _WeakAccess.WeakAccess = None, cursor=None, stringify_ids=None): '''Reference https://dev.twitter.com/rest/reference/get/statuses/retweeters/ids ''' if (Access == None): Access = defaultAccess api = tweepy.API(Access.auth) users = api.retweeters(id=id, cursor=cursor, stringify_ids=stringify_ids) lista = list() for user in users: lista.append(_TwitterUser.TwitterUser(id=user)) return lista
def getFollowersFromUser(id, Access: _WeakAccess.WeakAccess = None, cursor=None, count=None): '''Pega os seguidores do usuario Documentado em https://dev.twitter.com/rest/reference/get/followers/list ''' from SolTw import _TwitterUser if (Access == None): Access = defaultAccess api = tweepy.API(Access.auth) users = api.followers(user_id=id, cursor=cursor, count=count) lista = list() for u in users: lista.append(_TwitterUser.TwitterUser(dictionary=u)) 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 __init__(self, id="", dictionary=dict()): dictionary = _Utils.CastToDictionary(dictionary) dictionary = _Utils.removeEmptyFields(dictionary) self.annotations = "" self.contributors = list() self.coordinates = "" self.created_at = "" self.current_user_retweet = "" self.entities = "" self.favorite_count = "" self.favorited = "" self.filter_level = "" self.id = id self.id_str = "" self.in_reply_to_screen_name = "" self.lang = "" self.place = "" self.possibly_sensitive = "" self.quoted_status_id = "" self.quoted_status_id_str = "" self.quoted_status = "" self.scopes = "" self.retweet_count = "" self.retweeted = "" self.retweeted_status = "" self.source = "" self.text = "" self.truncated = "" self.user = "" self.withheld_copyright = "" self.withheld_in_countries = "" self.withheld_scope = "" if ("annotations" in dictionary): self.annotations = dictionary["annotations"] if ("contributors" in dictionary): for cont in dictionary["contributors"]: self.contributors.append( _Contributor.Contributor(dictionary=cont)) if ("coordinates" in dictionary): self.coordinates = _Coordinates.Coordinates( dictionary=dictionary["coordinates"]) if ("created_at" in dictionary): self.created_at = dictionary["created_at"] if ("current_user_retweet" in dictionary): self.current_user_retweet = dictionary["current_user_retweet"] if ("entities" in dictionary): self.entities = _Entity.Entity(dictionary=dictionary["entities"]) if ("favorite_count" in dictionary): self.favorite_count = dictionary["favorite_count"] if ("favorited" in dictionary): self.favorited = dictionary["favorited"] if ("filter_level" in dictionary): self.filter_level = dictionary["filter_level"] if ("id" in dictionary): self.id = dictionary["id"] if ("id_str" in dictionary): self.id_str = dictionary["id_str"] if ("in_reply_to_screen_name" in dictionary): self.in_reply_to_screen_name = dictionary[ "in_reply_to_screen_name"] if ("lang" in dictionary): self.lang = dictionary["lang"] if ("place" in dictionary): self.place = _Place.Place(dictionary=dictionary["place"]) if ("possibly_sensitive" in dictionary): self.possibly_sensitive = dictionary["possibly_sensitive"] if ("quoted_status_id" in dictionary): self.quoted_status_id = dictionary["quoted_status_id"] if ("quoted_status_id_str" in dictionary): self.quoted_status_id_str = dictionary["quoted_status_id_str"] if ("quoted_status" in dictionary): self.quoted_status = Tweet(dictionary=dictionary["quoted_status"]) if ("scopes" in dictionary): self.scopes = dictionary["scopes"] if ("retweet_count" in dictionary): self.retweet_count = dictionary["retweet_count"] if ("retweeted" in dictionary): self.retweeted = dictionary["retweeted"] if ("retweeted_status" in dictionary): self.retweeted_status = Tweet( dictionary=dictionary["retweeted_status"]) if ("source" in dictionary): self.source = dictionary["source"] if ("text" in dictionary): self.text = dictionary["text"] if ("truncated" in dictionary): self.truncated = dictionary["truncated"] if ("user" in dictionary): self.user = _TwitterUser.TwitterUser(dictionary=dictionary["user"]) if ("withheld_copyright" in dictionary): self.withheld_copyright = dictionary["withheld_copyright"] if ("withheld_in_countries" in dictionary): self.withheld_in_countries = dictionary["withheld_in_countries"] if ("withheld_scope" in dictionary): self.withheld_scope = dictionary["withheld_scope"]
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