Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Sijis Aviles
@sijis
Ohh. Gutter has threading now.
It looks terrible in an android app :/
Carlos
@nzlosh
:)
Anshul Choudhary
@achoudh5

Hi All
I am trying to schedule a cron job to post message on slack using my Err Bot . Has anyone used a scheduler/cron job for the same?

      def activate(self):
         super().activate()
         self.start_poller(60, self.oncall(msg,args), times=1)

Above is my code snippet I am using to schedule my function oncall after every 60seconds.

    @botcmd
    def oncall(self, msg, args):

Above is the function I am trying to call from my scheduler/cronjob

Second question:- above all my other functions I have used @botcmd but am not sure how to implement a scheduler with or without @
Mark Sullivan
@marksull

@achoudh5 yes I use the poller often. The mistake you've made is that you calling the on_call method in the start poller rather than just passing the method. For example it should be

def activate(self):
         super().activate()
         self.start_poller(60, self.oncall, 1, msg, args)

def oncall(self, msg, args):
    print("in on call")

I also noticed that your activate method doesn't contain the variables msg or args so are you making an assumption that they are present? If they are not going to be present then your code should be:

def activate(self):
         super().activate()
         self.start_poller(60, self.oncall, 1)

def oncall(self):
    print("in on call")
Anshul Choudhary
@achoudh5
@marksull thanks for correcting my code. Although I am not seeing any errors when I start my err bot on cli, my polling is not happening. Shouldn't my program run after 60 seconds on it's own? Also, if I remove times argument it would run infinitely after every 60 seconds right?
Anshul Choudhary
@achoudh5
Has anyone been getting 00:21:55 WARNING slackclient.client Failed RTM connect messages while integrating err bot with slack? I have used correct Bot OAuth token and getting this persistent error :/
Carlos
@nzlosh
@achoudh5 What type of bot token are you using, the legacy bot token or the fine gain bot token?
Anshul Choudhary
@achoudh5
@nzlosh I have used both classic app and normal bots & facing same issue
Carlos
@nzlosh
Which slack backend are you using?
Anshul Choudhary
@achoudh5
I am running it on my local machine for now
Carlos
@nzlosh
If you have a legacy token, you should be able to use the Slack backend with the slackclient v1.3.1 without any problems. If you're using scoped tokens, you'll need to use the Slack Event backend (There's a PR open but it hasn't been merged into master yet). Slack doesn't allow scoped tokens to connect to the RTM API.
Anshul Choudhary
@achoudh5

@nzlosh my config.py looks like this for ErrBot:-

import logging
BACKEND = 'Slack' 
BOT_IDENTITY ={'token':'xoxb-<slack OAuth Bot token>'}
BOT_DATA_DIR = r'<path>/ErrBot/errbot/data'
BOT_EXTRA_PLUGIN_DIR = r'<path>/ErrBot/errbot/plugins'
BOT_LOG_FILE = r'<path>/ErrBot/errbot/errbot.log'
BOT_LOG_LEVEL = logging.DEBUG
BOT_ADMINS = ("<slack_admin_name>")

Is there any more setting I need to do to make it work?

Carlos
@nzlosh
To use the Slack backend you must have a legacy token. To create one, follow these instructions https://github.com/slackapi/python-slack-sdk/issues/609#issuecomment-639887212.
Oz Linden
@oz-linden
I'm trying to use errbot with slack; having been doing so successfully for quite some time, but need to update to avoid the api deprecation in February.
I'm loading errbot from pip, and using with a local checkout of err-storage-sql. The pip command I use is pip install errbot[slack] which works, but when I start up I get log messages: ```
INFO sqlalchemy.engine.base.Engine DESCRIBE slack_backend
ERROR Could not start the SlackRTM backend
CRITICAL You need to install slackclient in order to use the Slack backend. You can do pip install errbot[slack-rtm] to install it.
but as far as I know I'm not configuring the SlackRTM anywhere...
Anshul Choudhary
@achoudh5

To use the Slack backend you must have a legacy token. To create one, follow these instructions https://github.com/slackapi/python-slack-sdk/issues/609#issuecomment-639887212.

@nzlosh there seems to be upgradation, there is not bot scope I have seen and rest I followed similar process before as well :/

