text stringlengths 81 112k |
|---|
See: https://core.telegram.org/bots/api#sendchataction
def sendChatAction(self, chat_id, action):
""" See: https://core.telegram.org/bots/api#sendchataction """
p = _strip(locals())
return self._api_request('sendChatAction', _rectify(p)) |
See: https://core.telegram.org/bots/api#getuserprofilephotos
def getUserProfilePhotos(self, user_id,
offset=None,
limit=None):
""" See: https://core.telegram.org/bots/api#getuserprofilephotos """
p = _strip(locals())
return self._api_req... |
See: https://core.telegram.org/bots/api#promotechatmember
def promoteChatMember(self, chat_id, user_id,
can_change_info=None,
can_post_messages=None,
can_edit_messages=None,
can_delete_messages=None,
... |
See: https://core.telegram.org/bots/api#exportchatinvitelink
def exportChatInviteLink(self, chat_id):
""" See: https://core.telegram.org/bots/api#exportchatinvitelink """
p = _strip(locals())
return self._api_request('exportChatInviteLink', _rectify(p)) |
See: https://core.telegram.org/bots/api#setchatphoto
def setChatPhoto(self, chat_id, photo):
""" See: https://core.telegram.org/bots/api#setchatphoto """
p = _strip(locals(), more=['photo'])
return self._api_request_with_file('setChatPhoto', _rectify(p), 'photo', photo) |
See: https://core.telegram.org/bots/api#deletechatphoto
def deleteChatPhoto(self, chat_id):
""" See: https://core.telegram.org/bots/api#deletechatphoto """
p = _strip(locals())
return self._api_request('deleteChatPhoto', _rectify(p)) |
See: https://core.telegram.org/bots/api#leavechat
def leaveChat(self, chat_id):
""" See: https://core.telegram.org/bots/api#leavechat """
p = _strip(locals())
return self._api_request('leaveChat', _rectify(p)) |
See: https://core.telegram.org/bots/api#getchat
def getChat(self, chat_id):
""" See: https://core.telegram.org/bots/api#getchat """
p = _strip(locals())
return self._api_request('getChat', _rectify(p)) |
See: https://core.telegram.org/bots/api#getchatadministrators
def getChatAdministrators(self, chat_id):
""" See: https://core.telegram.org/bots/api#getchatadministrators """
p = _strip(locals())
return self._api_request('getChatAdministrators', _rectify(p)) |
See: https://core.telegram.org/bots/api#getchatmemberscount
def getChatMembersCount(self, chat_id):
""" See: https://core.telegram.org/bots/api#getchatmemberscount """
p = _strip(locals())
return self._api_request('getChatMembersCount', _rectify(p)) |
See: https://core.telegram.org/bots/api#answershippingquery
def answerShippingQuery(self, shipping_query_id, ok,
shipping_options=None,
error_message=None):
""" See: https://core.telegram.org/bots/api#answershippingquery """
p = _strip(locals())
... |
See: https://core.telegram.org/bots/api#answerprecheckoutquery
def answerPreCheckoutQuery(self, pre_checkout_query_id, ok,
error_message=None):
""" See: https://core.telegram.org/bots/api#answerprecheckoutquery """
p = _strip(locals())
return self._api_request('an... |
See: https://core.telegram.org/bots/api#editmessagetext
:param msg_identifier:
a 2-tuple (``chat_id``, ``message_id``),
a 1-tuple (``inline_message_id``),
or simply ``inline_message_id``.
You may extract this value easily with :meth:`telepot.message_identifier`
... |
See: https://core.telegram.org/bots/api#editmessagecaption
:param msg_identifier: Same as ``msg_identifier`` in :meth:`telepot.Bot.editMessageText`
def editMessageCaption(self, msg_identifier,
caption=None,
parse_mode=None,
reply... |
See: https://core.telegram.org/bots/api#uploadstickerfile
def uploadStickerFile(self, user_id, png_sticker):
"""
See: https://core.telegram.org/bots/api#uploadstickerfile
"""
p = _strip(locals(), more=['png_sticker'])
return self._api_request_with_file('uploadStickerFile', _rect... |
See: https://core.telegram.org/bots/api#createnewstickerset
def createNewStickerSet(self, user_id, name, title, png_sticker, emojis,
contains_masks=None,
mask_position=None):
"""
See: https://core.telegram.org/bots/api#createnewstickerset
... |
See: https://core.telegram.org/bots/api#addstickertoset
def addStickerToSet(self, user_id, name, png_sticker, emojis,
mask_position=None):
"""
See: https://core.telegram.org/bots/api#addstickertoset
"""
p = _strip(locals(), more=['png_sticker'])
return se... |
See: https://core.telegram.org/bots/api#setstickerpositioninset
def setStickerPositionInSet(self, sticker, position):
"""
See: https://core.telegram.org/bots/api#setstickerpositioninset
"""
p = _strip(locals())
return self._api_request('setStickerPositionInSet', _rectify(p)) |
See: https://core.telegram.org/bots/api#setgamescore
:param game_message_identifier: Same as ``msg_identifier`` in :meth:`telepot.Bot.editMessageText`
def setGameScore(self, user_id, score, game_message_identifier,
force=None,
disable_edit_message=None):
"""
... |
See: https://core.telegram.org/bots/api#getgamehighscores
:param game_message_identifier: Same as ``msg_identifier`` in :meth:`telepot.Bot.editMessageText`
def getGameHighScores(self, user_id, game_message_identifier):
"""
See: https://core.telegram.org/bots/api#getgamehighscores
:par... |
Download a file to local disk.
:param dest: a path or a ``file`` object
def download_file(self, file_id, dest):
"""
Download a file to local disk.
:param dest: a path or a ``file`` object
"""
f = self.getFile(file_id)
try:
d = dest if _isfile(dest) ... |
:param s:
a list or set of chat id
:param types:
``all`` or a list of chat types (``private``, ``group``, ``channel``)
:return:
a seeder function that returns the chat id only if the chat id is in ``s``
and chat type is in ``types``.
def per_chat_id_in(s, types='all'):
"""... |
:param s:
a list or set of chat id
:param types:
``all`` or a list of chat types (``private``, ``group``, ``channel``)
:return:
a seeder function that returns the chat id only if the chat id is *not* in ``s``
and chat type is in ``types``.
def per_chat_id_except(s, types='all'... |
:param flavors:
``all`` or a list of flavors
:return:
a seeder function that returns the from id only if the message flavor is
in ``flavors``.
def per_from_id(flavors=chat_flavors+inline_flavors):
"""
:param flavors:
``all`` or a list of flavors
:return:
a seed... |
:param s:
a list or set of from id
:param flavors:
``all`` or a list of flavors
:return:
a seeder function that returns the from id only if the from id is in ``s``
and message flavor is in ``flavors``.
def per_from_id_in(s, flavors=chat_flavors+inline_flavors):
"""
:pa... |
:param s:
a list or set of from id
:param flavors:
``all`` or a list of flavors
:return:
a seeder function that returns the from id only if the from id is *not* in ``s``
and message flavor is in ``flavors``.
def per_from_id_except(s, flavors=chat_flavors+inline_flavors):
"... |
:return:
a seeder function that returns an event's source id only if that event's
source space equals to ``event_space``.
def per_event_source_id(event_space):
"""
:return:
a seeder function that returns an event's source id only if that event's
source space equals to ``event_sp... |
:param types:
``all`` or a list of chat types (``private``, ``group``, ``channel``)
:return:
a seeder function that returns a callback query's originating chat id
if the chat type is in ``types``.
def per_callback_query_chat_id(types='all'):
"""
:param types:
``all`` or a l... |
:param origins:
``all`` or a list of origin types (``chat``, ``inline``)
:return:
a seeder function that returns a callback query's origin identifier if
that origin type is in ``origins``. The origin identifier is guaranteed
to be a tuple.
def per_callback_query_origin(origins='all... |
:return:
a delegator function that returns a tuple (``func``, (seed tuple,)+ ``args``, ``kwargs``).
That is, seed tuple is inserted before supplied positional arguments.
By default, a thread wrapping ``func`` and all those arguments is spawned.
def call(func, *args, **kwargs):
"""
:retu... |
:return:
a delegator function that calls the ``cls`` constructor whose arguments being
a seed tuple followed by supplied ``*args`` and ``**kwargs``, then returns
the object's ``run`` method. By default, a thread wrapping that ``run`` method
is spawned.
def create_run(cls, *args, **kwarg... |
:return:
a delegator function that calls the ``cls`` constructor whose arguments being
a seed tuple followed by supplied ``*args`` and ``**kwargs``, then returns
a looping function that uses the object's ``listener`` to wait for messages
and invokes instance method ``open``, ``on_message... |
Try a list of seeder functions until a condition is met.
:param condition:
a function that takes one argument - a seed - and returns ``True``
or ``False``
:param fns:
a list of seeder functions
:return:
a "composite" seeder function that calls each supplied function in tur... |
The basic pair producer.
:return:
a (seeder, delegator_factory(\*args, \*\*kwargs)) tuple.
:param seeders:
If it is a seeder function or a list of one seeder function, it is returned
as the final seeder. If it is a list of more than one seeder function, they
are chained togethe... |
:return:
a pair producer that ensures the seeder and delegator share the same event space.
def pave_event_space(fn=pair):
"""
:return:
a pair producer that ensures the seeder and delegator share the same event space.
"""
global _event_space
event_space = next(_event_space)
@_en... |
:return:
a pair producer that enables static callback query capturing
across seeder and delegator.
:param types:
``all`` or a list of chat types (``private``, ``group``, ``channel``)
def include_callback_query_chat_id(fn=pair, types='all'):
"""
:return:
a pair producer that... |
:return:
a pair producer that enables dynamic callback query origin mapping
across seeder and delegator.
:param origins:
``all`` or a list of origin types (``chat``, ``inline``).
Origin mapping is only enabled for specified origin types.
def intercept_callback_query_origin(fn=pair,... |
Access Bot API through a proxy.
:param url: proxy URL
:param basic_auth: 2-tuple ``('username', 'password')``
def set_proxy(url, basic_auth=None):
"""
Access Bot API through a proxy.
:param url: proxy URL
:param basic_auth: 2-tuple ``('username', 'password')``
"""
global _pools, _onet... |
:type relax: float
:param relax: seconds between each :meth:`.getUpdates`
:type offset: int
:param offset:
initial ``offset`` parameter supplied to :meth:`.getUpdates`
:type timeout: int
:param timeout:
``timeout`` parameter supplied to :meth:`.getUpdate... |
:type maxhold: float
:param maxhold:
The maximum number of seconds an update is held waiting for a
not-yet-arrived smaller ``update_id``. When this number of seconds
is up, the update is delivered to the message-handling function
even if some smaller ``update_id``... |
:param data:
One of these:
- ``str``, ``unicode`` (Python 2.7), or ``bytes`` (Python 3, decoded using UTF-8)
representing a JSON-serialized `Update <https://core.telegram.org/bots/api#update>`_ object.
- a ``dict`` representing an Update object.
def feed(self, data):
... |
:return:
a dictionary roughly equivalent to ``{'key1': obj.on_key1, 'key2': obj.on_key2, ...}``,
but ``obj`` does not have to define all methods. It may define the needed ones only.
:param obj: the object
:param keys: a list of keys
:param prefix: a string to be prepended to keys to make ... |
:return:
A key function that returns a 2-tuple (content_type, (msg[content_type],)).
In plain English, it returns the message's *content type* as the key,
and the corresponding content as a positional argument to the handler
function.
def by_content_type():
"""
:return:
... |
:param extractor:
a function that takes one argument (the message) and returns a portion
of message to be interpreted. To extract the text of a chat message,
use ``lambda msg: msg['text']``.
:param prefix:
a list of special characters expected to indicate the head of a command.
... |
:param prefix:
a list of special characters expected to indicate the head of a command.
:param separator:
a command may be followed by arguments separated by ``separator``.
:type pass_args: bool
:param pass_args:
If ``True``, arguments following a command will be passed to the hand... |
:param extractor:
a function that takes one argument (the message) and returns a portion
of message to be interpreted. To extract the text of a chat message,
use ``lambda msg: msg['text']``.
:type regex: str or regex object
:param regex: the pattern to look for
:param key: the part... |
:param processor:
a function to process the key returned by the supplied key function
:param fn:
a key function
:return:
a function that wraps around the supplied key function to further
process the key before returning.
def process_key(processor, fn):
"""
:param proce... |
:param fn: a key function
:return:
a function that wraps around the supplied key function to ensure
the returned key is in lowercase.
def lower_key(fn):
"""
:param fn: a key function
:return:
a function that wraps around the supplied key function to ensure
the returned... |
:param fn: a key function
:return:
a function that wraps around the supplied key function to ensure
the returned key is in uppercase.
def upper_key(fn):
"""
:param fn: a key function
:return:
a function that wraps around the supplied key function to ensure
the returned... |
:return:
a dictionary roughly equivalent to ``{'key1': obj.on_key1, 'key2': obj.on_key2, ...}``,
but ``obj`` does not have to define all methods. It may define the needed ones only.
:param obj: the object
:param keys: a list of keys
:param prefix: a string to be prepended to keys to make ... |
A class decorator to fill in certain methods and properties to ensure
a class can be used by :func:`.create_open`.
These instance methods and property will be added, if not defined
by the class:
- ``open(self, initial_msg, seed)``
- ``on_message(self, msg)``
- ``on_close(self, ex)``
- ``cl... |
Block until a matched message appears.
def wait(self):
"""
Block until a matched message appears.
"""
if not self._patterns:
raise RuntimeError('Listener has nothing to capture')
while 1:
msg = self._queue.get(block=True)
if any(map(lambda p... |
Spawns a thread that calls ``compute fn`` (along with additional arguments
``*compute_args`` and ``**compute_kwargs``), then applies the returned value to
:meth:`.Bot.answerInlineQuery` to answer the inline query.
If a preceding thread is already working for a user, that thread is cancelled,
... |
Configure a :class:`.Listener` to capture callback query
def configure(self, listener):
"""
Configure a :class:`.Listener` to capture callback query
"""
listener.capture([
lambda msg: flavor(msg) == 'callback_query',
{'message': self._chat_origin_included}
... |
:param send_func:
a function that sends messages, such as :meth:`.Bot.send\*`
:return:
a function that wraps around ``send_func`` and examines whether the
sent message contains an inline keyboard with callback data. If so,
future callback query originating from t... |
:param delete_func:
a function that deletes messages, such as :meth:`.Bot.deleteMessage`
:return:
a function that wraps around ``delete_func`` and stops capturing
callback query originating from that deleted message.
def augment_delete(self, delete_func):
"""
... |
:return:
a proxy to ``bot`` with these modifications:
- all ``send*`` methods augmented by :meth:`augment_send`
- all ``edit*`` methods augmented by :meth:`augment_edit`
- ``deleteMessage()`` augmented by :meth:`augment_delete`
- all other public methods, inc... |
Refresh timeout timer
def refresh(self):
""" Refresh timeout timer """
try:
if self._timeout_event:
self._scheduler.cancel(self._timeout_event)
# Timeout event has been popped from queue prematurely
except exception.EventNotFound:
pass
#... |
:return:
a function wrapping ``handler`` to refresh timer for every
non-event message
def augment_on_message(self, handler):
"""
:return:
a function wrapping ``handler`` to refresh timer for every
non-event message
"""
def augmented(msg):
... |
:return:
a function wrapping ``handler`` to cancel timeout event
def augment_on_close(self, handler):
"""
:return:
a function wrapping ``handler`` to cancel timeout event
"""
def augmented(ex):
try:
if self._timeout_event:
... |
Configure a :class:`.Listener` to capture events with this object's
event space and source id.
def configure(self, listener):
"""
Configure a :class:`.Listener` to capture events with this object's
event space and source id.
"""
listener.capture([{re.compile('^_.+'): {'s... |
Marshall ``flavor`` and ``data`` into a standard event.
def make_event_data(self, flavor, data):
"""
Marshall ``flavor`` and ``data`` into a standard event.
"""
if not flavor.startswith('_'):
raise ValueError('Event flavor must start with _underscore')
d = {'source'... |
Schedule an event to be emitted at a certain time.
:param when: an absolute timestamp
:param data_tuple: a 2-tuple (flavor, data)
:return: an event object, useful for cancelling.
def event_at(self, when, data_tuple):
"""
Schedule an event to be emitted at a certain time.
... |
Schedule an event to be emitted after a delay.
:param delay: number of seconds
:param data_tuple: a 2-tuple (flavor, data)
:return: an event object, useful for cancelling.
def event_later(self, delay, data_tuple):
"""
Schedule an event to be emitted after a delay.
:par... |
Apply key function to ``msg`` to obtain a key. Return the routing table entry.
def map(self, msg):
"""
Apply key function to ``msg`` to obtain a key. Return the routing table entry.
"""
k = self.key_function(msg)
key = k[0] if isinstance(k, (tuple, list)) else k
return s... |
Apply key function to ``msg`` to obtain a key, look up routing table
to obtain a handler function, then call the handler function with
positional and keyword arguments, if any is returned by the key function.
``*aa`` and ``**kw`` are dummy placeholders for easy chaining.
Regardless of a... |
Format text as HTML. Also take care of escaping special characters.
Returned value can be passed to :meth:`.Bot.sendMessage` with appropriate
``parse_mode``.
:param text:
plain text
:param entities:
a list of `MessageEntity <https://core.telegram.org/bots/api#messageentity>`_ objects
... |
:return:
a delegator function that returns a coroutine object by calling
``corofunc(seed_tuple, *args, **kwargs)``.
def call(corofunc, *args, **kwargs):
"""
:return:
a delegator function that returns a coroutine object by calling
``corofunc(seed_tuple, *args, **kwargs)``.
""... |
See: https://core.telegram.org/bots/api#sendphoto
:param photo:
- string: ``file_id`` for a photo existing on Telegram servers
- string: HTTP URL of a photo from the Internet
- file-like object: obtained by ``open(path, 'rb')``
- tuple: (filename, file-like objec... |
See: https://core.telegram.org/bots/api#sendaudio
:param audio: Same as ``photo`` in :meth:`telepot.aio.Bot.sendPhoto`
async def sendAudio(self, chat_id, audio,
caption=None,
parse_mode=None,
duration=None,
perform... |
See: https://core.telegram.org/bots/api#editmessagelivelocation
:param msg_identifier: Same as in :meth:`.Bot.editMessageText`
async def editMessageLiveLocation(self, msg_identifier, latitude, longitude,
reply_markup=None):
"""
See: https://core.telegram.o... |
See: https://core.telegram.org/bots/api#getfile
async def getFile(self, file_id):
""" See: https://core.telegram.org/bots/api#getfile """
p = _strip(locals())
return await self._api_request('getFile', _rectify(p)) |
See: https://core.telegram.org/bots/api#kickchatmember
async def kickChatMember(self, chat_id, user_id,
until_date=None):
""" See: https://core.telegram.org/bots/api#kickchatmember """
p = _strip(locals())
return await self._api_request('kickChatMember', _rectify(p)... |
See: https://core.telegram.org/bots/api#restrictchatmember
async def restrictChatMember(self, chat_id, user_id,
until_date=None,
can_send_messages=None,
can_send_media_messages=None,
can_... |
See: https://core.telegram.org/bots/api#setchattitle
async def setChatTitle(self, chat_id, title):
""" See: https://core.telegram.org/bots/api#setchattitle """
p = _strip(locals())
return await self._api_request('setChatTitle', _rectify(p)) |
See: https://core.telegram.org/bots/api#setchatdescription
async def setChatDescription(self, chat_id,
description=None):
""" See: https://core.telegram.org/bots/api#setchatdescription """
p = _strip(locals())
return await self._api_request('setChatDescription',... |
See: https://core.telegram.org/bots/api#pinchatmessage
async def pinChatMessage(self, chat_id, message_id,
disable_notification=None):
""" See: https://core.telegram.org/bots/api#pinchatmessage """
p = _strip(locals())
return await self._api_request('pinChatMessage'... |
See: https://core.telegram.org/bots/api#unpinchatmessage
async def unpinChatMessage(self, chat_id):
""" See: https://core.telegram.org/bots/api#unpinchatmessage """
p = _strip(locals())
return await self._api_request('unpinChatMessage', _rectify(p)) |
See: https://core.telegram.org/bots/api#getchatmember
async def getChatMember(self, chat_id, user_id):
""" See: https://core.telegram.org/bots/api#getchatmember """
p = _strip(locals())
return await self._api_request('getChatMember', _rectify(p)) |
See: https://core.telegram.org/bots/api#setchatstickerset
async def setChatStickerSet(self, chat_id, sticker_set_name):
""" See: https://core.telegram.org/bots/api#setchatstickerset """
p = _strip(locals())
return await self._api_request('setChatStickerSet', _rectify(p)) |
See: https://core.telegram.org/bots/api#deletechatstickerset
async def deleteChatStickerSet(self, chat_id):
""" See: https://core.telegram.org/bots/api#deletechatstickerset """
p = _strip(locals())
return await self._api_request('deleteChatStickerSet', _rectify(p)) |
See: https://core.telegram.org/bots/api#answercallbackquery
async def answerCallbackQuery(self, callback_query_id,
text=None,
show_alert=None,
url=None,
cache_time=None):
""" ... |
See: https://core.telegram.org/bots/api#deletemessage
:param msg_identifier:
Same as ``msg_identifier`` in :meth:`telepot.aio.Bot.editMessageText`,
except this method does not work on inline messages.
async def deleteMessage(self, msg_identifier):
"""
See: https://core.... |
See: https://core.telegram.org/bots/api#sendsticker
:param sticker: Same as ``photo`` in :meth:`telepot.aio.Bot.sendPhoto`
async def sendSticker(self, chat_id, sticker,
disable_notification=None,
reply_to_message_id=None,
reply_mark... |
See: https://core.telegram.org/bots/api#getstickerset
async def getStickerSet(self, name):
"""
See: https://core.telegram.org/bots/api#getstickerset
"""
p = _strip(locals())
return await self._api_request('getStickerSet', _rectify(p)) |
See: https://core.telegram.org/bots/api#deletestickerfromset
async def deleteStickerFromSet(self, sticker):
"""
See: https://core.telegram.org/bots/api#deletestickerfromset
"""
p = _strip(locals())
return await self._api_request('deleteStickerFromSet', _rectify(p)) |
See: https://core.telegram.org/bots/api#answerinlinequery
async def answerInlineQuery(self, inline_query_id, results,
cache_time=None,
is_personal=None,
next_offset=None,
switch_pm_text=None,... |
See: https://core.telegram.org/bots/api#getupdates
async def getUpdates(self,
offset=None,
limit=None,
timeout=None,
allowed_updates=None):
""" See: https://core.telegram.org/bots/api#getupdates """
p = ... |
See: https://core.telegram.org/bots/api#setwebhook
async def setWebhook(self,
url=None,
certificate=None,
max_connections=None,
allowed_updates=None):
""" See: https://core.telegram.org/bots/api#setwebhook """
... |
Download a file to local disk.
:param dest: a path or a ``file`` object
async def download_file(self, file_id, dest):
"""
Download a file to local disk.
:param dest: a path or a ``file`` object
"""
f = await self.getFile(file_id)
try:
d = dest if i... |
Return a task to constantly ``getUpdates`` or pull updates from a queue.
Apply ``handler`` to every message received.
:param handler:
a function that takes one argument (the message), or a routing table.
If ``None``, the bot's ``handle`` method is used.
A *routing table... |
Gather proxies from the providers without checking.
:param list countries: (optional) List of ISO country codes
where should be located proxies
:param int limit: (optional) The maximum number of proxies
:ref:`Example of usage <proxybroker-examples-grab>`.
async ... |
Gather and check proxies from providers or from a passed data.
:ref:`Example of usage <proxybroker-examples-find>`.
:param list types:
Types (protocols) that need to be check on support by proxy.
Supported: HTTP, HTTPS, SOCKS4, SOCKS5, CONNECT:80, CONNECT:25
And lev... |
Start a local proxy server.
The server distributes incoming requests to a pool of found proxies.
When the server receives an incoming request, it chooses the optimal
proxy (based on the percentage of errors and average response time)
and passes to it the incoming request.
In a... |
Looking for proxies in the passed data.
Transform the passed data from [raw string | file-like object | list]
to set {(host, port), ...}: {('192.168.0.1', '80'), }
async def _load(self, data, check=True):
"""Looking for proxies in the passed data.
Transform the passed data from [raw s... |
Stop all tasks, and the local proxy server if it's running.
def stop(self):
"""Stop all tasks, and the local proxy server if it's running."""
self._done()
if self._server:
self._server.stop()
self._server = None
log.info('Stop!') |
Show statistics on the found proxies.
Useful for debugging, but you can also use if you're interested.
:param verbose: Flag indicating whether to print verbose stats
.. deprecated:: 0.2.0
Use :attr:`verbose` instead of :attr:`full`.
def show_stats(self, verbose=False, **kwargs):
... |
Save proxies to a file.
async def save(proxies, filename):
"""Save proxies to a file."""
with open(filename, 'w') as f:
while True:
proxy = await proxies.get()
if proxy is None:
break
f.write('%s:%d\n' % (proxy.host, proxy.port)) |
Return geo information about IP address.
`code` - ISO country code
`name` - Full name of country
`region_code` - ISO region code
`region_name` - Full name of region
`city_name` - Full name of city
def get_ip_info(ip):
"""Return geo information about IP address.
... |
Return real external IP address.
async def get_real_ext_ip(self):
"""Return real external IP address."""
while self._ip_hosts:
try:
timeout = aiohttp.ClientTimeout(total=self._timeout)
async with aiohttp.ClientSession(
timeout=timeout, loo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.