Search is not available for this dataset
text stringlengths 75 104k |
|---|
def has_permission(self, method, endpoint, user=None):
"""Return does the current user can access the resource.
Example::
@app.route('/some_url', methods=['GET', 'POST'])
@rbac.allow(['anonymous'], ['GET'])
def a_view_func():
return Response('Blah Bla... |
def allow(self, roles, methods, with_children=True):
"""This is a decorator function.
You can allow roles to access the view func with it.
An example::
@app.route('/website/setting', methods=['GET', 'POST'])
@rbac.allow(['administrator', 'super_user'], ['GET', 'POST'])... |
def remove_binaries():
"""Remove all binary files in the adslib directory."""
patterns = (
"adslib/*.a",
"adslib/*.o",
"adslib/obj/*.o",
"adslib/*.bin",
"adslib/*.so",
)
for f in functools.reduce(operator.iconcat, [glob.glob(p) for p in patterns]):
... |
def router_function(fn):
# type: (Callable) -> Callable
"""Raise a runtime error if on Win32 systems.
Decorator.
Decorator for functions that interact with the router for the Linux
implementation of the ADS library.
Unlike the Windows implementation which uses a separate router daemon,
th... |
def adsAddRoute(net_id, ip_address):
# type: (SAmsNetId, str) -> None
"""Establish a new route in the AMS Router.
:param pyads.structs.SAmsNetId net_id: net id of routing endpoint
:param str ip_address: ip address of the routing endpoint
"""
add_route = _adsDLL.AdsAddRoute
add_route.restyp... |
def adsPortOpenEx():
# type: () -> int
"""Connect to the TwinCAT message router.
:rtype: int
:return: port number
"""
port_open_ex = _adsDLL.AdsPortOpenEx
port_open_ex.restype = ctypes.c_long
port = port_open_ex()
if port == 0:
raise RuntimeError("Failed to open port on AM... |
def adsPortCloseEx(port):
# type: (int) -> None
"""Close the connection to the TwinCAT message router."""
port_close_ex = _adsDLL.AdsPortCloseEx
port_close_ex.restype = ctypes.c_long
error_code = port_close_ex(port)
if error_code:
raise ADSError(error_code) |
def adsGetLocalAddressEx(port):
# type: (int) -> AmsAddr
"""Return the local AMS-address and the port number.
:rtype: pyads.structs.AmsAddr
:return: AMS-address
"""
get_local_address_ex = _adsDLL.AdsGetLocalAddressEx
ams_address_struct = SAmsAddr()
error_code = get_local_address_ex(por... |
def adsSyncReadStateReqEx(port, address):
# type: (int, AmsAddr) -> Tuple[int, int]
"""Read the current ADS-state and the machine-state.
Read the current ADS-state and the machine-state from the
ADS-server.
:param pyads.structs.AmsAddr address: local or remote AmsAddr
:rtype: (int, int)
:r... |
def adsSyncReadDeviceInfoReqEx(port, address):
# type: (int, AmsAddr) -> Tuple[str, AdsVersion]
"""Read the name and the version number of the ADS-server.
:param int port: local AMS port as returned by adsPortOpenEx()
:param pyads.structs.AmsAddr address: local or remote AmsAddr
:rtype: string, Ads... |
def adsSyncWriteControlReqEx(
port, address, ads_state, device_state, data, plc_data_type
):
# type: (int, AmsAddr, int, int, Any, Type) -> None
"""Change the ADS state and the machine-state of the ADS-server.
:param int port: local AMS port as returned by adsPortOpenEx()
:param pyads.structs.AmsAd... |
def adsSyncWriteReqEx(port, address, index_group, index_offset, value, plc_data_type):
# type: (int, AmsAddr, int, int, Any, Type) -> None
"""Send data synchronous to an ADS-device.
:param int port: local AMS port as returned by adsPortOpenEx()
:param pyads.structs.AmsAddr address: local or remote AmsA... |
def adsSyncReadWriteReqEx2(
port,
address,
index_group,
index_offset,
read_data_type,
value,
write_data_type,
return_ctypes=False,
):
# type: (int, AmsAddr, int, int, Type, Any, Type, bool) -> Any
"""Read and write data synchronous from/to an ADS-device.
:param int port: loc... |
def adsSyncReadReqEx2(
port, address, index_group, index_offset, data_type, return_ctypes=False
):
# type: (int, AmsAddr, int, int, Type, bool) -> Any
"""Read data synchronous from an ADS-device.
:param int port: local AMS port as returned by adsPortOpenEx()
:param pyads.structs.AmsAddr address: lo... |
def adsSyncReadByNameEx(port, address, data_name, data_type, return_ctypes=False):
# type: (int, AmsAddr, str, Type, bool) -> Any
"""Read data synchronous from an ADS-device from data name.
:param int port: local AMS port as returned by adsPortOpenEx()
:param pyads.structs.AmsAddr address: local or rem... |
def adsSyncWriteByNameEx(port, address, data_name, value, data_type):
# type: (int, AmsAddr, str, Any, Type) -> None
"""Send data synchronous to an ADS-device from data name.
:param int port: local AMS port as returned by adsPortOpenEx()
:param pyads.structs.AmsAddr address: local or remote AmsAddr
... |
def adsSyncAddDeviceNotificationReqEx(
port, adr, data_name, pNoteAttrib, callback, user_handle=None
):
# type: (int, AmsAddr, str, NotificationAttrib, Callable, int) -> Tuple[int, int]
"""Add a device notification.
:param int port: local AMS port as returned by adsPortOpenEx()
:param pyads.structs... |
def adsSyncDelDeviceNotificationReqEx(port, adr, notification_handle, user_handle):
# type: (int, AmsAddr, int, int) -> None
"""Remove a device notification.
:param int port: local AMS port as returned by adsPortOpenEx()
:param pyads.structs.AmsAddr adr: local or remote AmsAddr
:param int notificat... |
def adsSyncSetTimeoutEx(port, nMs):
# type: (int, int) -> None
"""Set Timeout.
:param int port: local AMS port as returned by adsPortOpenEx()
:param int nMs: timeout in ms
"""
adsSyncSetTimeoutFct = _adsDLL.AdsSyncSetTimeoutEx
cms = ctypes.c_long(nMs)
err_code = adsSyncSetTimeoutFct(po... |
def _parse_ams_netid(ams_netid):
# type: (str) -> SAmsNetId
"""Parse an AmsNetId from *str* to *SAmsNetId*.
:param str ams_netid: NetId as a string
:rtype: SAmsNetId
:return: NetId as a struct
"""
try:
id_numbers = list(map(int, ams_netid.split(".")))
except ValueErr... |
def set_local_address(ams_netid):
# type: (Union[str, SAmsNetId]) -> None
"""Set the local NetID (**Linux only**).
:param str: new AmsNetID
:rtype: None
**Usage:**
>>> import pyads
>>> pyads.open_port()
>>> pyads.set_local_address('0.0.0.0.1.1')
"""
... |
def write_control(adr, ads_state, device_state, data, plc_datatype):
# type: (AmsAddr, int, int, Any, Type) -> None
"""Change the ADS state and the machine-state of the ADS-server.
:param AmsAddr adr: local or remote AmsAddr
:param int ads_state: new ADS-state, according to ADSTATE constants
... |
def write(adr, index_group, index_offset, value, plc_datatype):
# type: (AmsAddr, int, int, Any, Type) -> None
"""Send data synchronous to an ADS-device.
:param AmsAddr adr: local or remote AmsAddr
:param int index_group: PLC storage area, according to the INDEXGROUP
constants
:param... |
def read_write(
adr,
index_group,
index_offset,
plc_read_datatype,
value,
plc_write_datatype,
return_ctypes=False,
):
# type: (AmsAddr, int, int, Type, Any, Type, bool) -> Any
"""Read and write data synchronous from/to an ADS-device.
:param AmsAddr adr: local or remo... |
def read(adr, index_group, index_offset, plc_datatype, return_ctypes=False):
# type: (AmsAddr, int, int, Type, bool) -> Any
"""Read data synchronous from an ADS-device.
:param AmsAddr adr: local or remote AmsAddr
:param int index_group: PLC storage area, according to the INDEXGROUP
co... |
def read_by_name(adr, data_name, plc_datatype, return_ctypes=False):
# type: (AmsAddr, str, Type, bool) -> Any
"""Read data synchronous from an ADS-device from data name.
:param AmsAddr adr: local or remote AmsAddr
:param string data_name: data name
:param int plc_datatype: type of the data g... |
def write_by_name(adr, data_name, value, plc_datatype):
# type: (AmsAddr, str, Any, Type) -> None
"""Send data synchronous to an ADS-device from data name.
:param AmsAddr adr: local or remote AmsAddr
:param string data_name: PLC storage address
:param value: value to write to the storage addr... |
def add_device_notification(adr, data_name, attr, callback, user_handle=None):
# type: (AmsAddr, str, NotificationAttrib, Callable, int) -> Optional[Tuple[int, int]] # noqa: E501
"""Add a device notification.
:param pyads.structs.AmsAddr adr: AMS Address associated with the routing
entry whic... |
def del_device_notification(adr, notification_handle, user_handle):
# type: (AmsAddr, int, int) -> None
"""Remove a device notification.
:param pyads.structs.AmsAddr adr: AMS Address associated with the routing
entry which is to be removed from the router.
:param notification_handle: addr... |
def open(self):
# type: () -> None
"""Connect to the TwinCAT message router."""
if self._open:
return
self._port = adsPortOpenEx()
if linux:
adsAddRoute(self._adr.netIdStruct(), self.ip_address)
self._open = True |
def close(self):
# type: () -> None
""":summary: Close the connection to the TwinCAT message router."""
if not self._open:
return
if linux:
adsDelRoute(self._adr.netIdStruct())
if self._port is not None:
adsPortCloseEx(self._port)
... |
def write_control(self, ads_state, device_state, data, plc_datatype):
# type: (int, int, Any, Type) -> None
"""Change the ADS state and the machine-state of the ADS-server.
:param int ads_state: new ADS-state, according to ADSTATE constants
:param int device_state: new machine-stat... |
def write(self, index_group, index_offset, value, plc_datatype):
# type: (int, int, Any, Type) -> None
"""Send data synchronous to an ADS-device.
:param int index_group: PLC storage area, according to the INDEXGROUP
constants
:param int index_offset: PLC storage addres... |
def read_write(
self,
index_group,
index_offset,
plc_read_datatype,
value,
plc_write_datatype,
return_ctypes=False,
):
# type: (int, int, Type, Any, Type, bool) -> Any
"""Read and write data synchronous from/to an ADS-device.
... |
def read(self, index_group, index_offset, plc_datatype, return_ctypes=False):
# type: (int, int, Type, bool) -> Any
"""Read data synchronous from an ADS-device.
:param int index_group: PLC storage area, according to the INDEXGROUP
constants
:param int index_offset: PLC... |
def read_by_name(self, data_name, plc_datatype, return_ctypes=False):
# type: (str, Type, bool) -> Any
"""Read data synchronous from an ADS-device from data name.
:param string data_name: data name
:param int plc_datatype: type of the data given to the PLC, according
t... |
def write_by_name(self, data_name, value, plc_datatype):
# type: (str, Any, Type) -> None
"""Send data synchronous to an ADS-device from data name.
:param string data_name: PLC storage address
:param value: value to write to the storage address of the PLC
:param int plc_da... |
def add_device_notification(self, data_name, attr, callback, user_handle=None):
# type: (str, NotificationAttrib, Callable, int) -> Optional[Tuple[int, int]]
"""Add a device notification.
:param str data_name: PLC storage address
:param pyads.structs.NotificationAttrib attr: object... |
def del_device_notification(self, notification_handle, user_handle):
# type: (int, int) -> None
"""Remove a device notification.
:param notification_handle: address of the variable that contains
the handle of the notification
:param user_handle: user handle
... |
def notification(self, plc_datatype=None):
# type: (Optional[Type[Any]]) -> Callable
"""Decorate a callback function.
**Decorator**.
A decorator that can be used for callback functions in order to
convert the data of the NotificationHeader into the fitting
Pytho... |
def xml_extract_text(node, xpath):
"""
:param node: the node to be queried
:param xpath: the path to fetch the child node that has the wanted text
"""
text = node.find(xpath).text
if text is not None:
text = text.strip()
return text |
def xml_extract_date(node, xpath, date_format='%d/%m/%Y'):
"""
:param node: the node to be queried
:param xpath: the path to fetch the child node that has the wanted date
"""
return datetime.strptime(xml_extract_text(node, xpath), date_format) |
def xml_extract_datetime(node, xpath, datetime_format='%d/%m/%Y %H:%M:%S'):
"""
:param node: the node to be queried
:param xpath: the path to fetch the child node that has the wanted datetime
"""
return datetime.strptime(xml_extract_text(node, xpath), datetime_format) |
def translate_column(df, column, translations):
"""
:param df: (pandas.Dataframe) the dataframe to be translated
:param column: (str) the column to be translated
:param translations: (dict) a dictionary of the strings to be categorized and translated
"""
df[column] = df[column].astype('category'... |
def fetch_speeches(data_dir, range_start, range_end):
"""
:param data_dir: (str) directory in which the output file will be saved
:param range_start: (str) date in the format dd/mm/yyyy
:param range_end: (str) date in the format dd/mm/yyyy
"""
speeches = SpeechesDataset()
df = speeches.fetch... |
def fetch(self, range_start, range_end):
"""
Fetches speeches from the ListarDiscursosPlenario endpoint of the
SessoesReunioes (SessionsReunions) API.
The date range provided should be specified as a string using the
format supported by the API (%d/%m/%Y)
"""
ran... |
def fetch_presences(data_dir, deputies, date_start, date_end):
"""
:param data_dir: (str) directory in which the output file will be saved
:param deputies: (pandas.DataFrame) a dataframe with deputies data
:param date_start: (str) a date in the format dd/mm/yyyy
:param date_end: (str) a date in the ... |
def fetch(self, deputies, start_date, end_date):
"""
:param deputies: (pandas.DataFrame) a dataframe with deputies data
:param date_start: (str) date in the format dd/mm/yyyy
:param date_end: (str) date in the format dd/mm/yyyy
"""
log.debug("Fetching data for {} deputies... |
def fetch_official_missions(data_dir, start_date, end_date):
"""
:param data_dir: (str) directory in which the output file will be saved
:param start_date: (datetime) first date of the range to be scraped
:param end_date: (datetime) last date of the range to be scraped
"""
official_missions = Of... |
def fetch(self, start_date, end_date):
"""
Fetches official missions within the given date range
"""
records = []
for two_months_range in self._generate_ranges(start_date, end_date):
log.debug(two_months_range)
for record in self._fetch_missions_for_range... |
def _generate_ranges(start_date, end_date):
"""
Generate a list of 2 month ranges for the range requested with an
intersection between months. This is necessary because we can't search
for ranges longer than 3 months and the period searched has to encompass
the whole period of th... |
def fetch_session_start_times(data_dir, pivot, session_dates):
"""
:param data_dir: (str) directory in which the output file will be saved
:param pivot: (int) congressperson document to use as a pivot for scraping the data
:param session_dates: (list) datetime objects to fetch the start times for
""... |
def fetch(self, pivot, session_dates):
"""
:param pivot: (int) a congressperson document to use as a pivot for scraping the data
:param session_dates: (list) datetime objects to fetch the start times for
"""
records = self._all_start_times(pivot, session_dates)
return pd... |
def fetch_deputies(data_dir):
"""
:param data_dir: (str) directory in which the output file will be saved
"""
deputies = DeputiesDataset()
df = deputies.fetch()
save_to_csv(df, data_dir, "deputies")
holders = df.condition == 'Holder'
substitutes = df.condition == 'Substitute'
log.in... |
def fetch(self):
"""
Fetches the list of deputies for the current term.
"""
xml = urllib.request.urlopen(self.URL)
tree = ET.ElementTree(file=xml)
records = self._parse_deputies(tree.getroot())
df = pd.DataFrame(records, columns=(
'congressperson_id'... |
def add_node(self, node):
"""Adds a `node` to the hash ring (including a number of replicas).
"""
self.nodes.append(node)
for x in xrange(self.replicas):
ring_key = self.hash_method(b("%s:%d" % (node, x)))
self.ring[ring_key] = node
self.sorted_keys.ap... |
def remove_node(self, node):
"""Removes `node` from the hash ring and its replicas.
"""
self.nodes.remove(node)
for x in xrange(self.replicas):
ring_key = self.hash_method(b("%s:%d" % (node, x)))
self.ring.pop(ring_key)
self.sorted_keys.remove(ring_key... |
def get_node_pos(self, key):
"""Given a string key a corresponding node in the hash ring is returned
along with it's position in the ring.
If the hash ring is empty, (`None`, `None`) is returned.
"""
if len(self.ring) == 0:
return [None, None]
crc = self.hash... |
def iter_nodes(self, key):
"""Given a string key it returns the nodes as a generator that can hold the key.
"""
if len(self.ring) == 0:
yield None, None
node, pos = self.get_node_pos(key)
for k in self.sorted_keys[pos:]:
yield k, self.ring[k] |
def format_servers(servers):
"""
:param servers: server list, element in it can have two kinds of format.
- dict
servers = [
{'name':'node1','host':'127.0.0.1','port':10000,'db':0},
{'name':'node2','host':'127.0.0.1','port':11000,'db':0},
{'name':'node3','host':'127.0.0.1','por... |
def mget(self, keys, *args):
"""
Returns a list of values ordered identically to ``keys``
"""
args = list_or_args(keys, args)
server_keys = {}
ret_dict = {}
for key in args:
server_name = self.get_server_name(key)
server_keys[server_name] =... |
def mset(self, mapping):
"""
Sets each key in the ``mapping`` dict to its corresponding value
"""
servers = {}
for key, value in mapping.items():
server_name = self.get_server_name(key)
servers.setdefault(server_name, [])
servers[server_name].a... |
def lock(self, name, timeout=None, sleep=0.1):
"""
Return a new Lock object using key ``name`` that mimics
the behavior of threading.Lock.
If specified, ``timeout`` indicates a maximum life for the lock.
By default, it will remain locked until release() is called.
``sle... |
def parse_line(line, document=None):
'''
Return a language-server diagnostic from a line of the Mypy error report;
optionally, use the whole document to provide more context on it.
'''
result = re.match(line_pattern, line)
if result:
_, lineno, offset, severity, msg = result.groups()
... |
async def connect(self):
""" Establishes a connection to the Lavalink server. """
await self._lavalink.bot.wait_until_ready()
if self._ws and self._ws.open:
log.debug('WebSocket still open, closing...')
await self._ws.close()
user_id = self._lavalink.bot... |
async def _attempt_reconnect(self):
"""
Attempts to reconnect to the Lavalink server.
Returns
-------
bool
``True`` if the reconnection attempt was successful.
"""
log.info('Connection closed; attempting to reconnect in 30 seconds')
fo... |
async def listen(self):
""" Waits to receive a payload from the Lavalink server and processes it. """
while not self._shutdown:
try:
data = json.loads(await self._ws.recv())
except websockets.ConnectionClosed as error:
log.warning('Disconnect... |
def connected_channel(self):
""" Returns the voice channel the player is connected to. """
if not self.channel_id:
return None
return self._lavalink.bot.get_channel(int(self.channel_id)) |
async def connect(self, channel_id: int):
""" Connects to a voice channel. """
ws = self._lavalink.bot._connection._get_websocket(int(self.guild_id))
await ws.voice_state(self.guild_id, str(channel_id)) |
async def disconnect(self):
""" Disconnects from the voice channel, if any. """
if not self.is_connected:
return
await self.stop()
ws = self._lavalink.bot._connection._get_websocket(int(self.guild_id))
await ws.voice_state(self.guild_id, None) |
def store(self, key: object, value: object):
""" Stores custom user data. """
self._user_data.update({key: value}) |
def fetch(self, key: object, default=None):
""" Retrieves the related value from the stored user data. """
return self._user_data.get(key, default) |
def add(self, requester: int, track: dict):
""" Adds a track to the queue. """
self.queue.append(AudioTrack().build(track, requester)) |
def add_next(self, requester: int, track: dict):
""" Adds a track to beginning of the queue """
self.queue.insert(0, AudioTrack().build(track, requester)) |
def add_at(self, index: int, requester: int, track: dict):
""" Adds a track at a specific index in the queue. """
self.queue.insert(min(index, len(self.queue) - 1), AudioTrack().build(track, requester)) |
async def play(self, track_index: int = 0, ignore_shuffle: bool = False):
""" Plays the first track in the queue, if any or plays a track from the specified index in the queue. """
if self.repeat and self.current:
self.queue.append(self.current)
self.previous = self.current
... |
async def play_now(self, requester: int, track: dict):
""" Add track and play it. """
self.add_next(requester, track)
await self.play(ignore_shuffle=True) |
async def play_at(self, index: int):
""" Play the queue from a specific point. Disregards tracks before the index. """
self.queue = self.queue[min(index, len(self.queue) - 1):len(self.queue)]
await self.play(ignore_shuffle=True) |
async def play_previous(self):
""" Plays previous track if it exist, if it doesn't raises a NoPreviousTrack error. """
if not self.previous:
raise NoPreviousTrack
self.queue.insert(0, self.previous)
await self.play(ignore_shuffle=True) |
async def stop(self):
""" Stops the player, if playing. """
await self._lavalink.ws.send(op='stop', guildId=self.guild_id)
self.current = None |
async def set_pause(self, pause: bool):
""" Sets the player's paused state. """
await self._lavalink.ws.send(op='pause', guildId=self.guild_id, pause=pause)
self.paused = pause |
async def set_volume(self, vol: int):
""" Sets the player's volume (150% or 1000% limit imposed by lavalink depending on the version). """
if self._lavalink._server_version <= 2:
self.volume = max(min(vol, 150), 0)
else:
self.volume = max(min(vol, 1000), 0)
... |
async def seek(self, pos: int):
""" Seeks to a given position in the track. """
await self._lavalink.ws.send(op='seek', guildId=self.guild_id, position=pos) |
async def handle_event(self, event):
""" Makes the player play the next song from the queue if a song has finished or an issue occurred. """
if isinstance(event, (TrackStuckEvent, TrackExceptionEvent)) or \
isinstance(event, TrackEndEvent) and event.reason == 'FINISHED':
... |
def get(self, guild_id):
""" Returns a player from the cache, or creates one if it does not exist. """
if guild_id not in self._players:
p = self._player(lavalink=self.lavalink, guild_id=guild_id)
self._players[guild_id] = p
return self._players[guild_id] |
def remove(self, guild_id):
""" Removes a player from the current players. """
if guild_id in self._players:
self._players[guild_id].cleanup()
del self._players[guild_id] |
async def _play(self, ctx, *, query: str):
""" Searches and plays a song from a given query. """
player = self.bot.lavalink.players.get(ctx.guild.id)
query = query.strip('<>')
if not url_rx.match(query):
query = f'ytsearch:{query}'
tracks = await self.bot.... |
async def _seek(self, ctx, *, time: str):
""" Seeks to a given position in a track. """
player = self.bot.lavalink.players.get(ctx.guild.id)
if not player.is_playing:
return await ctx.send('Not playing.')
seconds = time_rx.search(time)
if not seconds:
... |
async def _skip(self, ctx):
""" Skips the current track. """
player = self.bot.lavalink.players.get(ctx.guild.id)
if not player.is_playing:
return await ctx.send('Not playing.')
await player.skip()
await ctx.send('⏭ | Skipped.') |
async def _stop(self, ctx):
""" Stops the player and clears its queue. """
player = self.bot.lavalink.players.get(ctx.guild.id)
if not player.is_playing:
return await ctx.send('Not playing.')
player.queue.clear()
await player.stop()
await ctx.send('... |
async def _now(self, ctx):
""" Shows some stats about the currently playing song. """
player = self.bot.lavalink.players.get(ctx.guild.id)
song = 'Nothing'
if player.current:
position = lavalink.Utils.format_time(player.position)
if player.current.stream:
... |
async def _queue(self, ctx, page: int = 1):
""" Shows the player's queue. """
player = self.bot.lavalink.players.get(ctx.guild.id)
if not player.queue:
return await ctx.send('There\'s nothing in the queue! Why not queue something?')
items_per_page = 10
pages... |
async def _pause(self, ctx):
""" Pauses/Resumes the current track. """
player = self.bot.lavalink.players.get(ctx.guild.id)
if not player.is_playing:
return await ctx.send('Not playing.')
if player.paused:
await player.set_pause(False)
await... |
async def _volume(self, ctx, volume: int = None):
""" Changes the player's volume. Must be between 0 and 150. Error Handling for that is done by Lavalink. """
player = self.bot.lavalink.players.get(ctx.guild.id)
if not volume:
return await ctx.send(f'🔈 | {player.volume}%')
... |
async def _shuffle(self, ctx):
""" Shuffles the player's queue. """
player = self.bot.lavalink.players.get(ctx.guild.id)
if not player.is_playing:
return await ctx.send('Nothing playing.')
player.shuffle = not player.shuffle
await ctx.send('🔀 | Shuffle ' + ... |
async def _repeat(self, ctx):
""" Repeats the current song until the command is invoked again. """
player = self.bot.lavalink.players.get(ctx.guild.id)
if not player.is_playing:
return await ctx.send('Nothing playing.')
player.repeat = not player.repeat
awai... |
async def _remove(self, ctx, index: int):
""" Removes an item from the player's queue with the given index. """
player = self.bot.lavalink.players.get(ctx.guild.id)
if not player.queue:
return await ctx.send('Nothing queued.')
if index > len(player.queue) or index < ... |
async def _disconnect(self, ctx):
""" Disconnects the player from the voice channel and clears its queue. """
player = self.bot.lavalink.players.get(ctx.guild.id)
if not player.is_connected:
return await ctx.send('Not connected.')
if not ctx.author.voice or (player.i... |
async def ensure_voice(self, ctx):
""" A few checks to make sure the bot can join a voice channel. """
player = self.bot.lavalink.players.get(ctx.guild.id)
if not player.is_connected:
if not ctx.author.voice or not ctx.author.voice.channel:
await ctx.send('You ... |
def register_hook(self, func):
"""
Registers a hook. Since this probably is a bit difficult, I'll explain it in detail.
A hook basically is an object of a function you pass. This will append that object to a list and whenever
an event from the Lavalink server is dispatched, the funct... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.