Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 27 15:28
    ykram opened #163
  • Aug 02 20:45
    trevortaG opened #162
  • Jul 27 17:24

    jaraco on master

    Remove pygments, apparently no … (compare)

  • Jul 13 12:39
    sbraz commented #161
  • Jul 13 05:11
    jaraco closed #159
  • Jul 13 05:11
    jaraco commented #159
  • Jul 13 05:05
    jaraco closed #160
  • Jul 13 05:05

    jaraco on master

    Remove reference to irc.functoo… (compare)

  • Jul 13 05:03
    jaraco commented #161
  • Jul 13 05:02

    jaraco on master

    Add black config, pre-commit in… Enable tox-pip-extensions ext_v… Rely on tox 3.2 and pip 10 or l… and 11 more (compare)

  • Jul 13 04:58

    jaraco on master

    Escape asterisks in doc of **co… Merge pull request #161 from sb… (compare)

  • Jul 13 04:58
    jaraco closed #161
  • Jul 13 01:25
    sbraz opened #161
  • Jul 13 01:23
    sbraz opened #160
  • May 21 14:19
    kutu opened #159
  • Apr 02 20:07
    DarthGandalf commented #152
  • Apr 02 08:27
    sbraz commented #152
  • Mar 29 15:25
    jaraco labeled #143
  • Mar 29 15:25
    jaraco labeled #143
  • Mar 29 15:22
    jaraco commented #146