Carlos
@nzlosh
@achoudh5 I just tested creating a legacy token following those instructions as a workspace owner and as a workspace user, both worked as described in the link.
Carlos
@nzlosh
@oz-linden Did you change the oauth scope of your bot token?
Oz Linden
@oz-linden
The token I'm using is a legacy token. I've been running this since long before the new scoped tokens.
Carlos
@nzlosh
What changed for it to stop working?
Oz Linden
@oz-linden
I updated to the 6.1.6 version of errbot by using an install from pypi (previously, I'd been doing my builds from a checked out local copy of an older version)
Carlos
@nzlosh
What version of slackclient are you using?
I don't use the slack_rtm backend but my understanding is you need to use slackclient v2 with it.
Oz Linden
@oz-linden
Collecting slackclient<2.0,>=1.0.5; extra == "slack" (from errbot[slack]->-r requirements.txt (line 12))
https://files.pythonhosted.org/packages/7c/2f/9b6db4c7686be3dc6b4244eaef4f37226a2ccca1a796516d4adcdfeefe56/slackclient-1.3.2.tar.gz
I'm trying not to use slack_rtm (or rather, not trying to use it), which is what confuses me. It almost looks as though something has stored that in the stored preferences (DESCRIBE slack_backend)?
My configuration just has BACKEND = 'Slack'
Carlos
@nzlosh
That's strange because the error message you posted ERROR Could not start the SlackRTM backend matches slack_rtm.py:32: log.exception("Could not start the SlackRTM backend")
Oz Linden
@oz-linden
Yeah, I found that... which has me pretty confused. I literally don't have the string 'RTM' anywhere in my source that I can find
Carlos
@nzlosh
It should be errbot's configuration file the defines the BACKEND variable, so unless there's another configuration file laying around that errbot could be automatically detecting, I can't really explain it. Maybe a clean install could help?
alpinweis
@alpinweis

I have a command with an argument. I'd like it to work with a default value if the argument is omitted.

@arg_botcmd("service_name", type=str, default="default_service", help="Service name")
def xstatus(self, msg, service_name):
  ...

What's the right way to do it? I get an error when I try to run it w/o an argument:

User: !xstatus myservice
Errbot: ok

User: !xstatus
Errbot: I couldn't parse the arguments; the following arguments are required: service_name
Carlos
@nzlosh
Have you tried setting the default value on the Python function? def xstatus(self, msg, service_name="default_service"):?
4 replies
Carlos
@nzlosh
What version of Python are you using?
Alex Sheluchin
@sheluchin
I still cannot get provisioning to work with err-storage-sql. errbot --storage-get <plugin> gives me the right config dict back but it's not actually applied -- errbot complains that the plugin isn't configured when it boots. I don't think errbotio/errbot#910 should have been closed.
Sijis Aviles
@sijis
Does it work without using a different storage backend?
Tomás Gutiérrez
@0x00cl_gitlab
Hello, I'm trying to schedule a callback following the documentation in here https://errbot.readthedocs.io/en/6.1.6/user_guide/plugin_development/scheduling.html
The function works fine if I do something as simple as self.send(...) but if I add more lines it stops working, is there any limit or possible reason for this?
Or is just my code bad? :p
Even if the first line of the function is self.send(...) it doesn't appear to get called
I get this message 2020-12-04 20:12:40,809 DEBUG errbot.botplugin Previous timer found and removed
Sijis Aviles
@sijis
I would appreciate feedback on slack backend plan/suggestion: errbotio/errbot#1480
Sijis Aviles
@sijis
I published the master branch as the latest tag in docker hub: https://hub.docker.com/r/errbotio/errbot
i'm hoping to publish a new release tomorrow (and publish to pypi) along with a docker image
Sijis Aviles
@sijis
Errbot 6.1.7 released. Mostly a clean up release.
Carlos
@nzlosh
Thanks for your work @sijis :thumbsup:
eggcaker
@eggcaker
hi all, I'm new to errbot , when i setup the basic errbot with a slack backend following the guide, fater that ,every message i sent to channel the bot cannot reply to channel
Atlas974
@Atlas974
This may be a bug: I try to use the @cmdfilter decorator to modify the arguments passed to a @re_botcmd command but it doesn't work as expected.
When I """return msg, cmd, new_args"" the new_args are not used by re.match. Instead, the """old_args""" are used. Is there something I missed?
@re_botcmd(pattern=r"(?=.*re?)(?=.*cmd)(?=.*param=(?P<param>\w+))",
        flags=re.IGNORECASE)
def my_re_cmd(self, msg, match):
    my_parm = match.groupdict().get("param", None)
    yield f"My re cmd with a param={my_param}"
    ...

@cmdfilter
def my_filter(self, msg, cmd, args, dry_run):
    if cmd == self.my_re_cmd.__name__:
        return msg, "my_func", None
    return None, None, None

@re_botcmd(pattern=r"ah ah")
def my_func(self, msg, match):
    print(match.groupdict()) # {'param' = 123} BUG???
    yield "My func"
Alex Sheluchin
@sheluchin
I'm getting Syntax error in the given configuration when trying to configure my plugins through Slack. It seems to happen intermittently. Anyone know what might be the cause? I've documented a similar issue here before errbotio/errbot#1298
Or any ideas for how to diagnose it, because there doesn't seem to be anything wrong with the configuration and there's nothing in the logs that seems helpful.
Carlos
@nzlosh
That message is inside a big catch all exception. The actual error is not being logged, just the text you quoted. To debug further, I'd recommend adding logging which displays the actual exception message, you may get more hints that way.