Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Feb 20 02:15

    jaraco on main

    Ran pre-commit autoupdate Merge https://github.com/jaraco… ⚫ Fade to black. (compare)

  • Feb 20 02:09
    jaraco labeled #197
  • Feb 20 02:09

    jaraco on main

    Suppress DeprecationWarning unt… (compare)

  • Feb 20 02:02
    jaraco opened #197
  • Feb 20 01:53

    jaraco on main

    Use preferred 'fixture'. Fixes … (compare)

  • Feb 20 01:52

    jaraco on main

    Update badge year Remove setup.py, no longer need… Add exclusions for pytest 7 dep… and 5 more (compare)

  • Jan 01 23:44

    jaraco on v20.0.0

    (compare)

  • Jan 01 23:44

    jaraco on main

    Remove wheel from build require… Require Python 3.7 or later. Remove filtered warnings, addre… and 5 more (compare)

  • Dec 22 2021 04:18
    fitnub-bosbud synchronize #196
  • Oct 19 2021 21:57
    fitnub-bosbud synchronize #196
  • Oct 19 2021 21:56
    fitnub-bosbud commented #196
  • Oct 19 2021 21:55
    fitnub-bosbud commented #196
  • Oct 19 2021 21:54
    fitnub-bosbud synchronize #196
  • Oct 19 2021 15:36
    jaraco commented #194
  • Oct 19 2021 14:32
    jaraco commented #196
  • Oct 19 2021 14:17

    jaraco on v20.0.0

    (compare)

  • Oct 19 2021 14:17

    jaraco on main

    Implement tidelift banner using… Remove blacken docs as it canno… .editorconfig: Set max_line_len… and 8 more (compare)

  • Oct 18 2021 22:27
    fitnub-bosbud commented #196
  • Oct 13 2021 01:19
    fitnub-bosbud commented #196
  • Oct 13 2021 01:19
    fitnub-bosbud commented #196
TurBoss
@TurBoss
sure
jus remove this:
to line 68
ry00001
@ry00001
Where's the example bot code
Jason R. Coombs
@jaraco
@ry00000 You might also look at testbot.py in the IRC project for a super basic example, or pmxbot for a more complex example, though if TurBoss’ ircbot gets you going then that’s fantastic.
ry00001
@ry00001
What's the example bot's prefix supposed to be?
: doesn't work
ry00001
@ry00001
@jaraco what's the example bot's prefix? I tried : but it didn't work
Jason R. Coombs
@jaraco
In test_bot, it looks like the prefix needs to be the bot nickname followed by a colon, so if the bot’s name is mybot, the prefix should be mybot:thecommand.
ry00001
@ry00001
ah
Jason R. Coombs
@jaraco
Each incoming message is handled in on_pubmsg, so you can adapt that to whatever behavior you want.
ry00001
@ry00001
Oh
but on_command is the main cmd loop
Jason R. Coombs
@jaraco
I’m not following. on_command does not appear in the testbot.py script (nor the irc library), so you’re probably getting that from elsewhere.
ry00001
@ry00001
er, no, do_command
sorry
Jason R. Coombs
@jaraco
Oh, right. Well on_pubmsg parses the incoming messages, and detects if there’s a command (as above) and if so, dispatches that using do_command.
ry00001
@ry00001
how do i turn pylint off
it's getting annoying
how do I get arguments from a command?
say i have kick <user> <channel>
how do i get user and channel
Jason R. Coombs
@jaraco
@ry00000: Not sure about pylint. Depends on your editor/environment. I don’t think IRC uses pylint itself.
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).
Jason R. Coombs
@jaraco
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