Jason R. Coombs
@jaraco
As for getting arguments from a command, I’m not sure what you’re after. Are you trying as the client (bot) to kick another user from a channel? For that, there’s a kick method on the ServerConnection (https://github.com/jaraco/irc/blob/master/irc/client.py#L803).
Or if you’re looking to respond to an event where your bot has been kicked, you probably need to define an on_kick method and it accepts a connection and event argument, with more details in the event that the server supplied. I’m not sure the protocol works that way, but if the server issues a KICK command, you would handle that with on_kick in the client.
Alexander
@zylinx
hello
I am subclassing SingleServerIRCBot for a simple IRC bot, i was wondering what is best practice for asynchronously doing work and then calling back to my SingleServerIRCBot instance to send a message to the channel
should i just spawn a new thread from the init and pass it a callback function defined within my subclass ?
Alexander
@zylinx
^still reading on how to do that
Alexander
@zylinx
can i use the irc.schedule module with irc.bot module ?
Jason R. Coombs
@jaraco
@zylinx In general, you shouldn’t need to use threads. The irc.client.Reactor is the default event loop, and it works synchronously (the process_forever method). It has a scheduler instance to which you may add scheduled functions. So you can schedule work to be done. But it really depends on what work it is you want to do. In most cases, the work you need to do is in response to an event from the IRC server and can be handled synchronously. See pmxbot for a mature implementation of a bot built on irc.
One plugin for that bot, the http API at jaraco.pmxbot, does some tricks to run a web server alongside the IRC client to proxy messages. It does that by creating a queue and having the web service run in one thread and periodically poll that queue from the IRC client’s main thread.
Alexander
@zylinx
thanks! my intention is to have the bot scrape rss feeds and webpages etc. and report back as it comes across something.
Alexander
@zylinx
is it possible to access the reactors scheduler instance from inside SingleServerIRCBot subclass ?
Alexander
@zylinx
pdb to the rescue, found him c.reactor.scheduler.execute_every(5, self.my_func) thanks for the help
Jason R. Coombs
@jaraco
@zylinx: Nice work. I realize now that when I jaraco/irc@6dc684d, it made it less clear how one goes about scheduling something. If you’re interested, I’d welcome updates to the docstrings in irc.client or in the README to enhance the documentation around using the scheduler.
kerbin111
@kerbin111
Hello! I have been trying to make the SingleServerIRCBot in irc.bot work, but the start() method is taking an indefinite amount of time. How do you start the SingleServerIRCBot?
Jason R. Coombs
@jaraco
@kerbin111: .start() is the right call. See scripts/testbot.py for a working example (last I checked). If it’s not doing anything, it’s probably because you need to respond to the welcome message to begin joining channels.
Consider turning on debug logging to see what’s happening in the traffic. Something like logging.basicConfig(level=logging.DEBUG).
MineRobber___T
@MineRobber9000
hi! I'm trying to connect a bot written in this libraru to connect to an IRCS server. Is there anything special I have to do to make the bot do TLS
?
Jason R. Coombs
@jaraco
You can do SSL by using a custom connection factory. https://python-irc.readthedocs.io/en/latest/irc.html#module-irc.connection
If you want to perform TLS, upgrading the connection within the IRC protocol, that’s not something the library supports, but I’d be open to contributions adding that feature.
Justin Kyle Ramos
@de-odex
hello, is defining the server password as simple as irc.bot.SingleServerIRCBot.__init__(self, [(server, port, password)], ...) in the custom Bot class?
Jason R. Coombs
@jaraco
@de-odex : Yes, essentially. Here’s where it’s done in pmxbot: https://github.com/yougov/pmxbot/blob/master/pmxbot/irc.py#L63
You can either define a custom bot class or pass in the list of servers to the bot class naturally.
Justin Kyle Ramos
@de-odex
what unit of time does execute_after use?
Justin Kyle Ramos
@de-odex
actually i cant even figure out how to use the scheduler
Jason R. Coombs
@jaraco
@de-odex It uses a datetime.timedelta or integer seconds.
(IIRC)
Justin Kyle Ramos
@de-odex
okay thanks
Jason R. Coombs
@jaraco
(the scheduler does)
Justin Kyle Ramos
@de-odex
is there a way to simulate a privmsg within python (maybe using the module)? for pytest
Justin Kyle Ramos
@de-odex
oh, also, does message sending also have a rate limit? can it be set?
Jason R. Coombs
@jaraco
@de-odex The pmxbot project sets up a full integration test, creating a server and client to test the interaction. https://github.com/yougov/pmxbot/blob/95c30bf82511174cb971b8f31fe5592a57b58a65/tests/functional/__init__.py#L38
It’s rather complicated, and there may be simpler approaches, but that’s the one with which I’m most familiar.
Justin Kyle Ramos
@de-odex
thanks again ;w;
Justin Kyle Ramos
@de-odex
more questions: how do i receive the output of a WHOIS?
also can set_rate_limit, rather than block, queue messages?
Justin Kyle Ramos
@de-odex
nevermind, seems like set_rate_limit queues messages, block implies the message is lost if it exceeds the rate limit
Jason R. Coombs
@jaraco
I’m not sure what it means to receive the output of a WHOIS. I think you mean for the client to issue a whois command and then respond when the result comes back. I think for that, all you need to do is define a handler for the response. I’m not sure how that response comes back, but it may be you just need to define an on_whois method in your client class.
Justin Kyle Ramos
@de-odex
image.png
how do i get this via your lib?
is it e.source?
nvm, thanks, it's e.source.userhost
Jason R. Coombs
@jaraco
Awesome. Glad you found it.
依云
@lilydjwg
I'm lost. Where is the doc for events?
Jason R. Coombs
@jaraco
Sorry, @lilydiwg - there’s no documentation other than the code and its docs. Best I can tell, an “event” is a concept internal to the IRC library and the IRC protocol, defined by https://tools.ietf.org/html/rfc1459 and others, speaks mostly of commands and messages.
MineRobber___T
@MineRobber9000
Hi, I was wondering how to get a userhost given a nick? I'm implementing a blocklist for my bot and I want to be able to block someone by their userhost (block by nick and they can change it, changing user requires thought and a relog)
Jason R. Coombs
@jaraco
@MineRobber9000 Looks like you can do client.userhost([nick]) to request the userhost and then define on_userhost in your client to handle the response.
(I haven’t tried this myself)