From ed045183b03d98a8d4d3fc61760804e1b752e209 Mon Sep 17 00:00:00 2001 From: Matthew Date: Thu, 3 Nov 2016 11:01:43 -0500 Subject: [PATCH 1/2] Added Test for PSA module --- .gitignore | 1 - docs/config.ini | 5 +++-- onebot/plugins/acl.py | 2 +- onebot/plugins/psa.py | 12 +++++++++--- tests/test_plugin_psa.py | 40 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 53 insertions(+), 7 deletions(-) create mode 100644 tests/test_plugin_psa.py diff --git a/.gitignore b/.gitignore index db33714..8c8410a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,6 @@ what.ini cookies.jar *.json *.bak - .DS_Store *.py[cod] diff --git a/docs/config.ini b/docs/config.ini index 2049d64..1cb11ff 100644 --- a/docs/config.ini +++ b/docs/config.ini @@ -5,7 +5,8 @@ host=my.irc.network port=6697 ssl=true -ssl_verify = CERT_NONE +# uncomment this if you don't want to check the certificate +# ssl_verify = CERT_NONE includes= irc3.plugins.uptime @@ -34,7 +35,7 @@ guard=onebot.plugins.acl.user_based_policy identify_by = mask [onebot.plugins.acl] -# Userhost without nick +# Pre-seed acl superadmin=me@my.awesome.host [onebot.plugins.lastfm] diff --git a/onebot/plugins/acl.py b/onebot/plugins/acl.py index 950d74f..a2846a4 100644 --- a/onebot/plugins/acl.py +++ b/onebot/plugins/acl.py @@ -77,7 +77,7 @@ class ACLPlugin(object): Configuration settings: - ``superadmin``: username to store in the database with - -``all_permissions`: username depends on mask chosen + - ``all_permissions``: username depends on mask chosen """ requires = [ diff --git a/onebot/plugins/psa.py b/onebot/plugins/psa.py index 929af2e..4af454c 100644 --- a/onebot/plugins/psa.py +++ b/onebot/plugins/psa.py @@ -27,7 +27,13 @@ def __init__(self, bot): def psa(self, mask, target, args): """Broadcast a public service announcement to all channels - %%psa ... + %%psa [...] """ - for channel in self.bot.channels: - self.bot.privmsg(channel, ' '.join(args[''])) + msg = ' '.join(args[''] or []) + if not msg: + self.bot.privmsg(mask.nick, "I need a message to announce") + # FIXME channels are only listed if activity (i.e. join, part) is + # recorded in them first, not a list of channels the bot is in. + else: + for channel in self.bot.channels: + self.bot.privmsg(channel, msg) diff --git a/tests/test_plugin_psa.py b/tests/test_plugin_psa.py new file mode 100644 index 0000000..72c22ee --- /dev/null +++ b/tests/test_plugin_psa.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +""" +test_plugin_psa +---------------------------------- + +Tests for PSA module +""" + +from irc3.testing import BotTestCase, patch + +from .test_plugin_users import MockDb + + +class PSATestCase(BotTestCase): + + config = { + 'includes': [ + 'onebot.plugins.psa', + 'irc3.plugins.command' + ], + 'cmd': '!' + } + + @patch('irc3.plugins.storage.Storage') + def setUp(self, mock): + super(PSATestCase, self).setUp() + self.callFTU() + self.bot.db = MockDb({ + 'the@boss': {'permissions': {'all_permissions'}} + }) + + def test_psa(self): + self.bot.dispatch(':rando!user@host JOIN #chan') + self.bot.dispatch(':im!the@boss PRIVMSG #chan :!psa best bot') + self.assertSent(['PRIVMSG #chan :best bot']) + + self.bot.dispatch(':im!the@boss PRIVMSG #chan :!psa') + self.assertSent(['PRIVMSG im :I need a message to announce']) From b80fb561b3f71b9822e62100b823f885a72229b2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Mar 2023 02:58:00 +0000 Subject: [PATCH 2/2] Bump coverallsapp/github-action from 1.1.3 to 1.2.3 Bumps [coverallsapp/github-action](https://github.com/coverallsapp/github-action) from 1.1.3 to 1.2.3. - [Release notes](https://github.com/coverallsapp/github-action/releases) - [Commits](https://github.com/coverallsapp/github-action/compare/1.1.3...v1.2.3) --- updated-dependencies: - dependency-name: coverallsapp/github-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/pythontest.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pythontest.yml b/.github/workflows/pythontest.yml index b179e52..39f573b 100644 --- a/.github/workflows/pythontest.yml +++ b/.github/workflows/pythontest.yml @@ -36,7 +36,7 @@ jobs: run: | poetry run black --check . - name: Coveralls Parallel - uses: coverallsapp/github-action@1.1.3 + uses: coverallsapp/github-action@v1.2.3 with: github-token: ${{ secrets.GITHUB_TOKEN }} flag-name: run-${{ matrix.python-version }} @@ -47,7 +47,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Coveralls Finished - uses: coverallsapp/github-action@1.1.3 + uses: coverallsapp/github-action@v1.2.3 with: github-token: ${{ secrets.GITHUB_TOKEN }} parallel-finished: true