pytwitcherapi.chat.connection.ServerConnection3

class pytwitcherapi.chat.connection.ServerConnection3(reactor, msglimit=20, limitinterval=30)[source]

Bases: irc.client.ServerConnection

ServerConncetion that can handle irc v3 tags

Tags are only handled for privmsg, pubmsg, notice events. All other events might be handled the old way.

__init__(reactor, msglimit=20, limitinterval=30)[source]

Initialize a connection that has a limit to sending messages

Parameters:
  • reactor (irc.client.Reactor) – the reactor of the connection
  • msglimit (int) – the maximum number of messages to send in limitinterval
  • limitinterval (int) – the timeframe in seconds in which you can only send as many messages as in msglimit
Raises:

None

Methods

__init__(reactor[, msglimit, limitinterval]) Initialize a connection that has a limit to sending messages
action(target, action) Send a CTCP ACTION command.
add_global_handler(*args) Add global handler.
admin([server]) Send an ADMIN command.
as_nick(*args, **kwds) Set the nick for the duration of the context.
cap(subcommand, *args) Send a CAP command according to the spec.
close() Close the connection.
connect(*args, **kwargs) Connect/reconnect to a server.
ctcp(ctcptype, target[, parameter]) Send a CTCP command.
ctcp_reply(target, parameter) Send a CTCP REPLY command.
disconnect([message]) Hang up the connection.
get_nickname() Get the (real) nick name.
get_server_name() Get the (real) server name.
get_waittime() Return the appropriate time to wait, if we sent too many messages
globops(text) Send a GLOBOPS command.
info([server]) Send an INFO command.
invite(nick, channel) Send an INVITE command.
is_connected() Return connection status.
ison(nicks) Send an ISON command.
join(channel[, key]) Send a JOIN command.
kick(channel, nick[, comment]) Send a KICK command.
links([remote_server, server_mask]) Send a LINKS command.
list([channels, server]) Send a LIST command.
lusers([server]) Send a LUSERS command.
mode(target, command) Send a MODE command.
motd([server]) Send an MOTD command.
names([channels]) Send a NAMES command.
nick(newnick) Send a NICK command.
notice(target, text) Send a NOTICE command.
oper(nick, password) Send an OPER command.
part(channels[, message]) Send a PART command.
pass_(password) Send a PASS command.
ping(target[, target2]) Send a PING command.
pong(target[, target2]) Send a PONG command.
privmsg(target, text) Send a PRIVMSG command.
privmsg_many(targets, text) Send a PRIVMSG command to multiple targets.
process_data() read and process input from self.socket
quit([message]) Send a QUIT command.
reconnect() Reconnect with the last arguments passed to self.connect()
remove_global_handler(*args) Remove global handler.
send_items(*items) Send all non-empty items, separated by spaces.
send_raw(string) Send raw string to the server.
set_keepalive(interval) Set a keepalive to occur every interval on this connection.
set_rate_limit(frequency) Set a frequency limit (messages per second) for this connection.
squit(server[, comment]) Send an SQUIT command.
stats(statstype[, server]) Send a STATS command.
time([server]) Send a TIME command.
topic(channel[, new_topic]) Send a TOPIC command.
trace([target]) Send a TRACE command.
user(username, realname) Send a USER command.
userhost(nicks) Send a USERHOST command.
users([server]) Send a USERS command.
version([server]) Send a VERSION command.
wallops(text) Send a WALLOPS command.
who([target, op]) Send a WHO command.
whois(targets) Send a WHOIS command.
whowas(nick[, max, server]) Send a WHOWAS command.

Attributes

socket
sentmessages = None

A queue with timestamps form the last sent messages. So we can track if we send to many messages.

limitinterval = None

the timeframe in seconds in which you can only send as many messages as in ServerConncetion3msglimit

get_waittime()[source]

Return the appropriate time to wait, if we sent too many messages

Returns:the time to wait in seconds
Return type:float
Raises:None
send_raw(string)[source]

Send raw string to the server.

The string will be padded with appropriate CR LF. If too many messages are sent, this will call time.sleep() until it is allowed to send messages again.

Parameters:string (str) – the raw string to send
Returns:None
Raises:irc.client.InvalidCharacters, irc.client.MessageTooLong, irc.client.ServerNotConnectedError