Skip to content

Commit

Permalink
Client class useragent
Browse files Browse the repository at this point in the history
  • Loading branch information
d60 committed Aug 13, 2024
1 parent ded520f commit b3a5564
Showing 1 changed file with 11 additions and 23 deletions.
34 changes: 11 additions & 23 deletions twikit/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import asyncio
import io
import json
import warnings
import re
import warnings
from functools import partial
from typing import Any, AsyncGenerator, Literal

Expand All @@ -17,24 +17,12 @@
from ..bookmark import BookmarkFolder
from ..community import Community, CommunityMember
from ..constants import TOKEN
from ..errors import (
AccountLocked,
AccountSuspended,
BadRequest,
CouldNotTweet,
Forbidden,
InvalidMedia,
NotFound,
RequestTimeout,
ServerError,
TooManyRequests,
TweetNotAvailable,
TwitterException,
Unauthorized,
UserNotFound,
UserUnavailable,
raise_exceptions_from_response
)
from ..errors import (AccountLocked, AccountSuspended, BadRequest,
CouldNotTweet, Forbidden, InvalidMedia, NotFound,
RequestTimeout, ServerError, TooManyRequests,
TweetNotAvailable, TwitterException, Unauthorized,
UserNotFound, UserUnavailable,
raise_exceptions_from_response)
from ..geo import Place, _places_from_response
from ..group import Group, GroupMessage
from ..list import List
Expand All @@ -44,7 +32,8 @@
from ..trend import Location, PlaceTrend, PlaceTrends, Trend
from ..tweet import CommunityNote, Poll, ScheduledTweet, Tweet, tweet_from_data
from ..user import User
from ..utils import Flow, Result, build_tweet_data, build_user_data, find_dict, find_entry_by_type, httpx_transport_to_url
from ..utils import (Flow, Result, build_tweet_data, build_user_data,
find_dict, find_entry_by_type, httpx_transport_to_url)
from .gql import GQLClient
from .v11 import V11Client

Expand Down Expand Up @@ -81,6 +70,7 @@ def __init__(
language: str | None = None,
proxy: str | None = None,
captcha_solver: Capsolver | None = None,
user_agent: str | None = None,
**kwargs
) -> None:
if 'proxies' in kwargs:
Expand All @@ -99,9 +89,7 @@ def __init__(

self._token = TOKEN
self._user_id = None
self._user_agent = ('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) '
'AppleWebKit/537.36 (KHTML, like Gecko) '
'Chrome/122.0.0.0 Safari/537.36')
self._user_agent = user_agent or 'Mozilla/5.0 (Macintosh; Intel Mac OS X 14_6_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.5 Safari/605.1.15'
self._act_as = None

self.gql = GQLClient(self)
Expand Down

0 comments on commit b3a5564

Please sign in to comment.