xdcc_dl.xdcc package¶
Submodules¶
xdcc_dl.xdcc.XDCCClient module¶
- class xdcc_dl.xdcc.XDCCClient.XDCCClient(pack: xdcc_dl.entities.XDCCPack.XDCCPack, retry: bool = False, timeout: int = 120, fallback_channel: Optional[str] = None, throttle: Union[int, str] = - 1, wait_time: int = 0, username: str = '', channel_join_delay: Optional[int] = None)¶
Bases:
irc.client.SimpleIRCClient
IRC Client that can download an XDCC pack
- __init__(pack: xdcc_dl.entities.XDCCPack.XDCCPack, retry: bool = False, timeout: int = 120, fallback_channel: Optional[str] = None, throttle: Union[int, str] = - 1, wait_time: int = 0, username: str = '', channel_join_delay: Optional[int] = None)¶
Initializes the XDCC IRC client :param pack: The pack to downloadX :param retry: Set to true for retried downloads. :param timeout: Sets the timeout time for starting downloads :param fallback_channel: A fallback channel for when whois
fails to find a valid channel
- Parameters
throttle – Throttles the download to n bytes per second. If this value is <= 0, the download speed will be unlimited
wait_time – Waits for the specified amount of time before sending a message
username – If specified sets the username to log on with
channel_join_delay – If specifies sets the channel join delay
- download() str ¶
Downloads the pack :return: The path to the downloaded file
- event = 'usersdontmatch'¶
- handle_generic_event(event_type: str, _: irc.client.ServerConnection, event: irc.client.Event)¶
Handles a generic event that isn’t handled explicitly :param event_type: The event type to handle :param _: The connection to use :param event: The received event :return: None
- on_action(c, e)¶
- on_adminemail(c, e)¶
- on_adminloc1(c, e)¶
- on_adminloc2(c, e)¶
- on_adminme(c, e)¶
- on_alreadyregistered(c, e)¶
- on_away(c, e)¶
- on_badchanmask(c, e)¶
- on_badchannelkey(c, e)¶
- on_banlist(c, e)¶
- on_banlistfull(c, e)¶
- on_bannedfromchan(c, e)¶
- on_cannotknock(c, e)¶
- on_cannotsendtochan(c, e)¶
- on_cantkillserver(c, e)¶
- on_channelcreate(c, e)¶
- on_channelisfull(c, e)¶
- on_channelmodeis(c, e)¶
- on_chanoprivsneeded(c, e)¶
- on_closeend(c, e)¶
- on_closing(c, e)¶
- on_created(c, e)¶
- on_ctcp(conn: irc.client.ServerConnection, event: irc.client.Event)¶
The ‘ctcp’ event indicates that a CTCP message was received. The downloader receives a CTCP from the bot to initialize the XDCC file transfer. Handles DCC ACCEPT and SEND messages. Other DCC messages will result in a raised InvalidCTCP exception. DCC ACCEPT will only occur when a resume request was sent successfully. DCC SEND will occur when the bot offers a file. :param conn: The connection :param event: The ‘ctcp’ event :return: None :raise InvalidCTCPException: In case no valid DCC message was received
- on_ctcpreply(c, e)¶
- on_currenttopic(c, e)¶
- on_dcc_connect(c, e)¶
- on_dcc_disconnect(_: irc.client.ServerConnection, __: irc.client.Event)¶
The ‘dccmsg’ event contains the file data. :param _: The connection :param __: The ‘dccmsg’ event :return: None
- on_dccmsg(_: irc.client.ServerConnection, event: irc.client.Event)¶
The ‘dccmsg’ event contains the file data. :param _: The connection :param event: The ‘dccmsg’ event :return: None
- on_disconnect(c, e)¶
- on_endofbanlist(c, e)¶
- on_endofexceptlist(c, e)¶
- on_endofinfo(c, e)¶
- on_endofinvitelist(c, e)¶
- on_endoflinks(c, e)¶
- on_endofmotd(c, e)¶
- on_endofnames(c, e)¶
- on_endofservices(c, e)¶
- on_endofstats(c, e)¶
- on_endoftrace(c, e)¶
- on_endofusers(c, e)¶
- on_endofwho(c, e)¶
- on_endofwhois(conn: irc.client.ServerConnection, _: irc.client.Event)¶
The ‘endofwhois’ event indicates the end of a whois request. This manually calls on_join in case the bot has not joined any channels. :param conn: The connection :param _: The ‘endofwhois’ event :return: None
- on_endofwhowas(c, e)¶
- on_erroneusnickname(c, e)¶
- on_error(_: irc.client.ServerConnection, __: irc.client.Event)¶
Sometimes, the connection gives an error which may prove fatal for the download process. A possible cause of error events is a banned IP address. :param _: The connection :param __: The error event :return: None
- on_exceptlist(c, e)¶
- on_featurelist(c, e)¶
- on_fileerror(c, e)¶
- on_info(c, e)¶
- on_infostart(c, e)¶
- on_invalidcapcmd(c, e)¶
- on_invite(c, e)¶
- on_invitelist(c, e)¶
- on_inviteonlychan(c, e)¶
- on_inviting(c, e)¶
- on_ison(c, e)¶
- on_join(conn: irc.client.ServerConnection, event: irc.client.Event, force: bool = False)¶
The ‘join’ event indicates that a channel was successfully joined. The first on_join call will send a message to the bot that requests the initialization of the XDCC file transfer. :param conn: The connection :param event: The ‘join’ event :param force: If set to True, will force sending an XDCC message :return: None
- on_keyset(c, e)¶
- on_kick(c, e)¶
- on_killdone(c, e)¶
- on_links(c, e)¶
- on_list(c, e)¶
- on_listend(c, e)¶
- on_liststart(c, e)¶
- on_luserchannels(c, e)¶
- on_luserclient(c, e)¶
- on_luserconns(c, e)¶
- on_luserme(c, e)¶
- on_luserop(c, e)¶
- on_luserunknown(c, e)¶
- on_mode(c, e)¶
- on_motd(c, e)¶
- on_motd2(c, e)¶
- on_motdstart(c, e)¶
- on_myinfo(c, e)¶
- on_myportis(c, e)¶
- on_n_global(c, e)¶
- on_n_local(c, e)¶
- on_namreply(c, e)¶
- on_needmoreparams(c, e)¶
- on_nick(c, e)¶
- on_nickcollision(c, e)¶
- on_nicknameinuse(c, e)¶
- on_noadmininfo(c, e)¶
- on_nochanmodes(c, e)¶
- on_nologin(c, e)¶
- on_nomotd(c, e)¶
- on_none(c, e)¶
- on_nonicknamegiven(c, e)¶
- on_nooperhost(c, e)¶
- on_noorigin(c, e)¶
- on_nopermforhost(c, e)¶
- on_noprivileges(c, e)¶
- on_norecipient(c, e)¶
- on_noservicehost(c, e)¶
- on_nosuchchannel(c, e)¶
- on_nosuchnick(_: irc.client.ServerConnection, __: irc.client.Event)¶
When a bot does not exist or is not online right now, aborts. :param _: The IRC connection :param __: The received event :return: None
- on_nosuchserver(c, e)¶
- on_notexttosend(c, e)¶
- on_notonchannel(c, e)¶
- on_notopic(c, e)¶
- on_notoplevel(c, e)¶
- on_notregistered(c, e)¶
- on_nousers(c, e)¶
- on_nowaway(c, e)¶
- on_part(c, e)¶
- on_passwdmismatch(c, e)¶
- on_ping(_: irc.client.ServerConnection, __: irc.client.Event)¶
Handles a ping event. Used for timeout checks :param _: The IRC connection :param __: The received event :return: None
- on_pong(c, e)¶
- on_privmsg(c, e)¶
- on_privnotice(_: irc.client.ServerConnection, event: irc.client.Event)¶
Handles privnotices. Bots sometimes send privnotices when a pack was already requested or the user is put into a queue.
If the privnotice indicates that a pack was already requested, the downloader will pause for 60 seconds
- Parameters
_ – The connection
event – The privnotice event
- Returns
None
- on_pubmsg(c, e)¶
- on_pubnotice(c, e)¶
- on_quit(c, e)¶
- on_rehashing(c, e)¶
- on_restricted(c, e)¶
- on_service(c, e)¶
- on_serviceinfo(c, e)¶
- on_servlist(c, e)¶
- on_servlistend(c, e)¶
- on_statscline(c, e)¶
- on_statscommands(c, e)¶
- on_statshline(c, e)¶
- on_statsiline(c, e)¶
- on_statskline(c, e)¶
- on_statslinkinfo(c, e)¶
- on_statslline(c, e)¶
- on_statsnline(c, e)¶
- on_statsoline(c, e)¶
- on_statsqline(c, e)¶
- on_statsuptime(c, e)¶
- on_statsyline(c, e)¶
- on_summondisabled(c, e)¶
- on_summoning(c, e)¶
- on_time(c, e)¶
- on_toomanychannels(c, e)¶
- on_toomanytargets(c, e)¶
- on_topic(c, e)¶
- on_topicinfo(c, e)¶
- on_traceclass(c, e)¶
- on_traceconnecting(c, e)¶
- on_tracehandshake(c, e)¶
- on_tracelink(c, e)¶
- on_tracelog(c, e)¶
- on_tracenewtype(c, e)¶
- on_traceoperator(c, e)¶
- on_tracereconnect(c, e)¶
- on_traceserver(c, e)¶
- on_traceservice(c, e)¶
- on_traceunknown(c, e)¶
- on_traceuser(c, e)¶
- on_tryagain(c, e)¶
- on_umodeis(c, e)¶
- on_umodeunknownflag(c, e)¶
- on_unaway(c, e)¶
- on_uniqopprivsneeded(c, e)¶
- on_unknowncommand(c, e)¶
- on_unknownmode(c, e)¶
- on_userhost(c, e)¶
- on_usernotinchannel(c, e)¶
- on_useronchannel(c, e)¶
- on_users(c, e)¶
- on_usersdisabled(c, e)¶
- on_usersdontmatch(c, e)¶
- on_usersstart(c, e)¶
- on_version(c, e)¶
- on_wasnosuchnick(c, e)¶
- on_welcome(conn: irc.client.ServerConnection, _: irc.client.Event)¶
The ‘welcome’ event indicates a successful connection to the server Sends a whois command to find the bot on the server :param conn: The connection :param _: The ‘welcome’ event :return: None
- on_whoisaccount(c, e)¶
- on_whoischannels(conn: irc.client.ServerConnection, event: irc.client.Event)¶
The ‘whoischannels’ event indicates that a whois request has found channels that the bot is a part of. Channels that the bot has joined will be joined as well. :param conn: The connection :param event: The ‘whoischannels’ event :return: None
- on_whoischanop(c, e)¶
- on_whoisidle(c, e)¶
- on_whoisoperator(c, e)¶
- on_whoisserver(c, e)¶
- on_whoisuser(c, e)¶
- on_whoreply(c, e)¶
- on_whospcrpl(c, e)¶
- on_whowasuser(c, e)¶
- on_wildtoplevel(c, e)¶
- on_yourebannedcreep(c, e)¶
- on_youreoper(c, e)¶
- on_yourhost(c, e)¶
- on_youwillbebanned(c, e)¶
- progress_printer()¶
Prints the download progress Should run in a separate thread to avoid blocking up the IO which could lead to reduced download speeds :return: None
- send_acks()¶
- timeout_watcher()¶
Monitors when the XDCC message is sent. If it is not sent by the timeout time, a ping will be sent and handled by the on_ping method :return: None
xdcc_dl.xdcc.exceptions module¶
- exception xdcc_dl.xdcc.exceptions.AlreadyDownloadedException¶
Bases:
Exception
Exception thrown when a file was already downloaded
- exception xdcc_dl.xdcc.exceptions.BotDoesNotExist¶
Bases:
xdcc_dl.xdcc.exceptions.UnrecoverableError
Exception raised if a bot does not exist
- exception xdcc_dl.xdcc.exceptions.DownloadCompleted¶
Bases:
Exception
Exception thrown once the download has been completed
- exception xdcc_dl.xdcc.exceptions.DownloadIncomplete¶
Bases:
Exception
Exception thrown if a download did not complete
- exception xdcc_dl.xdcc.exceptions.InvalidCTCPException¶
Bases:
Exception
Exception thrown when an invalid CTCP DCC message type is received
- exception xdcc_dl.xdcc.exceptions.PackAlreadyRequested¶
Bases:
Exception
Exception raised if a pack was already requested
- exception xdcc_dl.xdcc.exceptions.Timeout¶
Bases:
xdcc_dl.xdcc.exceptions.UnrecoverableError
Exception raised when a timeout occurs
- exception xdcc_dl.xdcc.exceptions.UnrecoverableError¶
Bases:
Exception
Exception raised when an unrecoverable error occurs
Module contents¶
- xdcc_dl.xdcc.download_packs(packs: List[xdcc_dl.entities.XDCCPack.XDCCPack], timeout: int = 120, fallback_channel: Optional[str] = None, throttle: Union[int, str] = - 1, wait_time: int = 0, username: Optional[str] = None, channel_join_delay: Optional[int] = None)¶
Downloads a list of XDCC Packs :param packs: The packs to download :param timeout: Specifies timeout time :param fallback_channel: A fallback channel for when no channels were found :param throttle: Throttles the download to n bytes per second.
If this value is <= 0, the download speed will be unlimited
- Parameters
wait_time – Waits for the specified amount of time before sending a message
username – The username to use. If not specified, will use a random one.
channel_join_delay – Delays the joining of channels by a set amount of seconds. If not specified, the bot will wait a random amount of time
- Returns
None