mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-08-13 08:27:22 +02:00
Compare commits
No commits in common. "v0.83.1" and "gh-pages" have entirely different histories.
8
.editorconfig
Normal file
8
.editorconfig
Normal file
@ -0,0 +1,8 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
end_of_line = lf
|
||||
trim_trailing_whitespace = false
|
||||
insert_final_newline = true
|
||||
charset = utf-8
|
||||
indent_style = space
|
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@ -0,0 +1 @@
|
||||
* text=auto eol=lf
|
1
.github/CODEOWNERS
vendored
Normal file
1
.github/CODEOWNERS
vendored
Normal file
@ -0,0 +1 @@
|
||||
* @Mikaela
|
5
.github/renovate.json5
vendored
Normal file
5
.github/renovate.json5
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
/** @format */
|
||||
|
||||
{
|
||||
extends: ["local>Mikaela/shell-things:.renovate-shared"],
|
||||
}
|
25
.github/workflows/html5validator.yml.disabled
vendored
Normal file
25
.github/workflows/html5validator.yml.disabled
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
name: HTML5 Validator
|
||||
|
||||
on:
|
||||
push:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4 # Required will all actions
|
||||
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 3.1
|
||||
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
||||
|
||||
- name: Jekyll build
|
||||
run: |
|
||||
bundle exec jekyll build --drafts --profile
|
||||
|
||||
- name: Checks HTML5 validity
|
||||
uses: Cyb3r-Jak3/html5validator-action@v7.2.0
|
||||
with:
|
||||
root: _site/
|
||||
blacklist: n r or ir
|
32
.gitignore
vendored
Normal file
32
.gitignore
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
*.mo
|
||||
*.py[cdo]
|
||||
*~
|
||||
.*.swp
|
||||
.swp
|
||||
MANIFEST
|
||||
backup/
|
||||
build/
|
||||
debian/compat
|
||||
debian/files
|
||||
debian/limnoria*
|
||||
debian/python-module-stampdir/
|
||||
dist/
|
||||
docs/_build/
|
||||
docs/plugins/
|
||||
limnoria.egg-info/
|
||||
merge.sh
|
||||
nano.save
|
||||
push.sh
|
||||
py3k/
|
||||
src/version.py
|
||||
supybot.egg-info/
|
||||
test-conf/
|
||||
test-data/
|
||||
test-logs/
|
||||
src/version.py
|
||||
_site
|
||||
.sass-cache
|
||||
vendor/
|
||||
.bundle
|
||||
node_modules/
|
||||
pnpm-lock.yaml
|
83
.pre-commit-config.yaml
Normal file
83
.pre-commit-config.yaml
Normal file
@ -0,0 +1,83 @@
|
||||
# @format
|
||||
|
||||
# SPDX-FileCopyrightText: 2023 Aminda Suomalainen <suomalainen+git@mikaela.info>
|
||||
#
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
# See https://pre-commit.com for more information
|
||||
# See https://pre-commit.ci for more information
|
||||
ci:
|
||||
# I don't need so many duplicated notifications on the same thing as I keep
|
||||
# autoupdating manually too. Besides it just creates extra branch I never
|
||||
# touch.
|
||||
# https://github.com/pre-commit-ci/issues/issues/83
|
||||
autoupdate_schedule: quarterly
|
||||
skip: [pnpm-install-dev, prettier]
|
||||
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v5.0.0
|
||||
hooks:
|
||||
- id: trailing-whitespace
|
||||
args: ["--markdown-linebreak-ext", "md,markdown"]
|
||||
exclude_types: [svg, tsv]
|
||||
- id: end-of-file-fixer
|
||||
- id: check-yaml
|
||||
- id: check-added-large-files
|
||||
- id: check-case-conflict
|
||||
- id: check-executables-have-shebangs
|
||||
- id: check-json
|
||||
- id: check-merge-conflict
|
||||
- id: check-shebang-scripts-are-executable
|
||||
- id: destroyed-symlinks
|
||||
- id: detect-private-key
|
||||
- id: fix-byte-order-marker
|
||||
- id: check-merge-conflict
|
||||
- id: mixed-line-ending
|
||||
args: [--fix=auto]
|
||||
- id: pretty-format-json
|
||||
args: [--autofix, --no-ensure-ascii]
|
||||
|
||||
- repo: https://github.com/pre-commit-ci/pre-commit-ci-config
|
||||
rev: v1.6.1
|
||||
hooks:
|
||||
- id: check-pre-commit-ci-config
|
||||
|
||||
- repo: https://github.com/thlorenz/doctoc
|
||||
rev: v2.2.0
|
||||
hooks:
|
||||
- id: doctoc
|
||||
args: [--update-only, --notitle]
|
||||
|
||||
- repo: https://github.com/python-jsonschema/check-jsonschema
|
||||
rev: 0.33.0
|
||||
hooks:
|
||||
- id: check-dependabot
|
||||
- id: check-github-workflows
|
||||
- id: check-gitlab-ci
|
||||
|
||||
# - repo: https://github.com/fsfe/reuse-tool
|
||||
# rev: v3.0.2
|
||||
# hooks:
|
||||
# - id: reuse
|
||||
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: pnpm-install-dev
|
||||
name: Install pnpm dev dependencies
|
||||
entry: corepack pnpm install -D
|
||||
language: system
|
||||
always_run: true
|
||||
#verbose: true
|
||||
pass_filenames: false
|
||||
- id: prettier
|
||||
name: prettier
|
||||
entry: corepack pnpm exec prettier --cache --ignore-unknown --write
|
||||
language: system
|
||||
|
||||
- repo: https://github.com/editorconfig-checker/editorconfig-checker.python
|
||||
rev: "3.2.1"
|
||||
hooks:
|
||||
- id: editorconfig-checker
|
||||
alias: ec
|
||||
args: [-disable-max-line-length]
|
5
.prettierignore
Normal file
5
.prettierignore
Normal file
@ -0,0 +1,5 @@
|
||||
_includes/
|
||||
_layouts/
|
||||
_sass/
|
||||
css/
|
||||
feed.xml
|
1
.prettierrc
Normal file
1
.prettierrc
Normal file
@ -0,0 +1 @@
|
||||
{}
|
1
.ruby-version
Normal file
1
.ruby-version
Normal file
@ -0,0 +1 @@
|
||||
3.4.2
|
4
.travis.yml
Normal file
4
.travis.yml
Normal file
@ -0,0 +1,4 @@
|
||||
# @format
|
||||
|
||||
language: ruby
|
||||
script: "bundle exec jekyll build"
|
12
ACKS
12
ACKS
@ -1,12 +0,0 @@
|
||||
* johhnyace, who gave me the modem that helped me tremendously early on
|
||||
in development.
|
||||
|
||||
* sweede, for hosting the "main" supybot for awhile.
|
||||
|
||||
* bwp, who rewrote the Http.weather command (ham site), and also
|
||||
hosted the canonical supybot in #supybot on OFTC and Freenode for
|
||||
quite some time.
|
||||
|
||||
* HostPC.com, for hosting the current canonical "supybot" and for
|
||||
graciously providing DNS services and email.
|
||||
|
8
Gemfile
Normal file
8
Gemfile
Normal file
@ -0,0 +1,8 @@
|
||||
source "https://rubygems.org"
|
||||
ruby file: ".ruby-version"
|
||||
# For now this is a GitHub Pages hosted website.
|
||||
# Ref: https://github.com/Mikaela/mikaela.github.io/issues/153
|
||||
gem 'github-pages', group: :jekyll_plugins
|
||||
gem 'jekyll-seo-tag'
|
||||
# Required for `bundle exec jekyll serve`
|
||||
gem "webrick"
|
286
Gemfile.lock
Normal file
286
Gemfile.lock
Normal file
@ -0,0 +1,286 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
activesupport (8.0.2)
|
||||
base64
|
||||
benchmark (>= 0.3)
|
||||
bigdecimal
|
||||
concurrent-ruby (~> 1.0, >= 1.3.1)
|
||||
connection_pool (>= 2.2.5)
|
||||
drb
|
||||
i18n (>= 1.6, < 2)
|
||||
logger (>= 1.4.2)
|
||||
minitest (>= 5.1)
|
||||
securerandom (>= 0.3)
|
||||
tzinfo (~> 2.0, >= 2.0.5)
|
||||
uri (>= 0.13.1)
|
||||
addressable (2.8.7)
|
||||
public_suffix (>= 2.0.2, < 7.0)
|
||||
base64 (0.2.0)
|
||||
benchmark (0.4.0)
|
||||
bigdecimal (3.1.9)
|
||||
coffee-script (2.4.1)
|
||||
coffee-script-source
|
||||
execjs
|
||||
coffee-script-source (1.12.2)
|
||||
colorator (1.1.0)
|
||||
commonmarker (0.23.11)
|
||||
concurrent-ruby (1.3.5)
|
||||
connection_pool (2.5.0)
|
||||
csv (3.3.3)
|
||||
dnsruby (1.72.4)
|
||||
base64 (~> 0.2.0)
|
||||
logger (~> 1.6.5)
|
||||
simpleidn (~> 0.2.1)
|
||||
drb (2.2.1)
|
||||
em-websocket (0.5.3)
|
||||
eventmachine (>= 0.12.9)
|
||||
http_parser.rb (~> 0)
|
||||
ethon (0.16.0)
|
||||
ffi (>= 1.15.0)
|
||||
eventmachine (1.2.7)
|
||||
execjs (2.10.0)
|
||||
faraday (2.13.0)
|
||||
faraday-net_http (>= 2.0, < 3.5)
|
||||
json
|
||||
logger
|
||||
faraday-net_http (3.4.0)
|
||||
net-http (>= 0.5.0)
|
||||
ffi (1.17.1-x86_64-linux-gnu)
|
||||
forwardable-extended (2.6.0)
|
||||
gemoji (4.1.0)
|
||||
github-pages (232)
|
||||
github-pages-health-check (= 1.18.2)
|
||||
jekyll (= 3.10.0)
|
||||
jekyll-avatar (= 0.8.0)
|
||||
jekyll-coffeescript (= 1.2.2)
|
||||
jekyll-commonmark-ghpages (= 0.5.1)
|
||||
jekyll-default-layout (= 0.1.5)
|
||||
jekyll-feed (= 0.17.0)
|
||||
jekyll-gist (= 1.5.0)
|
||||
jekyll-github-metadata (= 2.16.1)
|
||||
jekyll-include-cache (= 0.2.1)
|
||||
jekyll-mentions (= 1.6.0)
|
||||
jekyll-optional-front-matter (= 0.3.2)
|
||||
jekyll-paginate (= 1.1.0)
|
||||
jekyll-readme-index (= 0.3.0)
|
||||
jekyll-redirect-from (= 0.16.0)
|
||||
jekyll-relative-links (= 0.6.1)
|
||||
jekyll-remote-theme (= 0.4.3)
|
||||
jekyll-sass-converter (= 1.5.2)
|
||||
jekyll-seo-tag (= 2.8.0)
|
||||
jekyll-sitemap (= 1.4.0)
|
||||
jekyll-swiss (= 1.0.0)
|
||||
jekyll-theme-architect (= 0.2.0)
|
||||
jekyll-theme-cayman (= 0.2.0)
|
||||
jekyll-theme-dinky (= 0.2.0)
|
||||
jekyll-theme-hacker (= 0.2.0)
|
||||
jekyll-theme-leap-day (= 0.2.0)
|
||||
jekyll-theme-merlot (= 0.2.0)
|
||||
jekyll-theme-midnight (= 0.2.0)
|
||||
jekyll-theme-minimal (= 0.2.0)
|
||||
jekyll-theme-modernist (= 0.2.0)
|
||||
jekyll-theme-primer (= 0.6.0)
|
||||
jekyll-theme-slate (= 0.2.0)
|
||||
jekyll-theme-tactile (= 0.2.0)
|
||||
jekyll-theme-time-machine (= 0.2.0)
|
||||
jekyll-titles-from-headings (= 0.5.3)
|
||||
jemoji (= 0.13.0)
|
||||
kramdown (= 2.4.0)
|
||||
kramdown-parser-gfm (= 1.1.0)
|
||||
liquid (= 4.0.4)
|
||||
mercenary (~> 0.3)
|
||||
minima (= 2.5.1)
|
||||
nokogiri (>= 1.16.2, < 2.0)
|
||||
rouge (= 3.30.0)
|
||||
terminal-table (~> 1.4)
|
||||
webrick (~> 1.8)
|
||||
github-pages-health-check (1.18.2)
|
||||
addressable (~> 2.3)
|
||||
dnsruby (~> 1.60)
|
||||
octokit (>= 4, < 8)
|
||||
public_suffix (>= 3.0, < 6.0)
|
||||
typhoeus (~> 1.3)
|
||||
html-pipeline (2.14.3)
|
||||
activesupport (>= 2)
|
||||
nokogiri (>= 1.4)
|
||||
http_parser.rb (0.8.0)
|
||||
i18n (1.14.7)
|
||||
concurrent-ruby (~> 1.0)
|
||||
jekyll (3.10.0)
|
||||
addressable (~> 2.4)
|
||||
colorator (~> 1.0)
|
||||
csv (~> 3.0)
|
||||
em-websocket (~> 0.5)
|
||||
i18n (>= 0.7, < 2)
|
||||
jekyll-sass-converter (~> 1.0)
|
||||
jekyll-watch (~> 2.0)
|
||||
kramdown (>= 1.17, < 3)
|
||||
liquid (~> 4.0)
|
||||
mercenary (~> 0.3.3)
|
||||
pathutil (~> 0.9)
|
||||
rouge (>= 1.7, < 4)
|
||||
safe_yaml (~> 1.0)
|
||||
webrick (>= 1.0)
|
||||
jekyll-avatar (0.8.0)
|
||||
jekyll (>= 3.0, < 5.0)
|
||||
jekyll-coffeescript (1.2.2)
|
||||
coffee-script (~> 2.2)
|
||||
coffee-script-source (~> 1.12)
|
||||
jekyll-commonmark (1.4.0)
|
||||
commonmarker (~> 0.22)
|
||||
jekyll-commonmark-ghpages (0.5.1)
|
||||
commonmarker (>= 0.23.7, < 1.1.0)
|
||||
jekyll (>= 3.9, < 4.0)
|
||||
jekyll-commonmark (~> 1.4.0)
|
||||
rouge (>= 2.0, < 5.0)
|
||||
jekyll-default-layout (0.1.5)
|
||||
jekyll (>= 3.0, < 5.0)
|
||||
jekyll-feed (0.17.0)
|
||||
jekyll (>= 3.7, < 5.0)
|
||||
jekyll-gist (1.5.0)
|
||||
octokit (~> 4.2)
|
||||
jekyll-github-metadata (2.16.1)
|
||||
jekyll (>= 3.4, < 5.0)
|
||||
octokit (>= 4, < 7, != 4.4.0)
|
||||
jekyll-include-cache (0.2.1)
|
||||
jekyll (>= 3.7, < 5.0)
|
||||
jekyll-mentions (1.6.0)
|
||||
html-pipeline (~> 2.3)
|
||||
jekyll (>= 3.7, < 5.0)
|
||||
jekyll-optional-front-matter (0.3.2)
|
||||
jekyll (>= 3.0, < 5.0)
|
||||
jekyll-paginate (1.1.0)
|
||||
jekyll-readme-index (0.3.0)
|
||||
jekyll (>= 3.0, < 5.0)
|
||||
jekyll-redirect-from (0.16.0)
|
||||
jekyll (>= 3.3, < 5.0)
|
||||
jekyll-relative-links (0.6.1)
|
||||
jekyll (>= 3.3, < 5.0)
|
||||
jekyll-remote-theme (0.4.3)
|
||||
addressable (~> 2.0)
|
||||
jekyll (>= 3.5, < 5.0)
|
||||
jekyll-sass-converter (>= 1.0, <= 3.0.0, != 2.0.0)
|
||||
rubyzip (>= 1.3.0, < 3.0)
|
||||
jekyll-sass-converter (1.5.2)
|
||||
sass (~> 3.4)
|
||||
jekyll-seo-tag (2.8.0)
|
||||
jekyll (>= 3.8, < 5.0)
|
||||
jekyll-sitemap (1.4.0)
|
||||
jekyll (>= 3.7, < 5.0)
|
||||
jekyll-swiss (1.0.0)
|
||||
jekyll-theme-architect (0.2.0)
|
||||
jekyll (> 3.5, < 5.0)
|
||||
jekyll-seo-tag (~> 2.0)
|
||||
jekyll-theme-cayman (0.2.0)
|
||||
jekyll (> 3.5, < 5.0)
|
||||
jekyll-seo-tag (~> 2.0)
|
||||
jekyll-theme-dinky (0.2.0)
|
||||
jekyll (> 3.5, < 5.0)
|
||||
jekyll-seo-tag (~> 2.0)
|
||||
jekyll-theme-hacker (0.2.0)
|
||||
jekyll (> 3.5, < 5.0)
|
||||
jekyll-seo-tag (~> 2.0)
|
||||
jekyll-theme-leap-day (0.2.0)
|
||||
jekyll (> 3.5, < 5.0)
|
||||
jekyll-seo-tag (~> 2.0)
|
||||
jekyll-theme-merlot (0.2.0)
|
||||
jekyll (> 3.5, < 5.0)
|
||||
jekyll-seo-tag (~> 2.0)
|
||||
jekyll-theme-midnight (0.2.0)
|
||||
jekyll (> 3.5, < 5.0)
|
||||
jekyll-seo-tag (~> 2.0)
|
||||
jekyll-theme-minimal (0.2.0)
|
||||
jekyll (> 3.5, < 5.0)
|
||||
jekyll-seo-tag (~> 2.0)
|
||||
jekyll-theme-modernist (0.2.0)
|
||||
jekyll (> 3.5, < 5.0)
|
||||
jekyll-seo-tag (~> 2.0)
|
||||
jekyll-theme-primer (0.6.0)
|
||||
jekyll (> 3.5, < 5.0)
|
||||
jekyll-github-metadata (~> 2.9)
|
||||
jekyll-seo-tag (~> 2.0)
|
||||
jekyll-theme-slate (0.2.0)
|
||||
jekyll (> 3.5, < 5.0)
|
||||
jekyll-seo-tag (~> 2.0)
|
||||
jekyll-theme-tactile (0.2.0)
|
||||
jekyll (> 3.5, < 5.0)
|
||||
jekyll-seo-tag (~> 2.0)
|
||||
jekyll-theme-time-machine (0.2.0)
|
||||
jekyll (> 3.5, < 5.0)
|
||||
jekyll-seo-tag (~> 2.0)
|
||||
jekyll-titles-from-headings (0.5.3)
|
||||
jekyll (>= 3.3, < 5.0)
|
||||
jekyll-watch (2.2.1)
|
||||
listen (~> 3.0)
|
||||
jemoji (0.13.0)
|
||||
gemoji (>= 3, < 5)
|
||||
html-pipeline (~> 2.2)
|
||||
jekyll (>= 3.0, < 5.0)
|
||||
json (2.10.2)
|
||||
kramdown (2.4.0)
|
||||
rexml
|
||||
kramdown-parser-gfm (1.1.0)
|
||||
kramdown (~> 2.0)
|
||||
liquid (4.0.4)
|
||||
listen (3.9.0)
|
||||
rb-fsevent (~> 0.10, >= 0.10.3)
|
||||
rb-inotify (~> 0.9, >= 0.9.10)
|
||||
logger (1.6.6)
|
||||
mercenary (0.3.6)
|
||||
minima (2.5.1)
|
||||
jekyll (>= 3.5, < 5.0)
|
||||
jekyll-feed (~> 0.9)
|
||||
jekyll-seo-tag (~> 2.1)
|
||||
minitest (5.25.5)
|
||||
net-http (0.6.0)
|
||||
uri
|
||||
nokogiri (1.18.7-x86_64-linux-gnu)
|
||||
racc (~> 1.4)
|
||||
octokit (4.25.1)
|
||||
faraday (>= 1, < 3)
|
||||
sawyer (~> 0.9)
|
||||
pathutil (0.16.2)
|
||||
forwardable-extended (~> 2.6)
|
||||
public_suffix (5.1.1)
|
||||
racc (1.8.1)
|
||||
rb-fsevent (0.11.2)
|
||||
rb-inotify (0.11.1)
|
||||
ffi (~> 1.0)
|
||||
rexml (3.4.1)
|
||||
rouge (3.30.0)
|
||||
rubyzip (2.4.1)
|
||||
safe_yaml (1.0.5)
|
||||
sass (3.7.4)
|
||||
sass-listen (~> 4.0.0)
|
||||
sass-listen (4.0.0)
|
||||
rb-fsevent (~> 0.9, >= 0.9.4)
|
||||
rb-inotify (~> 0.9, >= 0.9.7)
|
||||
sawyer (0.9.2)
|
||||
addressable (>= 2.3.5)
|
||||
faraday (>= 0.17.3, < 3)
|
||||
securerandom (0.4.1)
|
||||
simpleidn (0.2.3)
|
||||
terminal-table (1.8.0)
|
||||
unicode-display_width (~> 1.1, >= 1.1.1)
|
||||
typhoeus (1.4.1)
|
||||
ethon (>= 0.9.0)
|
||||
tzinfo (2.0.6)
|
||||
concurrent-ruby (~> 1.0)
|
||||
unicode-display_width (1.8.0)
|
||||
uri (1.0.3)
|
||||
webrick (1.9.1)
|
||||
|
||||
PLATFORMS
|
||||
x86_64-linux
|
||||
|
||||
DEPENDENCIES
|
||||
github-pages
|
||||
jekyll-seo-tag
|
||||
webrick
|
||||
|
||||
RUBY VERSION
|
||||
ruby 3.4.2p28
|
||||
|
||||
BUNDLED WITH
|
||||
2.6.2
|
91
INSTALL
91
INSTALL
@ -1,91 +0,0 @@
|
||||
Common
|
||||
|
||||
First things first: Supybot *requires* at least Python 2.3. There
|
||||
ain't no getting around it. We do not require any version greater than
|
||||
2.3, but we will be compatible with any version of Python >= 2.3. If
|
||||
you're a Python developer, you probably know how superior 2.3 is to
|
||||
previous incarnations. If you're not, just think about the difference
|
||||
between a bowl of plain vanilla ice cream and a banana split. Or
|
||||
something like that. Either way, *We're* Python developers and we like
|
||||
banana splits. So, be sure to install python2.3 or greater before
|
||||
continuing. You can get it from http://www.python.org/.
|
||||
|
||||
Recommended Software
|
||||
|
||||
PySQLite -- Version 1.0.x
|
||||
|
||||
Twisted -- Version 1.2.0 or greater
|
||||
|
||||
For more information and help on how to use Supybot, checkout
|
||||
the documents under docs/ (especially GETTING_STARTED and
|
||||
CONFIGURATION). Our forums (http://supybot.com/forums/) may also be of
|
||||
use.
|
||||
|
||||
So what do you do? That depends on which operating system you're
|
||||
running. We've split this document up to address the different
|
||||
methods, so find the section for your operating system and continue
|
||||
from there.
|
||||
|
||||
UNIX/Linux/*BSD
|
||||
|
||||
If you're installing Python using your distributor's packages, you may
|
||||
need a python-dev package installed, too. If you don't have a
|
||||
'/usr/lib/python2.3/distutils' directory or
|
||||
'/usr/lib/python2.3/config/Makefile' (assuming '/usr/lib/python2.3' is
|
||||
where your Python libs are installed), then you will need a python-dev
|
||||
package.
|
||||
|
||||
After you extract Supybot and cd into the supybot directory just
|
||||
created, you'll want to run (as root) 'python setup.py install'. This
|
||||
will install Supybot globally. If you need to install locally for
|
||||
whatever reason, see the notes at the end of this section. You'll then
|
||||
have several new programs installed where Python scripts are normally
|
||||
installed on your system ('/usr/bin' or '/usr/local/bin' are common on
|
||||
UNIX systems). The two that might be of particular interest to you, the
|
||||
new user, are 'supybot' and 'supybot-wizard'. The former, 'supybot', is
|
||||
the script to run an actual bot; the latter, 'supybot-wizard', is an
|
||||
in-depth wizard that provides a nice user interface for creating a
|
||||
registry file for your bot.
|
||||
|
||||
Local Install
|
||||
|
||||
You can install Supybot in a local directory by using the '--prefix'
|
||||
option when running 'setup.py'. E.g., 'python setup.py install
|
||||
--prefix=$HOME' to install into your home directory. You'll now have
|
||||
a $HOME/bin directory containing Supybot programs ('supybot',
|
||||
'supybot-wizard', etc.) and a $HOME/lib directory containing the
|
||||
Supybot libraries. It is also recommended that you setup a proper
|
||||
PYTHONPATH environment variable in your shell's init file.
|
||||
|
||||
bash -- 'export PYTHONPATH=$HOME/lib/python2.3/site-packages'
|
||||
|
||||
(t)csh -- 'setenv PYTHONPATH $HOME/lib/python2.3/site-packages'
|
||||
|
||||
Windows
|
||||
|
||||
**Note**: If you are using an IPV6 connection, you will not be able
|
||||
to run Supybot under Windows (unless Python has fixed things). Current
|
||||
versions of Python for Windows are *not* built with IPV6 support. This
|
||||
isn't expected to be fixed until Python 2.4, at the earliest.
|
||||
|
||||
Now that you have Python installed, open up a command prompt. The
|
||||
easiest way to do this is to open the run dialog (Programs -> run) and
|
||||
type "cmd" (for Windows 2000/XP/2003) or "command" (for Windows 9x). In
|
||||
order to reduce the amount of typing you need to do, I suggest adding
|
||||
Python's directory to your path. If you installed Python using the
|
||||
default settings, you would then do the following in the command prompt
|
||||
(otherwise change the path to match your settings)::
|
||||
|
||||
set PATH=C:\Python23\;%PATH%
|
||||
|
||||
You should now be able to type 'python' to start the Python
|
||||
interpreter. Exit by pressing CTRL-Z and then Return. Now that that's
|
||||
setup, you'll want to cd into the directory that was created when you
|
||||
unzipped Supybot; I'll assume you unzipped it to 'C:\Supybot' for these
|
||||
instructions. From 'C:\Supybot', run 'python setup.py install'. This
|
||||
will install Supybot under 'C:\Python23\'. You will now have several new
|
||||
programs installed in 'C:\Python23\Scripts\'. The two that might be of
|
||||
particular interest to you, the new user, are 'supybot' and 'supybot-wizard'.
|
||||
The former, 'supybot', is the script to run an actual bot; the latter,
|
||||
'supybot-wizard', is an in-depth wizard that provides a nice user interface for
|
||||
creating a registry file for your bot.
|
28
LICENSE
28
LICENSE
@ -1,28 +0,0 @@
|
||||
Copyright (c) 2002-2005 Jeremiah Fincher and others
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions, and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions, and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the author of this software nor the name of
|
||||
contributors to this software may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
Portions of the included source code are copyright by its original author(s)
|
||||
and remain subject to its associated license.
|
31
README
31
README
@ -1,31 +0,0 @@
|
||||
EVERYONE:
|
||||
---------
|
||||
Read LICENSE. It's a 2-clause BSD license, but you should read it
|
||||
anyway.
|
||||
|
||||
|
||||
USERS:
|
||||
------
|
||||
If you're upgrading, read RELNOTES. There is also much documentation
|
||||
at http://supybot.com/ for your perusal. Please read it; we took the
|
||||
time to write it, you should take the time to read it.
|
||||
|
||||
If you have any trouble, feel free to swing by #supybot on
|
||||
irc.freenode.net or irc.oftc.net (we have a Supybot there relaying,
|
||||
so either network works) and ask questions. We'll be happy to help
|
||||
wherever we can. And by all means, if you find anything hard to
|
||||
understand or think you know of a better way to do something,
|
||||
*please* post it on Sourceforge.net so we can improve the bot!
|
||||
|
||||
WINDOWS USERS:
|
||||
--------------
|
||||
The wizards (supybot-wizard, supybot-newplugin, and
|
||||
supybot-adduser) are all installed to your Python directory's
|
||||
\Scripts. What that *probably* means is that you'll run them like
|
||||
this: C:\Python23\python C:\Python23\Scripts\supybot-wizard
|
||||
|
||||
|
||||
DEVELOPERS:
|
||||
-----------
|
||||
We likewise have tons of developer documentation at
|
||||
http://supybot.com/ for your learning adventures. Have fun :)
|
11
README.md
Normal file
11
README.md
Normal file
@ -0,0 +1,11 @@
|
||||
<!-- @format -->
|
||||
|
||||
# Mikaela's fork of Limnoria.
|
||||
|
||||
There are mainly two branches. This one which you are looking at, gh-pages which
|
||||
is the source of <https://supybot.mikaela.info/>.
|
||||
|
||||
**testing** which will be synced with [ProgVal/Limnoria] when needed. It is used
|
||||
as base for my changes which will be pull requested.
|
||||
|
||||
[ProgVal/Limnoria]: https://github.com/ProgVal/Limnoria.git
|
371
RELNOTES
371
RELNOTES
@ -1,371 +0,0 @@
|
||||
Version 0.83.1
|
||||
|
||||
No incompatibilities, just fixing an important bug with plugin loading.
|
||||
|
||||
|
||||
Version 0.83.0
|
||||
|
||||
This far overdue release contains mostly bug-fixes.
|
||||
|
||||
Incompatibilities:
|
||||
Changed the prefixName keyword argument (which appears in various places
|
||||
in callbacks.py and the reply-related irc methods) to prefixNick.
|
||||
|
||||
|
||||
Version 0.83.0rc3
|
||||
|
||||
This release candidate contains mostly bug-fixes.
|
||||
|
||||
Incompatibilities:
|
||||
utils.changeFunctionName was moved to utils.python.changeFunctionName
|
||||
|
||||
|
||||
Version 0.83.0rc2
|
||||
|
||||
This release candidate contains a few bug-fixes and some plugins we
|
||||
forgot in the last RC. Otherwise, everything is compatible.
|
||||
|
||||
|
||||
Version 0.83.0rc1
|
||||
|
||||
There have been some fairly significant changes since our last release.
|
||||
This means that you should uninstall your previous version before
|
||||
installing this version.
|
||||
|
||||
First, plugins are now a directory of files rather than a single file.
|
||||
This makes it much easier for an individual plugin to supply any
|
||||
3rd-party modules it may depend on and resolves some bugs we had with
|
||||
reloading plugins. supybot-plugin-create (nee supybot-newplugin) has
|
||||
been updated to reflect this. A side effect of using a directory-based
|
||||
plugin is that @load/@reload are now case-sensitive. "@load foo" is not
|
||||
the same as "@load Foo".
|
||||
|
||||
As part of the conversion to the new plugin format, some plugins were
|
||||
broken up into more focused plugins. Also, not all of the plugins that
|
||||
we used to ship are part of this release. Some we moved to the
|
||||
supybot-plugins package and some others (which would be candidates for
|
||||
supybot-plugins) have yet to be converted to the new format.
|
||||
|
||||
Second, we've updated the scripts that ship with Supybot. As noted in
|
||||
the previous section, supybot-newplugin is now named
|
||||
supybot-plugin-create. We've also added the following scripts:
|
||||
|
||||
supybot-botchk - Handy script for starting the bot and keeping it
|
||||
running. Ideal for having cron automatically start the
|
||||
bot.
|
||||
supybot-plugin-doc - Generates documentation for the specified
|
||||
plugin(s). Currently, the documentation is
|
||||
generated using Structured TeXt so that it can
|
||||
easily be uploaded to our website.
|
||||
supybot-plugin-package - The beginning of a script to make a plugin
|
||||
package which can be uploaded to our website
|
||||
for general consumption.
|
||||
supybot-test - Runs a plugin's test suite.
|
||||
|
||||
Third, we've broken supybot.utils into focused sub-modules. There's no
|
||||
longer a supybot.fix module and we now have the following modules:
|
||||
|
||||
supybot.utils.file - utilities for dealing with files (e.g. the old
|
||||
supybot.utils.transactionalFile is now
|
||||
supybot.utils.file.AtomicFile)
|
||||
supybot.utils.iter - utilities for dealing with iterables (all, any,
|
||||
partition, groupBy, choice, etc)
|
||||
supybot.utils.gen - general purpose utilities which are imported into
|
||||
the supybot.utils namespace
|
||||
supybot.utils.net - utilities for dealing with the network
|
||||
supybot.utils.python - utilities for dealing with Python
|
||||
supybot.utils.seq - utilities for dealing with sequences
|
||||
supybot.utils.str - utilities for dealing with strings (including our
|
||||
new format() function)
|
||||
supybot.utils.structures - general purpose structures used in Supybot
|
||||
supybot.utils.web - utilities for dealing with the web (used to be
|
||||
supybot.webutils)
|
||||
|
||||
Fourth, we've added source-nested plugins (using the class
|
||||
callbacks.Commands). This allows you to group similar commands
|
||||
together. Some examples are:
|
||||
|
||||
Channel.{ban add,ban list,ban remove}
|
||||
User.{hostmask add,hostmask list,hostmask remove}
|
||||
|
||||
Fifth, we've removed the privmsgs module. All of the functionality
|
||||
that was offered in that module is now available by using commands.wrap.
|
||||
Use of this is documented at:
|
||||
http://supybot.com/documentation/help/tutorial/wrap
|
||||
|
||||
Sixth, we've renamed some plugin-related API changes. Some classes had
|
||||
their names changed. The old names are still available for
|
||||
backwards-compatibility.
|
||||
|
||||
callbacks.Privmsg -> callbacks.Plugin
|
||||
callbacks.PrivmsgCommandAndRegexp -> callbacks.PluginRegexp
|
||||
callbacks.IrcObjectProxy -> callbacks.NestedCommandsIrcProxy
|
||||
|
||||
callbacks.PrivmsgRegexp was removed since its functionality is covered
|
||||
by setting using PluginRegexp.
|
||||
|
||||
Also, the prototype for a plugin's __init__ method changed:
|
||||
|
||||
def __init__(self): -> def __init__(self, irc):
|
||||
|
||||
Remember to pass the irc object on when you call the parent class's
|
||||
__init__ method.
|
||||
|
||||
|
||||
Version 0.80.0
|
||||
|
||||
We *finally* hit 0.80.0! This release is completely compatible with
|
||||
the last release candidate.
|
||||
|
||||
An update to Babelfish may cause an error message to be displayed in
|
||||
the console when the bot is first run. The error message should be
|
||||
gone when the bot is restarted.
|
||||
|
||||
We also have a new community website at http://www.supybot.com/ where
|
||||
our users can submit their own plugins, view/download other people's
|
||||
plugins and discuss all things Supybot-related.
|
||||
|
||||
|
||||
Version 0.80.0rc3
|
||||
|
||||
Another bugfix release. This one was pretty important as it actually
|
||||
makes supybot.database.plugins.channelSpecific work properly.
|
||||
|
||||
|
||||
Version 0.80.0rc2
|
||||
|
||||
supybot.databases.plugins.channelSpecific.channel was renamed to
|
||||
supybot.databases.plugins.channelSpecific.link.
|
||||
|
||||
supybot.databases.plugins.channelSpecific.link.allow was added, which
|
||||
determines whether a channel will allow other channels to link to its
|
||||
database.
|
||||
|
||||
Infobot is no longer deprecated and the following changes were made to
|
||||
its config variables:
|
||||
supybot.plugins.Infobot.answerUnaddressedQuestions was renamed to
|
||||
supybot.plugins.Infobot.unaddressed.answerQuestions.
|
||||
supybot.plugins.Infobot.snarfUnaddressedDefinitions was renamed to
|
||||
supybot.plugins.Infobot.unaddressed.snarfDefinitions.
|
||||
supybot.plugins.Infobot.unaddressed.replyExistingFactoid was added to
|
||||
determine whether the bot will reply when someone attempts to create a
|
||||
duplicate factoid.
|
||||
|
||||
|
||||
Version 0.80.0pre6
|
||||
|
||||
Another bugfix release. No incompatibilities known. The only
|
||||
registry change is that supybot.databases.users.hash has been
|
||||
removed.
|
||||
|
||||
|
||||
Version 0.80.0pre5
|
||||
|
||||
Completely bugfix release. No incompatibilies known.
|
||||
|
||||
|
||||
Version 0.80.0pre4
|
||||
|
||||
Mainly a bug fix release. This will likely be the last release before
|
||||
0.80.0final, but we're gonna let it stew for a couple weeks to attempt
|
||||
to catch any lingering bugs.
|
||||
|
||||
ansycoreDrivers is now deprecated in favor of socketDrivers or
|
||||
twistedDrivers.
|
||||
|
||||
supybot.databases.plugins.channelSpecific.channel is now a channelValue
|
||||
so that you can link specific channels together (instead of all channels
|
||||
being linked together).
|
||||
|
||||
For those of you that use eval and/or exec, they have been removed from
|
||||
the Owner plugin and are now in sandbox/Debug.py (which you'll have to
|
||||
grab from CVS).
|
||||
|
||||
|
||||
Version 0.80.0pre3
|
||||
|
||||
The database format for the Note plugin has changed to a flatfile
|
||||
format; use tools/noteConvert.py to convert it to the new format.
|
||||
|
||||
Ditto that for the URL database.
|
||||
|
||||
FunDB is deprecated and will be removed at the next major release;
|
||||
use tools/fundbConvert.py to convert your old FunDB databases to Lart
|
||||
and Praise databases.
|
||||
|
||||
If you had turned off supybot.databases.plugins.channelSpecific, your
|
||||
non-channel-specific database files had gone directly into your data/
|
||||
directory. We had some problems with poor interactions between that
|
||||
configuration variable and channel capabilities, though, so we
|
||||
changed the implementation so that non-channel-specific databases are
|
||||
considered databases of a single (configurable) channel (defaulting
|
||||
to "#"). This will also help others who are converting from
|
||||
channel-specific to non-channel-specific databases, but for you
|
||||
who've already made the switch, you'll need to move your database
|
||||
files again, from data/ to data/# (or whatever channel you might
|
||||
change that variable to).
|
||||
|
||||
supybot.channels doesn't exist anymore; now the only list of channels
|
||||
to join is per-network, in supybot.networks.<network>.channels.
|
||||
|
||||
We weren't serializing supybot.replies.* properly in older versions.
|
||||
Now we are, but the old, improperly serialized versions won't work
|
||||
properly. Remove from your configuration file all variables
|
||||
beginning with "supybot.replies" before you start the bot.
|
||||
|
||||
The URL database has been changed again, but it will use a different
|
||||
filename so you shouldn't run into conflicts, just a newly-empty
|
||||
database.
|
||||
|
||||
We upgraded the SOAP stuff in others; you may do well to do a
|
||||
setup.py install --clean this time around.
|
||||
|
||||
|
||||
Version 0.80.0pre2
|
||||
|
||||
Many more bugs have been fixed. A few more plugins have been updated
|
||||
to use our new-style database abstraction. If it seems like your
|
||||
databases are suddenly empty, look for a new database file named
|
||||
Plugin.dbtype.db. We've also added a few more configuration variables.
|
||||
|
||||
|
||||
Version 0.80.0pre1
|
||||
|
||||
Tons of bugs fixed, many features and plugins added. Everything
|
||||
should be entirely compatible; many more configuration variables have
|
||||
been added.
|
||||
|
||||
|
||||
Version 0.79.9999
|
||||
|
||||
Some more bugs fixed, added a few features and a couple configuration
|
||||
variabless. This should hopefully be the last release before 0.80.0,
|
||||
which will finally bring us to pure Beta status.
|
||||
|
||||
|
||||
Version 0.79.999
|
||||
|
||||
Some bugs fixed, but the ones that were fixed were pretty big. This
|
||||
is, of course, completely compatible with the last release.
|
||||
|
||||
|
||||
Version 0.79.99
|
||||
|
||||
Many bugs fixed, thanks to the users who reported them. We're
|
||||
getting asymptotically closer to 0.80.0 -- maybe this'll be the last
|
||||
one, maybe we'll have to release an 0.79.999 -- either way, we're
|
||||
getting close :) Check out the ChangeLog for the fixes and a few new
|
||||
features.
|
||||
|
||||
|
||||
Version 0.79.9
|
||||
|
||||
We've changed so much stuff in this release that we've given up on
|
||||
users upgrading their configuration files for the new release. So
|
||||
do a clean install (python2.3 setup.py install --clean), run the
|
||||
wizard again, and kick some butt.
|
||||
|
||||
(It's rumored that you can save most of your old configuration by
|
||||
appending your new configuration at the end of your old configuration
|
||||
and running supybot with that new configuration file. This, of
|
||||
course, comes with no warranty or guarantee of utility -- try it if
|
||||
you want, but backup your original configuration file!)
|
||||
|
||||
|
||||
Version 0.77.2
|
||||
|
||||
This is a drop-in replacement for 0.77.1, with two exceptions. The
|
||||
configuration variable formerly known as
|
||||
"supybot.plugins.Services.password" is now known as
|
||||
"supybot.plugins.Services.NickServ.password", due to the fact that
|
||||
there might be different passwords for NickServ and ChanServ (and
|
||||
ChanServ passwords are per-channel, whereas NickServ passwords are
|
||||
global). If you're using the Services plugin, you'll need to make
|
||||
this change in order to continue identifying with services. The
|
||||
configuration variable formerly known as
|
||||
"supybot.plugins.Babelfish.disabledLanguages" is now known as
|
||||
"supybot.plugins.Babelfish.languages". The configuration variable now
|
||||
accepts the languages that *will* be translated as opposed to ones
|
||||
that are *not* translated.
|
||||
|
||||
Tests and the developer sandbox are not longer delivered with our
|
||||
release tarballs. If you're a developer and you want these, you
|
||||
should either check out CVS or download one of our weekly CVS
|
||||
snapshots, available at http://supybot.sourceforge.net/snapshots/ .
|
||||
|
||||
|
||||
Version 0.77.1
|
||||
|
||||
This is a drop-in replacement for 0.77.0 -- no incompatibilities, to
|
||||
out knowledge. Simply install over your old installation and restart
|
||||
your bot :)
|
||||
|
||||
|
||||
Version 0.77.0
|
||||
|
||||
Setup.py will automatically remove your old installations for you, no
|
||||
need to worry about that yourself.
|
||||
|
||||
Configuration has been *entirely* redone. Read the new
|
||||
GETTING_STARTED document to see how to work with configuration
|
||||
variables now. Your old botscripts from earlier versions *will not*
|
||||
work with the new configuration method. We'd appreciate it if you'd
|
||||
rerun the wizard in order for us to find any bugs that remain in it
|
||||
before we officially declare ourselves Beta. Note also that because
|
||||
of the new configuration method, the interface for plugins' configure
|
||||
function has changed: there are no longer any onStart or afterConnect
|
||||
arguments, so all configuration should be performed via the registry.
|
||||
|
||||
Channel capabilities have been changed; rather than being
|
||||
#channel.capability, they're now #channel,capability. It's a bit
|
||||
uglier, we know, but dots can be valid in channel names, and we
|
||||
needed the dot for handling plugin.command capabilities.
|
||||
tools/ircdbConvert.py should update this for you.
|
||||
|
||||
The on-disk format of the user/channel databases has changed to be far
|
||||
more readable. A conversion utility is included, as mentioned before:
|
||||
tools/ircdbConvert.py. Run this with no arguments to see the
|
||||
directions for using it.
|
||||
|
||||
Uh, we were just kidding about the upgrade script in 0.76.0 :) It'll
|
||||
be a little while longer. We do have several little upgrade scripts,
|
||||
though.
|
||||
|
||||
|
||||
Version 0.76.1
|
||||
|
||||
Almost entirely bugfixes, just some minor (and some less minor) bugs
|
||||
that need to get in before we really start hacking on the next
|
||||
version. Should be *entirely* compatible with 0.76.0.
|
||||
|
||||
|
||||
Version 0.76.0
|
||||
|
||||
Major bugfix release. A great number of bugs fixed. This is the last
|
||||
release without an upgrade script.
|
||||
|
||||
The only hiccup in the upgrade from 0.75.0 should be that you'll need
|
||||
to update your botscript to reflect the removal of the debug module.
|
||||
We'd rather you use supybot-wizard to generate a new botscript, of
|
||||
course, but if you insist on modifying your existing botscript, take a
|
||||
look at
|
||||
<http://cvs.sourceforge.net/viewcvs.py/supybot/supybot/src/template.py?r1=1.20&r2=1.21>
|
||||
to see what you need to do.
|
||||
|
||||
|
||||
Version 0.75.0
|
||||
|
||||
Don't forget to reinstall (i.e., run "python setup.py install" as
|
||||
root). Sometimes it even does good to remove the old installation;
|
||||
$PYTHON/site-packages/supybot can be removed with no problems
|
||||
whatsoever.
|
||||
|
||||
You will need to re-run supybot-wizard and generate a new botscript.
|
||||
|
||||
The Infobot plugin has been removed from this release; it's not ready
|
||||
for prime time. If you're interested in getting it running (i.e., you
|
||||
want full Infobot compatibility and aren't satisfied with either
|
||||
MoobotFactoids or Factoids) then swing over to #supybot and we can
|
||||
discuss the tests. We simply don't know enough about Infobot to make
|
||||
sure our Infobot plugin is an exact replica, and need someone's help
|
||||
with making the changes necessary for that.
|
71
Relaybot.markdown
Normal file
71
Relaybot.markdown
Normal file
@ -0,0 +1,71 @@
|
||||
---
|
||||
layout: page
|
||||
title: Ignoring RelayBot
|
||||
permalink: /Relaybot.html
|
||||
---
|
||||
|
||||
<!-- @format -->
|
||||
|
||||
RelayBot is the bot which relays between #supybot,#limnoria at a couple of
|
||||
networks (TODO/FIXME, which ones?). It is currently using the
|
||||
[LinkRelay](https://github.com/ProgVal/Supybot-plugins/tree/master/LinkRelay)
|
||||
plugin to do this.
|
||||
|
||||
It's sometimes considered as annoyance as it has lately mostly spammed with join
|
||||
(part messages aren't working, because of a bug (2014-06-23)) messages of people
|
||||
who usually say nothing and this is why this page is here to tell how to ignore
|
||||
it on various client.
|
||||
|
||||
We(who? I?) encourage you to ignore only notices from RelayBot instead of
|
||||
everything as there are people whom should be heard at OFTC (mainly main Supybot
|
||||
developer). (TODO/FIXME: is this the case in 2021?)
|
||||
|
||||
Related links:
|
||||
|
||||
- [LinkRelay plugin](https://github.com/ProgVal/Supybot-plugins/tree/master/LinkRelay)
|
||||
- [Feature request for smart filtering of joins/quits/parts](https://github.com/ProgVal/Supybot-plugins/issues/66)
|
||||
- [Feature request for RELAYMSG for more native look&feel](https://github.com/ProgVal/Supybot-plugins/issues/338)
|
||||
|
||||
Hostmask of RelayBot on Libera.Chat 2021-06-06:
|
||||
|
||||
- `RelayBot!~limnoria@helium.progval.net`
|
||||
- This is absolute hostmask, also known as NUH (`nick!user@host`)
|
||||
- `RelayBot*!*@helium.progval.net`
|
||||
- This is recommended hostmask as it matches RelayBot even if it cannot use
|
||||
it's primary nickname or networks cannot connect to it's identd.
|
||||
|
||||
## HexChat
|
||||
|
||||
From the "Window" menu you can find "Ignore list". Click "Add" and add one of
|
||||
the hostmasks mentioned above (the lower is recommended).
|
||||
|
||||
Uncheck the other checkboxes than "Notice" and you can close the window and you
|
||||
won't see spamming.
|
||||
|
||||
## KVIRC
|
||||
|
||||
I am not primarily KVIRC user and I cannot say anything else than right click
|
||||
RelayBot and select something that matches only RelayBot.
|
||||
|
||||
**WARNING: KVIRC makes it very easy to also ignore pinkieval which you don't
|
||||
want to do as they are author of Limnoria and help people often!**
|
||||
|
||||
## Linkinus
|
||||
|
||||
According to another person, there is a GUI where you can easily ignore notices
|
||||
from specific hostmask.
|
||||
|
||||
## WeeChat
|
||||
|
||||
`/filter add relaybotnotices * irc_notice+nick_RelayBot *`
|
||||
|
||||
This creates a new filter with the name "relaybotnotices" which filters all
|
||||
notices from the nickname "RelayBot".
|
||||
|
||||
---
|
||||
|
||||
This page is very likely missing many IRC clients. Could you
|
||||
[open an issue](https://github.com/mikaela/limnoria/issues) about how to do this
|
||||
with your IRC client that isn't mentioned here?
|
||||
|
||||
---
|
145
Supybot.markdown
Normal file
145
Supybot.markdown
Normal file
@ -0,0 +1,145 @@
|
||||
---
|
||||
layout: page
|
||||
title: Security issues
|
||||
permalink: /Supybot.html
|
||||
---
|
||||
|
||||
<!-- @format -->
|
||||
|
||||
Supybot git repository was declared dead on 2018-05-10 and archived on GitHub.
|
||||
[v0.84.0 was the last release at that time](https://github.com/Supybot/Supybot/releases/tag/v0.84.0).
|
||||
0.83.4.1 used to be a very common release available through several Linux
|
||||
distributions for years and thus I made this page, which I guess is now
|
||||
available more of for historical reasons.
|
||||
|
||||
**_WARNING: most of the content originates from 2014!_**
|
||||
|
||||
## The issues of 0.83.4.1.
|
||||
|
||||
### 1. Anyone can crash it and computer where it's running on
|
||||
|
||||
And this is very easy. Just run the command
|
||||
|
||||
`!misc last --regexp m/(.*\w){512}/`
|
||||
|
||||
where ! is the prefix character.
|
||||
|
||||
Misc is loaded by default and cannot be unloaded without modifying the config.
|
||||
|
||||
- [Limnoria issue #157](https://github.com/ProgVal/Limnoria/issues/157)
|
||||
- Fixing commits:
|
||||
[3526d5d](https://github.com/ProgVal/Limnoria/commit/3526d5dabf587457a43af8bee8d4db21986e8222)
|
||||
&
|
||||
[e11dc28](https://github.com/ProgVal/Limnoria/commit/e11dc28025de877b1b6cf059013eef88337b7e44)
|
||||
- [Ubuntu bug #996947](https://bugs.launchpad.net/ubuntu/+source/supybot/+bug/996947)
|
||||
- [Debian bug #672214](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=672214)
|
||||
|
||||
### 2. The previous wasn't the only way to do this
|
||||
|
||||
Everyone can also make the bot count an equation, which brings it and the host
|
||||
computer down.
|
||||
|
||||
For example:
|
||||
|
||||
`!math calc factorial(999999)`
|
||||
|
||||
This requires Math plugin which comes with Supybot, but isn't load by default.
|
||||
|
||||
- [Limnoria issue #354](https://github.com/ProgVal/Limnoria/issues/354)
|
||||
- Fixing commit:
|
||||
[695078e](https://github.com/ProgVal/Limnoria/commit/695078edeb91e5ff1eec728fedf0e0c27b55c505)
|
||||
- [Ubuntu bug #996950](https://bugs.launchpad.net/ubuntu/+source/supybot/+bug/996950)
|
||||
- [Debian bug 672215](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=672215)
|
||||
|
||||
### 3. Anyone can access network services via the bot.
|
||||
|
||||
I don't have example command for this, but it happens by nesting "format cut"
|
||||
and "misc tell".
|
||||
|
||||
What does this mean? Anyone can tell the bot to ghost someone else on same
|
||||
account, take over a channel by telling the bot to give flags (if it has correct
|
||||
flags), change password of the account and everything else what you do with
|
||||
network services.
|
||||
|
||||
- _This was only reported at IRC and I am unable to find issue report or fixing
|
||||
commit. ~~Mikaela on 2015-01-04._
|
||||
|
||||
### 4. Web page with special characters in \<title\> can be used to send DCC/CTCP commands.
|
||||
|
||||
This doesn't mean only things like CTCP actions (also known as /me), but known
|
||||
problems with old routers ( `FF ? DCC SEND “ff???f??????????????” 0 0 0` ) which
|
||||
make them reconnect to the internet.
|
||||
|
||||
Usage:
|
||||
|
||||
- `!web title <malicious.page.here>`
|
||||
- `!web fetch <malicious.page.here>`
|
||||
|
||||
_This was only reported at IRC and I am unable to find issue report or fixing
|
||||
commit. ~~Mikaela on 2015-01-04._
|
||||
|
||||
### 5. Web Titlte/Fetch can be used for DoS
|
||||
|
||||
They are vulnerable to queries to servers which have custom headers which can
|
||||
lead to DoS.
|
||||
|
||||
_This was only reported at IRC and I am unable to find issue report or fixing
|
||||
commit. ~~Mikaela on 2015-01-04._
|
||||
|
||||
### 6. QuoteGrabs grab command also works in PM
|
||||
|
||||
and can grab private content such as `user register` or `user identify` or with
|
||||
the case of owner possibly NickServ passwords and others not so nice things.
|
||||
|
||||
- _It appears this issue was only reported at IRC._
|
||||
- Fixing commit:
|
||||
[a3346343679f3bdf8c77d9efb5a2097e215d51df](https://github.com/ProgVal/Limnoria/commit/a3346343679f3bdf8c77d9efb5a2097e215d51df)
|
||||
|
||||
### Are these issues publicly known?
|
||||
|
||||
**Of course they are.** Issue reports are below the actual issues.
|
||||
|
||||
The first issue has been also used to take down some of
|
||||
[Ubuntu IRC bots](https://wiki.ubuntu.com/IRC/Bots) several times. At least
|
||||
UbotX (I don't remember the number) and meetingology.
|
||||
|
||||
Some of these issues are fixed in git repository, but most people aren't using
|
||||
it. If you wish to start using it, please scroll down to installation
|
||||
instructions lower this page even though [Limnoria] and [gribble] are more
|
||||
recommended.
|
||||
|
||||
### How to avoid them?
|
||||
|
||||
You can add anticapability for these commands using `owner defaultcapability`,
|
||||
but that is only a temporary solution. There can also be other issues.
|
||||
|
||||
There are also two active Supybot forks, known as [Limnoria] and [Gribble],
|
||||
which are actively developed and have fixed these issues. If you want permanent
|
||||
solution, you should install either of them.
|
||||
|
||||
## Possibly interesting links
|
||||
|
||||
- [Comparsion of commit activity between Limnoria, Gribble and Supybot](https://www.openhub.net/p/compare?project_0=Limnoria&project_1=Gribble%3A+Support+Bottie&project_2=Supybot).
|
||||
- [Gribble's modifications to stock Supybot](https://sourceforge.net/p/gribble/wiki/Gribble_Project_Git_Repository/)
|
||||
- [Limnoria's modifications to Gribble.](https://github.com/ProgVal/Limnoria/wiki/LGC)
|
||||
- Features of Gribble are fully merged to Limnoria.
|
||||
|
||||
Your current botname.conf is **100% compatible with forks**.
|
||||
|
||||
[Join Supybot channels on LiberaChat!](ircs://irc.libera.chat:6697/#supybot,#gribble,#limnoria)
|
||||
|
||||
[Limnoria]: https://github.com/ProgVal/Limnoria
|
||||
[Gribble]: http://github.com/nanotube/supybot_fixes
|
||||
|
||||
## Installing forks
|
||||
|
||||
_This section has been removed in order to not duplicate
|
||||
[Limnoria's documentation.](http://doc.supybot.aperio.fr/en/latest/use/install.html)_
|
||||
|
||||
---
|
||||
|
||||
Do you know issue that isn't mentioned here? If it's not already reported,
|
||||
please report it
|
||||
on [Limnoria's issue tracker.](https://github.com/ProgVal/Limnoria/issues) If
|
||||
it's known, but just not reported here,
|
||||
[please feel free to add it.](https://github.com/Mikaela/limnoria/edit/gh-pages/Supybot.markdown)
|
38
_config.yml
Normal file
38
_config.yml
Normal file
@ -0,0 +1,38 @@
|
||||
# @format
|
||||
|
||||
theme: minima
|
||||
title: Mikaela's Supybot site
|
||||
tagline: Things official documentation may not tell you
|
||||
author:
|
||||
name: "Aminda Suomalainen"
|
||||
url: "https://aminda.eu/"
|
||||
description: > # this means to ignore newlines until "baseurl:"
|
||||
Mikaela's Supybot site where nowadays the only content is security issues of
|
||||
stock Supybot.
|
||||
baseurl: "" # the subpath of your site, e.g. /blog/
|
||||
url: "https://supybot.mikaela.info/" # the base hostname & protocol for your site
|
||||
github_username: Mikaela
|
||||
lang: en
|
||||
timezone: Etc/UTC
|
||||
encoding: utf-8
|
||||
plugins:
|
||||
# - jekyll-mentions
|
||||
- jekyll-redirect-from
|
||||
- jekyll-sitemap
|
||||
- jekyll-seo-tag
|
||||
sitemap:
|
||||
file: "/sitemap.xml"
|
||||
include: [robots.txt]
|
||||
robots: nofollow, noai
|
||||
icon: https://github.com/ProgVal/Supybot-website/raw/master/static/logo.png
|
||||
markdown: kramdown
|
||||
kramdown:
|
||||
parse_block_html: true
|
||||
#webmaster_verifications:
|
||||
#google:
|
||||
#bing:
|
||||
defaults:
|
||||
- scope:
|
||||
path: "*"
|
||||
values:
|
||||
image: https://github.com/ProgVal/Supybot-website/raw/master/static/logo.png
|
32
_includes/footer.html
Normal file
32
_includes/footer.html
Normal file
@ -0,0 +1,32 @@
|
||||
<footer class="site-footer h-card">
|
||||
<data class="u-url" href="{{ "/" | relative_url }}"></data>
|
||||
|
||||
<div class="wrapper">
|
||||
|
||||
<h2 class="footer-heading">{{ site.title | escape }}</h2>
|
||||
|
||||
<div class="footer-col-wrapper">
|
||||
<div class="footer-col footer-col-1">
|
||||
<ul class="contact-list">
|
||||
<li class="p-name">
|
||||
<a rel="me prefetch" href="{{ site.author.url }}">{{ site.author.name }}</a><br>
|
||||
{{ site.title | escape }}
|
||||
</li>
|
||||
{%- if site.email -%}
|
||||
<li><a class="u-email" href="mailto:{{ site.email }}">{{ site.email }}</a></li>
|
||||
{%- endif -%}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="footer-col footer-col-2">
|
||||
{%- include social.html -%}
|
||||
</div>
|
||||
|
||||
<div class="footer-col footer-col-3">
|
||||
<p>{{- site.description | escape -}}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</footer>
|
15
_includes/head.html
Normal file
15
_includes/head.html
Normal file
@ -0,0 +1,15 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<!---->
|
||||
{%- seo -%}
|
||||
<!---->
|
||||
<meta name="robots" content="{% if page.robots %}{{ page.robots }} {% else %}{{ site.robots }} {% endif %}">
|
||||
<link rel="icon" href="https://github.com/ProgVal/Supybot-website/raw/master/static/logo.png">
|
||||
<meta name="color-scheme" content="dark light">
|
||||
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="#ffb700">
|
||||
<meta name="theme-color" media="(prefers-color-scheme: light)" content="#fdfdfd">
|
||||
<link rel="stylesheet" href="{{ "/assets/main.css" | prepend: site.baseurl }}">
|
||||
<link rel="alternate" type="application/rss+xml" title="{{ site.title }}" href="{{ "/feed.xml" | prepend: site.baseurl | prepend: site.url }}">
|
||||
</head>
|
210
_sass/_base.scss
Normal file
210
_sass/_base.scss
Normal file
@ -0,0 +1,210 @@
|
||||
:root {
|
||||
color-scheme: dark light;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset some basic elements
|
||||
*/
|
||||
body, h1, h2, h3, h4, h5, h6,
|
||||
p, blockquote, pre, hr,
|
||||
dl, dd, ol, ul, figure {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Basic styling
|
||||
*/
|
||||
body {
|
||||
font-family: $base-font-family;
|
||||
font-size: $base-font-size;
|
||||
line-height: $base-line-height;
|
||||
font-weight: 300;
|
||||
color: $text-color;
|
||||
background-color: $background-color;
|
||||
-webkit-text-size-adjust: 100%;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Set `margin-bottom` to maintain vertical rhythm
|
||||
*/
|
||||
h1, h2, h3, h4, h5, h6,
|
||||
p, blockquote, pre,
|
||||
ul, ol, dl, figure,
|
||||
%vertical-rhythm {
|
||||
margin-bottom: $spacing-unit / 2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Images
|
||||
*/
|
||||
img {
|
||||
max-width: 100%;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Figures
|
||||
*/
|
||||
figure > img {
|
||||
display: block;
|
||||
}
|
||||
|
||||
figcaption {
|
||||
font-size: $small-font-size;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Lists
|
||||
*/
|
||||
ul, ol {
|
||||
margin-left: $spacing-unit;
|
||||
}
|
||||
|
||||
li {
|
||||
> ul,
|
||||
> ol {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Headings
|
||||
*/
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Links
|
||||
*/
|
||||
a {
|
||||
color: $brand-color;
|
||||
//text-decoration: none;
|
||||
text-decoration: underline;
|
||||
|
||||
&:visited {
|
||||
//color: darken($brand-color, 15%);
|
||||
}
|
||||
|
||||
&:hover {
|
||||
color: $text-color;
|
||||
//text-decoration: underline;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Blockquotes
|
||||
*/
|
||||
blockquote {
|
||||
color: $grey-color;
|
||||
border-left: 4px solid $grey-color-light;
|
||||
padding-left: $spacing-unit / 2;
|
||||
font-size: 18px;
|
||||
letter-spacing: -1px;
|
||||
font-style: italic;
|
||||
|
||||
> :last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Code formatting
|
||||
*/
|
||||
pre,
|
||||
code {
|
||||
font-family: $monospace-font-family;
|
||||
font-size: 15px;
|
||||
border: 1px solid; //$grey-color-light;
|
||||
border-radius: 3px;
|
||||
background-color: revert; //#eef;
|
||||
}
|
||||
|
||||
code {
|
||||
padding: 1px 5px;
|
||||
}
|
||||
|
||||
pre {
|
||||
padding: 8px 12px;
|
||||
overflow-x: scroll;
|
||||
|
||||
> code {
|
||||
border: 0;
|
||||
padding-right: 0;
|
||||
padding-left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Wrapper
|
||||
*/
|
||||
.wrapper {
|
||||
max-width: -webkit-calc(#{$content-width} - (#{$spacing-unit} * 2));
|
||||
max-width: calc(#{$content-width} - (#{$spacing-unit} * 2));
|
||||
margin-right: auto;
|
||||
margin-left: auto;
|
||||
padding-right: $spacing-unit;
|
||||
padding-left: $spacing-unit;
|
||||
@extend %clearfix;
|
||||
|
||||
@include media-query($on-laptop) {
|
||||
max-width: -webkit-calc(#{$content-width} - (#{$spacing-unit}));
|
||||
max-width: calc(#{$content-width} - (#{$spacing-unit}));
|
||||
padding-right: $spacing-unit / 2;
|
||||
padding-left: $spacing-unit / 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Clearfix
|
||||
*/
|
||||
%clearfix {
|
||||
|
||||
&:after {
|
||||
content: "";
|
||||
display: table;
|
||||
clear: both;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Icons
|
||||
*/
|
||||
.icon {
|
||||
|
||||
> svg {
|
||||
display: inline-block;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
vertical-align: middle;
|
||||
|
||||
path {
|
||||
fill: $grey-color;
|
||||
}
|
||||
}
|
||||
}
|
236
_sass/_layout.scss
Normal file
236
_sass/_layout.scss
Normal file
@ -0,0 +1,236 @@
|
||||
/**
|
||||
* Site header
|
||||
*/
|
||||
.site-header {
|
||||
border-top: 5px solid $grey-color-dark;
|
||||
border-bottom: 1px solid $grey-color-light;
|
||||
min-height: 56px;
|
||||
|
||||
// Positioning context for the mobile navigation icon
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.site-title {
|
||||
font-size: 26px;
|
||||
line-height: 56px;
|
||||
letter-spacing: -1px;
|
||||
margin-bottom: 0;
|
||||
float: left;
|
||||
|
||||
&,
|
||||
&:visited {
|
||||
color: $grey-color-dark;
|
||||
}
|
||||
}
|
||||
|
||||
.site-nav {
|
||||
float: right;
|
||||
line-height: 56px;
|
||||
|
||||
.menu-icon {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.page-link {
|
||||
color: $text-color;
|
||||
line-height: $base-line-height;
|
||||
|
||||
// Gaps between nav items, but not on the first one
|
||||
&:not(:first-child) {
|
||||
margin-left: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
@include media-query($on-palm) {
|
||||
position: absolute;
|
||||
top: 9px;
|
||||
right: 30px;
|
||||
background-color: $background-color;
|
||||
border: 1px solid $grey-color-light;
|
||||
border-radius: 5px;
|
||||
text-align: right;
|
||||
|
||||
.menu-icon {
|
||||
display: block;
|
||||
float: right;
|
||||
width: 36px;
|
||||
height: 26px;
|
||||
line-height: 0;
|
||||
padding-top: 10px;
|
||||
text-align: center;
|
||||
|
||||
> svg {
|
||||
width: 18px;
|
||||
height: 15px;
|
||||
|
||||
path {
|
||||
fill: $grey-color-dark;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.trigger {
|
||||
clear: both;
|
||||
display: none;
|
||||
}
|
||||
|
||||
&:hover .trigger {
|
||||
display: block;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
|
||||
.page-link {
|
||||
display: block;
|
||||
padding: 5px 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Site footer
|
||||
*/
|
||||
.site-footer {
|
||||
border-top: 1px solid $grey-color-light;
|
||||
padding: $spacing-unit 0;
|
||||
}
|
||||
|
||||
.footer-heading {
|
||||
font-size: 18px;
|
||||
margin-bottom: $spacing-unit / 2;
|
||||
}
|
||||
|
||||
.contact-list,
|
||||
.social-media-list {
|
||||
list-style: none;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.footer-col-wrapper {
|
||||
font-size: 15px;
|
||||
color: $grey-color;
|
||||
margin-left: -$spacing-unit / 2;
|
||||
@extend %clearfix;
|
||||
}
|
||||
|
||||
.footer-col {
|
||||
float: left;
|
||||
margin-bottom: $spacing-unit / 2;
|
||||
padding-left: $spacing-unit / 2;
|
||||
}
|
||||
|
||||
.footer-col-1 {
|
||||
width: -webkit-calc(35% - (#{$spacing-unit} / 2));
|
||||
width: calc(35% - (#{$spacing-unit} / 2));
|
||||
}
|
||||
|
||||
.footer-col-2 {
|
||||
width: -webkit-calc(20% - (#{$spacing-unit} / 2));
|
||||
width: calc(20% - (#{$spacing-unit} / 2));
|
||||
}
|
||||
|
||||
.footer-col-3 {
|
||||
width: -webkit-calc(45% - (#{$spacing-unit} / 2));
|
||||
width: calc(45% - (#{$spacing-unit} / 2));
|
||||
}
|
||||
|
||||
@include media-query($on-laptop) {
|
||||
.footer-col-1,
|
||||
.footer-col-2 {
|
||||
width: -webkit-calc(50% - (#{$spacing-unit} / 2));
|
||||
width: calc(50% - (#{$spacing-unit} / 2));
|
||||
}
|
||||
|
||||
.footer-col-3 {
|
||||
width: -webkit-calc(100% - (#{$spacing-unit} / 2));
|
||||
width: calc(100% - (#{$spacing-unit} / 2));
|
||||
}
|
||||
}
|
||||
|
||||
@include media-query($on-palm) {
|
||||
.footer-col {
|
||||
float: none;
|
||||
width: -webkit-calc(100% - (#{$spacing-unit} / 2));
|
||||
width: calc(100% - (#{$spacing-unit} / 2));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Page content
|
||||
*/
|
||||
.page-content {
|
||||
padding: $spacing-unit 0;
|
||||
}
|
||||
|
||||
.page-heading {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.post-list {
|
||||
margin-left: 0;
|
||||
list-style: none;
|
||||
|
||||
> li {
|
||||
margin-bottom: $spacing-unit;
|
||||
}
|
||||
}
|
||||
|
||||
.post-meta {
|
||||
font-size: $small-font-size;
|
||||
color: $grey-color;
|
||||
}
|
||||
|
||||
.post-link {
|
||||
display: block;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Posts
|
||||
*/
|
||||
.post-header {
|
||||
margin-bottom: $spacing-unit;
|
||||
}
|
||||
|
||||
.post-title {
|
||||
font-size: 42px;
|
||||
letter-spacing: -1px;
|
||||
line-height: 1;
|
||||
|
||||
@include media-query($on-laptop) {
|
||||
font-size: 36px;
|
||||
}
|
||||
}
|
||||
|
||||
.post-content {
|
||||
margin-bottom: $spacing-unit;
|
||||
|
||||
h2 {
|
||||
font-size: 32px;
|
||||
|
||||
@include media-query($on-laptop) {
|
||||
font-size: 28px;
|
||||
}
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 26px;
|
||||
|
||||
@include media-query($on-laptop) {
|
||||
font-size: 22px;
|
||||
}
|
||||
}
|
||||
|
||||
h4 {
|
||||
font-size: 20px;
|
||||
|
||||
@include media-query($on-laptop) {
|
||||
font-size: 18px;
|
||||
}
|
||||
}
|
||||
}
|
67
_sass/_syntax-highlighting.scss
Normal file
67
_sass/_syntax-highlighting.scss
Normal file
@ -0,0 +1,67 @@
|
||||
/**
|
||||
* Syntax highlighting styles
|
||||
*/
|
||||
.highlight {
|
||||
background: #fff;
|
||||
@extend %vertical-rhythm;
|
||||
|
||||
.c { color: #998; font-style: italic } // Comment
|
||||
.err { color: #a61717; background-color: #e3d2d2 } // Error
|
||||
.k { font-weight: bold } // Keyword
|
||||
.o { font-weight: bold } // Operator
|
||||
.cm { color: #998; font-style: italic } // Comment.Multiline
|
||||
.cp { color: #999; font-weight: bold } // Comment.Preproc
|
||||
.c1 { color: #998; font-style: italic } // Comment.Single
|
||||
.cs { color: #999; font-weight: bold; font-style: italic } // Comment.Special
|
||||
.gd { color: #000; background-color: #fdd } // Generic.Deleted
|
||||
.gd .x { color: #000; background-color: #faa } // Generic.Deleted.Specific
|
||||
.ge { font-style: italic } // Generic.Emph
|
||||
.gr { color: #a00 } // Generic.Error
|
||||
.gh { color: #999 } // Generic.Heading
|
||||
.gi { color: #000; background-color: #dfd } // Generic.Inserted
|
||||
.gi .x { color: #000; background-color: #afa } // Generic.Inserted.Specific
|
||||
.go { color: #888 } // Generic.Output
|
||||
.gp { color: #555 } // Generic.Prompt
|
||||
.gs { font-weight: bold } // Generic.Strong
|
||||
.gu { color: #aaa } // Generic.Subheading
|
||||
.gt { color: #a00 } // Generic.Traceback
|
||||
.kc { font-weight: bold } // Keyword.Constant
|
||||
.kd { font-weight: bold } // Keyword.Declaration
|
||||
.kp { font-weight: bold } // Keyword.Pseudo
|
||||
.kr { font-weight: bold } // Keyword.Reserved
|
||||
.kt { color: #458; font-weight: bold } // Keyword.Type
|
||||
.m { color: #099 } // Literal.Number
|
||||
.s { color: #d14 } // Literal.String
|
||||
.na { color: #008080 } // Name.Attribute
|
||||
.nb { color: #0086B3 } // Name.Builtin
|
||||
.nc { color: #458; font-weight: bold } // Name.Class
|
||||
.no { color: #008080 } // Name.Constant
|
||||
.ni { color: #800080 } // Name.Entity
|
||||
.ne { color: #900; font-weight: bold } // Name.Exception
|
||||
.nf { color: #900; font-weight: bold } // Name.Function
|
||||
.nn { color: #555 } // Name.Namespace
|
||||
.nt { color: #000080 } // Name.Tag
|
||||
.nv { color: #008080 } // Name.Variable
|
||||
.ow { font-weight: bold } // Operator.Word
|
||||
.w { color: #bbb } // Text.Whitespace
|
||||
.mf { color: #099 } // Literal.Number.Float
|
||||
.mh { color: #099 } // Literal.Number.Hex
|
||||
.mi { color: #099 } // Literal.Number.Integer
|
||||
.mo { color: #099 } // Literal.Number.Oct
|
||||
.sb { color: #d14 } // Literal.String.Backtick
|
||||
.sc { color: #d14 } // Literal.String.Char
|
||||
.sd { color: #d14 } // Literal.String.Doc
|
||||
.s2 { color: #d14 } // Literal.String.Double
|
||||
.se { color: #d14 } // Literal.String.Escape
|
||||
.sh { color: #d14 } // Literal.String.Heredoc
|
||||
.si { color: #d14 } // Literal.String.Interpol
|
||||
.sx { color: #d14 } // Literal.String.Other
|
||||
.sr { color: #009926 } // Literal.String.Regex
|
||||
.s1 { color: #d14 } // Literal.String.Single
|
||||
.ss { color: #990073 } // Literal.String.Symbol
|
||||
.bp { color: #999 } // Name.Builtin.Pseudo
|
||||
.vc { color: #008080 } // Name.Variable.Class
|
||||
.vg { color: #008080 } // Name.Variable.Global
|
||||
.vi { color: #008080 } // Name.Variable.Instance
|
||||
.il { color: #099 } // Literal.Number.Integer.Long
|
||||
}
|
145
assets/main.scss
Normal file
145
assets/main.scss
Normal file
@ -0,0 +1,145 @@
|
||||
---
|
||||
# front-matter
|
||||
---
|
||||
|
||||
@charset "utf-8";
|
||||
|
||||
// Font specifications. I keep changing my mind on what are the most pleasant
|
||||
// fonts to my eyes, so I won't bother commenting them here.'
|
||||
$serif-font-family:
|
||||
ui-serif, "Roboto Serif", "Noto Serif", Tinos, serif, "Noto Emoji",
|
||||
"Noto Color Emoji", "Segoe UI Emoji", emoji;
|
||||
$sans-serif-font-family:
|
||||
"Inclusive Sans", ui-sans-serif, "Roboto Flex", "Segoe UI Variable", Roboto,
|
||||
"Noto Sans", Arimo, sans-serif, "Noto Emoji", "Noto Color Emoji",
|
||||
"Segoe UI Emoji", emoji;
|
||||
$monospace-font-family:
|
||||
"Comic Shanns Mono", ui-monospace, "Roboto Mono", "Segoe UI Mono",
|
||||
"Noto Mono", Cousine, monospace, "Noto Emoji", "Noto Color Emoji",
|
||||
"Segoe UI Emoji", emoji;
|
||||
// Must be in the end under threat of undefined variable error.
|
||||
$base-font-family: $sans-serif-font-family;
|
||||
|
||||
@font-face {
|
||||
font-family: "Inclusive Sans";
|
||||
src: url("https://raw.githubusercontent.com/LivKing/Inclusive-Sans/refs/heads/main/fonts/webfonts/InclusiveSans[wght].woff2")
|
||||
format("woff2");
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
@font-face {
|
||||
font-family: "Inclusive Sans Italic";
|
||||
src: url("https://raw.githubusercontent.com/LivKing/Inclusive-Sans/refs/heads/main/fonts/webfonts/InclusiveSans-Italic[wght].woff2")
|
||||
format("woff2");
|
||||
font-weight: normal;
|
||||
font-style: italic;
|
||||
}
|
||||
@font-face {
|
||||
font-family: "Comic Shanns Mono";
|
||||
src: url("https://raw.githubusercontent.com/jesusmgg/comic-shanns-mono/refs/heads/master/fonts/ComicShannsMono-Regular.otf")
|
||||
format("opentype");
|
||||
}
|
||||
|
||||
@import "{{ site.theme }}";
|
||||
|
||||
:root {
|
||||
color-scheme: dark light !important;
|
||||
}
|
||||
|
||||
* {
|
||||
// box-sizing: border-box !important;
|
||||
color: revert !important;
|
||||
background-color: revert !important;
|
||||
//margin: auto !important;
|
||||
// line-height: 1.2 !important;
|
||||
// A4 paper
|
||||
//max-width: 210mm !important;
|
||||
font-size: revert;
|
||||
//padding: auto !important;
|
||||
overflow-wrap: break-word !important;
|
||||
hyphens: auto !important;
|
||||
// Experimental trick to make all emojis text if supported.
|
||||
//font-variant-emoji: text;
|
||||
/* WCAG minimum suggestions */
|
||||
margin-bottom: 2 !important;
|
||||
line-height: 1.5 !important;
|
||||
letter-spacing: 0.12 !important;
|
||||
word-spacing: 0.16 !important;
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: underline !important;
|
||||
}
|
||||
|
||||
a.site-title {
|
||||
font-family: $serif-font-family;
|
||||
}
|
||||
|
||||
// Monospace preferred for code
|
||||
code,
|
||||
pre {
|
||||
font-family: $monospace-font-family !important;
|
||||
}
|
||||
|
||||
// So it will not look bigger than normal text
|
||||
code {
|
||||
font-size: 0.8em !important;
|
||||
}
|
||||
|
||||
// Sans-Serif for headings to constrast with aminda.eu
|
||||
// h2,
|
||||
// h3,
|
||||
// h4,
|
||||
// h5,
|
||||
// h6 {
|
||||
// font-family: $sans-serif-font-family !important;
|
||||
// }
|
||||
|
||||
h2.footer-heading {
|
||||
font-family: $sans-serif-font-family !important;
|
||||
}
|
||||
|
||||
// The introduction on top
|
||||
#bio {
|
||||
text-align: center;
|
||||
font-style: italic;
|
||||
font-family: ui-cursive, $sans-serif-font-family;
|
||||
}
|
||||
|
||||
img {
|
||||
border-radius: 50% !important;
|
||||
display: block;
|
||||
margin-left: auto !important;
|
||||
margin-right: auto !important;
|
||||
@media (min-width: 395px) {
|
||||
display: float !important;
|
||||
float: right !important;
|
||||
}
|
||||
}
|
||||
|
||||
ul.linklist {
|
||||
list-style: none inside;
|
||||
font-family: $monospace-font-family;
|
||||
//font-variant: small-caps;
|
||||
}
|
||||
|
||||
// Customize the dark theme to be more me
|
||||
@media (prefers-color-scheme: dark) {
|
||||
* {
|
||||
color: #ffb700 !important;
|
||||
border-color: #ffb700 !important;
|
||||
background-color: #000000 !important;
|
||||
}
|
||||
|
||||
.site-nav {
|
||||
color-scheme: only dark !important;
|
||||
color: #ffb700 !important;
|
||||
background-color: #000000 !important;
|
||||
color: #ffb700 !important;
|
||||
}
|
||||
|
||||
// I don't want links to be restored to amber'
|
||||
a {
|
||||
color: revert !important;
|
||||
}
|
||||
}
|
@ -1,171 +0,0 @@
|
||||
Introduction
|
||||
|
||||
Ok, so you've decided to try out Supybot. That's great! The more people who
|
||||
use Supybot, the more people can submit bugs and help us to make it the best
|
||||
IRC bot in the world :)
|
||||
|
||||
You should have already read through our install document (if you had to
|
||||
manually install) before reading any further. Now we'll give you a whirlwind
|
||||
tour as to how you can get Supybot setup and use Supybot effectively.
|
||||
|
||||
Initial Setup
|
||||
|
||||
Now that you have Supybot installed, you'll want to get it running. The
|
||||
first thing you'll want to do is run supybot-wizard. Before running
|
||||
supybot-wizard, you should be in the directory in which you want your
|
||||
bot-related files to reside. The wizard will walk you through setting up a
|
||||
base config file for your Supybot. Once you've completed the wizard, you will
|
||||
have a config file called botname.conf. In order to get the bot running, run
|
||||
'supybot botname.conf'.
|
||||
|
||||
Listing Commands
|
||||
|
||||
Ok, so let's assume your bot connected to the server and joined the channels
|
||||
you told it to join. For now we'll assume you named your bot 'supybot' (you
|
||||
probably didn't, but it'll make it much clearer in the examples that follow to
|
||||
assume that you did). We'll also assume that you told it to join #channel (a
|
||||
nice generic name for a channel, isn't it? :)) So what do you do with this bot
|
||||
that you just made to join your channel? Try this in the channel::
|
||||
|
||||
supybot: list
|
||||
|
||||
Replacing 'supybot' with the actual name you picked for your bot, of course.
|
||||
Your bot should reply with a list of the plugins he currently has loaded. At
|
||||
least Admin, Channel, Config, Misc, Owner, and User should be there; if you
|
||||
used supybot-wizard to create your configuration file you may have many more
|
||||
plugins loaded. The list command can also be used to list the commands in a
|
||||
given plugin::
|
||||
|
||||
supybot: list Misc
|
||||
|
||||
will list all the commands in the Misc plugin. If you want to see the help
|
||||
for any command, just use the help command::
|
||||
|
||||
supybot: help help
|
||||
supybot: help list
|
||||
supybot: help load
|
||||
|
||||
Sometimes more than one plugin will have a given command; for instance, the
|
||||
"list" command exists in both the Misc and Config plugins (both loaded by
|
||||
default). List, in this case, defaults to the Misc plugin, but you may want to
|
||||
get the help for the list command in the Config plugin. In that case, you'll
|
||||
want to give your command like this::
|
||||
|
||||
supybot: help config list
|
||||
|
||||
Anytime your bot tells you that a given command is defined in several
|
||||
plugins, you'll want to use this syntax ("plugin command") to disambiguate
|
||||
which plugin's command you wish to call. For instance, if you wanted to call
|
||||
the Config plugin's list command, then you'd need to say::
|
||||
|
||||
supybot: config list
|
||||
|
||||
Rather than just 'list'.
|
||||
|
||||
Making Supybot Recognize You
|
||||
|
||||
If you ran the wizard, then it is almost certainly the case that you already
|
||||
added an owner user for yourself. If not, however, you can add one via the
|
||||
handy-dandy 'supybot-adduser' script. You'll want to run it while the bot is
|
||||
not running (otherwise it could overwrite supybot-adduser's changes to your
|
||||
user database before you get a chance to reload them). Just follow the
|
||||
prompts, and when it asks if you want to give the user any capabilities, say
|
||||
yes and then give yourself the 'owner' capability, restart the bot and you'll
|
||||
be ready to load some plugins!
|
||||
|
||||
Now, in order for the bot to recognize you as your owner user, you'll have to
|
||||
identify with the bot. Open up a query window in your irc client ('/query'
|
||||
should do it; if not, just know that you can't identify in a channel because it
|
||||
requires sending your password to the bot). Then type this::
|
||||
|
||||
help identify
|
||||
|
||||
And follow the instructions; the command you send will probably look like
|
||||
this, with 'myowneruser' and 'myuserpassword' replaced::
|
||||
|
||||
identify myowneruser myuserpassword
|
||||
|
||||
The bot will tell you that 'The operation succeeded' if you got the right
|
||||
name and password. Now that you're identified, you can do anything that
|
||||
requires any privilege: that includes all the commands in the Owner and Admin
|
||||
plugins, which you may want to take a look at (using the list and help
|
||||
commands, of course). One command in particular that you might want to use
|
||||
(it's from the User plugin) is the 'addhostmask' command: it lets you add a
|
||||
hostmask to your user record so the bot recognizes you by your hostmask instead
|
||||
of requiring you always to identify with it before it recognizes you. Use the
|
||||
'help' command to see how this command works. Here's how I often use it::
|
||||
|
||||
addhostmask myuser [hostmask] mypassword
|
||||
|
||||
You may not have seen that '[hostmask]' syntax before. Supybot allows nested
|
||||
commands, which means that any command's output can be nested as an argument to
|
||||
another command. The hostmask command from the Misc plugin returns the
|
||||
hostmask of a given nick, but if given no arguments, it returns the hostmask of
|
||||
the person giving the command. So the command above adds the hostmask I'm
|
||||
currently using to my user's list of recognized hostmasks. I'm only required
|
||||
to give mypassword if I'm not already identified with the bot.
|
||||
|
||||
Loading Plugins
|
||||
|
||||
Let's take a look at loading other plugins. If you didn't use
|
||||
supybot-wizard, though, you might do well to try it before playing around with
|
||||
loading plugins yourself: each plugin has its own configure function that the
|
||||
wizard uses to setup the appropriate registry entries if the plugin requires
|
||||
any.
|
||||
|
||||
If you do want to play around with loading plugins, you're going to need to
|
||||
have the owner capability.
|
||||
|
||||
Remember earlier when I told you to try 'help load'? That's the very command
|
||||
you'll be using. Basically, if you want to load, say, the Games plugin, then
|
||||
'load Games'. Simple, right? If you need a list of the plugins you can load,
|
||||
you'll have to list the directory the plugins are in (using whatever command is
|
||||
appropriate for your operating system, either 'ls' or 'dir').
|
||||
|
||||
Getting More From Your Supybot
|
||||
|
||||
Another command you might find yourself needing somewhat often is the 'more'
|
||||
command. The IRC protocol limits messages to 512 bytes, 60 or so of which must
|
||||
be devoted to some bookkeeping. Sometimes, however, Supybot wants to send a
|
||||
message that's longer than that. What it does, then, is break it into "chunks"
|
||||
and send the first one, following it with '(X more messages)' where X is how
|
||||
many more chunks there are. To get to these chunks, use the more command. One
|
||||
way to try is to look at the default value of
|
||||
supybot.replies.genericNoCapability -- it's so long that it'll stretch across two
|
||||
messages::
|
||||
|
||||
<jemfinch|lambda> $config default
|
||||
supybot.replies.genericNoCapability
|
||||
<lambdaman> jemfinch|lambda: You're missing some capability
|
||||
you need. This could be because you actually
|
||||
possess the anti-capability for the capability
|
||||
that's required of you, or because the channel
|
||||
provides that anti-capability by default, or
|
||||
because the global capabilities include that
|
||||
anti-capability. Or, it could be because the
|
||||
channel or the global defaultAllow is set to
|
||||
False, meaning (1 more message)
|
||||
<jemfinch|lambda> $more
|
||||
<lambdaman> jemfinch|lambda: that no commands are allowed
|
||||
unless explicitly in your capabilities. Either
|
||||
way, you can't do what you want to do.
|
||||
|
||||
So basically, the bot keeps, for each person it sees, a list of "chunks"
|
||||
which are "released" one at a time by the 'more' command. In fact, you can
|
||||
even get the more chunks for another user: if you want to see another chunk in
|
||||
the last command jemfinch gave, for instance, you would just say 'more
|
||||
jemfinch' after which, his "chunks" now belong to you. So, you would just need
|
||||
to say 'more' to continue seeing chunks from jemfinch's initial command.
|
||||
|
||||
Final Word
|
||||
|
||||
You should now have a solid foundation for using Supybot. You can use the
|
||||
'list' command to see what plugins your bot has loaded and what commands are in
|
||||
those plugins; you can use the 'help' command to see how to use a specific
|
||||
command, and you can use the 'more' command to continue a long response from
|
||||
the bot. With these three commands, you should have a strong basis with which
|
||||
to discover the rest of the features of Supybot!
|
||||
|
||||
Do be sure to read our other documentation and make use of the resources we
|
||||
provide for assistance; this website, the forums on it, and, of course,
|
||||
#supybot on irc.freenode.net if you run into any trouble!
|
@ -1,42 +0,0 @@
|
||||
.\" Process this file with
|
||||
.\" groff -man -Tascii supybot-adduser.1
|
||||
.\"
|
||||
.TH SUPYBOT-ADDUSER 1 "APRIL 2005"
|
||||
.SH NAME
|
||||
supybot-adduser \- Adds a user to a Supybot users.conf file
|
||||
.SH SYNOPSIS
|
||||
.B supybot-adduser
|
||||
.RI [ options ] " users.conf
|
||||
.SH DESCRIPTION
|
||||
.B supybot-adduser
|
||||
adds a user to the specified users.conf file.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B \-\^\-version
|
||||
Show version of program.
|
||||
.TP
|
||||
.BR \-h ", " \-\^\-help
|
||||
Show summary of options.
|
||||
.TP
|
||||
.BR \-u " NAME" "\fR,\fP \-\^\-username=" NAME
|
||||
Specifies the username to use for the new user.
|
||||
.TP
|
||||
.BR \-p " PASSWORD" "\fR,\fP \-\^\-password=" PASSWORD
|
||||
Specifies the password to use for the new user.
|
||||
.TP
|
||||
.BR \-c " CAPABILITY" "\fR,\fP \-\^\-capability=" CAPABILITY
|
||||
Capability the user should have; this option may be given
|
||||
multiple times.
|
||||
.SH "SEE ALSO"
|
||||
.IR python (1),
|
||||
.IR supybot (1),
|
||||
.IR supybot-test (1),
|
||||
.IR supybot-botchk (1),
|
||||
.IR supybot-wizard (1),
|
||||
.IR supybot-plugin-doc (1),
|
||||
.IR supybot-plugin-create (1)
|
||||
.SH AUTHOR
|
||||
This manual page was originally written by James Vega
|
||||
<vega dot james at gmail dot com>. Permission is granted to copy,
|
||||
distribute and/or modify this document under the terms of the Supybot
|
||||
license, a BSD-style license.
|
@ -1,54 +0,0 @@
|
||||
.\" Process this file with
|
||||
.\" groff -man -Tascii supybot-botchk.1
|
||||
.\"
|
||||
.TH SUPYBOT-BOTCHK 1 "APRIL 2005"
|
||||
.SH NAME
|
||||
supybot-botchk \- A script to start Supybot if it's not already running.
|
||||
.SH SYNOPSIS
|
||||
.B supybot-botchk
|
||||
.RI [ options ]
|
||||
.SH DESCRIPTION
|
||||
.B supybot-botchk
|
||||
is a script that will start Supybot if it detects that one is not currently
|
||||
running. This can be useful for scheduling
|
||||
.IR supybot (1)
|
||||
to run via
|
||||
.IR cron (8).
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.BR \-h ", " \-\^\-help
|
||||
Show summary of options.
|
||||
.TP
|
||||
.BR \-v ", " \-\^\-verbose
|
||||
Use verbose output when running the script.
|
||||
.TP
|
||||
.BI \-\^\-botdir= BOTDIR
|
||||
Determines which directory the bot be started in.
|
||||
.TP
|
||||
.BI \-\^\-pidfile= PIDFILE
|
||||
Specifies the name of the pidfile to look for. This should be relative
|
||||
to the given botdir.
|
||||
.TP
|
||||
.BI \-\^\-supybot= SUPYBOT
|
||||
Specifies the location of
|
||||
.IR supybot (1).
|
||||
If this is not given, it is assumed that
|
||||
.IR supybot (1)
|
||||
is in the user's $PATH.
|
||||
.TP
|
||||
.BI \-\^\-conffile= CONFFILE
|
||||
Specifies the path to the bot's configuration file. This will be used
|
||||
when (re)starting the bot.
|
||||
.SH "SEE ALSO"
|
||||
.IR python (1),
|
||||
.IR supybot (1),
|
||||
.IR supybot-test (1),
|
||||
.IR supybot-wizard (1),
|
||||
.IR supybot-adduser (1),
|
||||
.IR supybot-plugin-doc (1),
|
||||
.IR supybot-plugin-create (1)
|
||||
.SH AUTHOR
|
||||
This manual page was originally written by James Vega
|
||||
<vega dot james at gmail dot com>. Permission is granted to copy,
|
||||
distribute and/or modify this document under the terms of the Supybot
|
||||
license, a BSD-style license.
|
@ -1,43 +0,0 @@
|
||||
.\" Process this file with
|
||||
.\" groff -man -Tascii supybot-plugin-create.1
|
||||
.\"
|
||||
.TH SUPYBOT-PLUGIN-CREATE 1 "APRIL 2005"
|
||||
.SH NAME
|
||||
supybot-plugin-create \- A wizard for creating Supybot plugins
|
||||
.SH SYNOPSIS
|
||||
.B supybot-plugin-create
|
||||
.RI [ options ]
|
||||
.SH DESCRIPTION
|
||||
.B supybot-plugin-create
|
||||
is a wizard that creates a template python source file for a new
|
||||
.IR supybot (1)
|
||||
plugin.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B \-\^\-version
|
||||
Show version of program.
|
||||
.TP
|
||||
.BR \-h ", " \-\^\-help
|
||||
Show summary of options.
|
||||
.TP
|
||||
.BI \-n " NAME" "\fR,\fP \-\^\-name=" NAME
|
||||
Sets the name for the plugin.
|
||||
.TP
|
||||
.BR \-t ", " \-\^\-thread
|
||||
Makes the plugin threaded.
|
||||
.TP
|
||||
.BI \-\^\-real\-name= REALNAME
|
||||
Specify what real name the copyright is assigned to.
|
||||
.SH "SEE ALSO"
|
||||
.IR python (1),
|
||||
.IR supybot (1),
|
||||
.IR supybot-test (1),
|
||||
.IR supybot-botchk (1),
|
||||
.IR supybot-wizard (1),
|
||||
.IR supybot-adduser (1),
|
||||
.IR supybot-plugin-doc (1)
|
||||
.SH AUTHOR
|
||||
This manual page was originally written by James Vega
|
||||
<vega dot james at gmail dot com>. Permission is granted to copy,
|
||||
distribute and/or modify this document under the terms of the Supybot
|
||||
license, a BSD-style license.
|
@ -1,45 +0,0 @@
|
||||
.\" Process this file with
|
||||
.\" groff -man -Tascii supybot-plugin-doc.1
|
||||
.\"
|
||||
.TH SUPYBOT-PLUGIN-DOC 1 "APRIL 2005"
|
||||
.SH NAME
|
||||
supybot-plugin-doc \- Generates the documentation for a Supybot plugin
|
||||
.SH SYNOPSIS
|
||||
.B supybot-plugin-doc
|
||||
.RI [ options ]
|
||||
.SH DESCRIPTION
|
||||
.B supybot-plugin-doc
|
||||
is used to generate documentation (STX format) for a
|
||||
.IR supybot (1)
|
||||
plugin.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B \-\^\-version
|
||||
Show version of program.
|
||||
.TP
|
||||
.BR \-h ", " \-\^\-help
|
||||
Show summary of options.
|
||||
.TP
|
||||
.BI \-c ", " \-\^\-clean
|
||||
Clean the various data/conf/log directories after generating the docs.
|
||||
.TP
|
||||
.BR \-\^\-no\-escape
|
||||
Disables escaping of html entities e.g., < as <. This is useful for making
|
||||
documentation that will not be rendered as STX on a website.
|
||||
.TP
|
||||
.BI \-\^\-plugins\-dir= PLUGINSDIRS
|
||||
Looks in the given directory for plugins and generates documentation for all of
|
||||
them.
|
||||
.SH "SEE ALSO"
|
||||
.IR python (1),
|
||||
.IR supybot (1),
|
||||
.IR supybot-test (1),
|
||||
.IR supybot-botchk (1),
|
||||
.IR supybot-wizard (1),
|
||||
.IR supybot-adduser (1),
|
||||
.IR supybot-plugin-create (1)
|
||||
.SH AUTHOR
|
||||
This manual page was originally written by James Vega
|
||||
<vega dot james at gmail dot com>. Permission is granted to copy,
|
||||
distribute and/or modify this document under the terms of the Supybot
|
||||
license, a BSD-style license.
|
@ -1,42 +0,0 @@
|
||||
.\" Process this file with
|
||||
.\" groff -man -Tascii supybot-wizard.1
|
||||
.\"
|
||||
.TH SUPYBOT-WIZARD 1 "SEPTEMBER 2004"
|
||||
.SH NAME
|
||||
supybot-wizard \- A wizard for creating Supybot configuration files
|
||||
.SH SYNOPSIS
|
||||
.B supybot-wizard
|
||||
.RI [ options ]
|
||||
.SH DESCRIPTION
|
||||
.B supybot-wizard
|
||||
is an in-depth wizard that provides a nice user interface for creating
|
||||
configuration files for
|
||||
.IR supybot (1).
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B \-\^\-version
|
||||
Show version of program.
|
||||
.TP
|
||||
.BR \-h ", " \-\^\-help
|
||||
Show summary of options.
|
||||
.TP
|
||||
.B \-\^\-allow\-root
|
||||
Determines whether the wizard will be allowed to run as root. You do not
|
||||
want this. Do not do it. Even if you think you want it, you do not.
|
||||
.TP
|
||||
.B \-\^\-no\-network
|
||||
Determines whether the wizard will be allowed to run without a network
|
||||
connection.
|
||||
.SH "SEE ALSO"
|
||||
.IR python (1),
|
||||
.IR supybot (1),
|
||||
.IR supybot-test (1),
|
||||
.IR supybot-botchk (1),
|
||||
.IR supybot-adduser (1),
|
||||
.IR supybot-plugin-doc (1),
|
||||
.IR supybot-plugin-create (1)
|
||||
.SH AUTHOR
|
||||
This manual page was originally written by James Vega
|
||||
<vega dot james at gmail dot com>. Permission is granted to copy,
|
||||
distribute and/or modify this document under the terms of the Supybot
|
||||
license, a BSD-style license.
|
@ -1,66 +0,0 @@
|
||||
.\" Process this file with
|
||||
.\" groff -man -Tascii supybot.1
|
||||
.\"
|
||||
.TH SUPYBOT 1 "APRIL 2005"
|
||||
.SH NAME
|
||||
supybot \- A robust and user friendly Python IRC bot
|
||||
.SH SYNOPSIS
|
||||
.B supybot
|
||||
.RI [ options ] " configFile
|
||||
.SH DESCRIPTION
|
||||
.B Supybot
|
||||
is a robust, user-friendly, and programmer-friendly Python IRC bot.
|
||||
It aims to be an adequate replacement for most existing IRC bots. It
|
||||
includes a very flexible and powerful ACL system for controlling access
|
||||
to commands, as well as more than 50 builtin plugins providing around
|
||||
400 actual commands.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B \-\^\-version
|
||||
Show version of program.
|
||||
.TP
|
||||
.BR \-h ", " \-\^\-help
|
||||
Show summary of options.
|
||||
.TP
|
||||
.BR \-P ", " \-\^\-profile
|
||||
Enable profiling.
|
||||
.TP
|
||||
.BI \-n " NICK" "\fR,\fP \-\^\-nick=" NICK
|
||||
Nick the bot should use.
|
||||
.TP
|
||||
.BI \-u " USER" "\fR,\fP \-\^\-user=" USER
|
||||
Full username the bot should use.
|
||||
.TP
|
||||
.BI \-i " IDENT" "\fR,\fP \-\^\-ident=" IDENT
|
||||
Ident the bot should use.
|
||||
.TP
|
||||
.BR \-d ", " \-\^\-daemon
|
||||
Determines whether the bot will daemonize. This is a no-op on
|
||||
non-POSIX systems.
|
||||
.TP
|
||||
.B \-\^\-allow\-default\-owner
|
||||
Determines whether the bot will allow its defaultCapabilities not to
|
||||
include "-owner", thus giving all users the owner capability by
|
||||
default. This is dumb, hence we require a command-line option to
|
||||
enable it.
|
||||
.TP
|
||||
.B \-\^\-allow\-root
|
||||
Determines whether the bot will be allowed to run as root. You do not
|
||||
want this. Do not do it. Even if you think you want it, you do not.
|
||||
.TP
|
||||
.B \-\^\-debug
|
||||
Determines whether some extra debugging stuff will be logged by this
|
||||
script.
|
||||
.SH "SEE ALSO"
|
||||
.IR python (1),
|
||||
.IR supybot-test (1),
|
||||
.IR supybot-botchk (1),
|
||||
.IR supybot-wizard (1),
|
||||
.IR supybot-adduser (1),
|
||||
.IR supybot-plugin-doc (1),
|
||||
.IR supybot-plugin-create (1)
|
||||
.SH AUTHOR
|
||||
This manual page was originally written by James Vega
|
||||
<vega dot james at gmail dot com>. Permission is granted to copy,
|
||||
distribute and/or modify this document under the terms of the Supybot
|
||||
license, a BSD-style license.
|
30
feed.xml
Normal file
30
feed.xml
Normal file
@ -0,0 +1,30 @@
|
||||
---
|
||||
layout: null
|
||||
---
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||
<channel>
|
||||
<title>{{ site.title | xml_escape }}</title>
|
||||
<description>{{ site.description | xml_escape }}</description>
|
||||
<link>{{ site.url }}{{ site.baseurl }}/</link>
|
||||
<atom:link href="{{ "/feed.xml" | prepend: site.baseurl | prepend: site.url }}" rel="self" type="application/rss+xml"/>
|
||||
<pubDate>{{ site.time | date_to_rfc822 }}</pubDate>
|
||||
<lastBuildDate>{{ site.time | date_to_rfc822 }}</lastBuildDate>
|
||||
<generator>Jekyll v{{ jekyll.version }}</generator>
|
||||
{% for post in site.posts limit:10 %}
|
||||
<item>
|
||||
<title>{{ post.title | xml_escape }}</title>
|
||||
<description>{{ post.content | xml_escape }}</description>
|
||||
<pubDate>{{ post.date | date_to_rfc822 }}</pubDate>
|
||||
<link>{{ post.url | prepend: site.baseurl | prepend: site.url }}</link>
|
||||
<guid isPermaLink="true">{{ post.url | prepend: site.baseurl | prepend: site.url }}</guid>
|
||||
{% for tag in post.tags %}
|
||||
<category>{{ tag | xml_escape }}</category>
|
||||
{% endfor %}
|
||||
{% for cat in post.categories %}
|
||||
<category>{{ cat | xml_escape }}</category>
|
||||
{% endfor %}
|
||||
</item>
|
||||
{% endfor %}
|
||||
</channel>
|
||||
</rss>
|
26
index.markdown
Normal file
26
index.markdown
Normal file
@ -0,0 +1,26 @@
|
||||
---
|
||||
layout: default
|
||||
---
|
||||
|
||||
<!-- @format -->
|
||||
|
||||
**_WARNING: most of the content on this site originates from 2014!_**
|
||||
|
||||
Welcome to Mikaela's Supybot pages.
|
||||
|
||||
This site isn't official and won't help with most of issues. In case you are
|
||||
looking for the official sites, they are here:
|
||||
|
||||
- [Limnoria's website](https://limnoria.net/)
|
||||
- [Limnoria official documentation](https://docs.limnoria.net/)
|
||||
- [Supybook](https://hoxu.github.io/supybook/devel/)
|
||||
- [Gribble Wiki](https://sourceforge.net/p/gribble/wiki/Main_Page/)
|
||||
|
||||
I also have
|
||||
[something in my gist repo](https://gitea.blesmrt.net/mikaela/gist/src/branch/master/irc/limnoria/)
|
||||
at 2021-06-11 16:07 UTC
|
||||
[opinionated titlefetching instructions](https://gitea.blesmrt.net/mikaela/gist/src/branch/master/irc/limnoria/titlefetching.md).
|
||||
|
||||
If you cannot find what you are looking for from them, please come to IRC and
|
||||
ask. The Support channels are
|
||||
[#supybot,#limnoria on irc.libera.chat](ircs://irc.libera.chat:6697/%23supybot%2c%23limnoria)
|
14
package.json
Normal file
14
package.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"devDependencies": {
|
||||
"@aminda/global-prettier-config": "2025.15.0",
|
||||
"@prettier/plugin-ruby": "4.0.4",
|
||||
"@prettier/plugin-xml": "3.4.1",
|
||||
"corepack": "latest",
|
||||
"prettier": "3.5.3",
|
||||
"prettier-plugin-nginx": "1.0.3",
|
||||
"prettier-plugin-sh": "0.17.1",
|
||||
"prettier-plugin-toml": "2.0.4"
|
||||
},
|
||||
"packageManager": "pnpm@10.8.0+sha512.0e82714d1b5b43c74610193cb20734897c1d00de89d0e18420aebc5977fa13d780a9cb05734624e81ebd81cc876cd464794850641c48b9544326b5622ca29971",
|
||||
"prettier": "@aminda/global-prettier-config"
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2004-2005, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
"""
|
||||
These are commands useful for administrating the bot; they all require their
|
||||
caller to have the 'admin' capability. This plugin is loaded by default.
|
||||
"""
|
||||
|
||||
import supybot
|
||||
import supybot.world as world
|
||||
|
||||
__author__ = supybot.authors.jemfinch
|
||||
|
||||
# Use this for the version of this plugin. You may wish to put a CVS keyword
|
||||
# in here if you\'re keeping the plugin in CVS or some similar system.
|
||||
__version__ = "%%VERSION%%"
|
||||
|
||||
# This is a dictionary mapping supybot.Author instances to lists of
|
||||
# contributions.
|
||||
__contributors__ = {}
|
||||
|
||||
import config
|
||||
import plugin
|
||||
reload(plugin) # In case we're being reloaded.
|
||||
|
||||
if world.testing:
|
||||
import test
|
||||
|
||||
Class = plugin.Class
|
||||
configure = config.configure
|
@ -1,48 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2004-2005, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
|
||||
import supybot.conf as conf
|
||||
import supybot.registry as registry
|
||||
|
||||
def configure(advanced):
|
||||
# This will be called by supybot to configure this module. advanced is
|
||||
# a bool that specifies whether the user identified himself as an advanced
|
||||
# user or not. You should effect your configuration by manipulating the
|
||||
# registry as appropriate.
|
||||
from supybot.questions import expect, anything, something, yn
|
||||
conf.registerPlugin('Admin', True)
|
||||
|
||||
|
||||
Admin = conf.registerPlugin('Admin')
|
||||
# This is where your configuration variables (if any) should go. For example:
|
||||
# conf.registerGlobalValue(Admin, 'someConfigVariableName',
|
||||
# registry.Boolean(False, """Help for someConfigVariableName."""))
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1,340 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2002-2005, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
import sys
|
||||
import time
|
||||
|
||||
import supybot.conf as conf
|
||||
import supybot.ircdb as ircdb
|
||||
import supybot.utils as utils
|
||||
from supybot.commands import *
|
||||
import supybot.ircmsgs as ircmsgs
|
||||
import supybot.ircutils as ircutils
|
||||
import supybot.schedule as schedule
|
||||
import supybot.callbacks as callbacks
|
||||
|
||||
class Admin(callbacks.Plugin):
|
||||
def __init__(self, irc):
|
||||
self.__parent = super(Admin, self)
|
||||
self.__parent.__init__(irc)
|
||||
self.joins = {}
|
||||
self.pendingNickChanges = {}
|
||||
|
||||
def do437(self, irc, msg):
|
||||
"""Nick/channel temporarily unavailable."""
|
||||
target = msg.args[0]
|
||||
if irc.isChannel(target): # We don't care about nicks.
|
||||
t = time.time() + 30
|
||||
# Let's schedule a rejoin.
|
||||
networkGroup = conf.supybot.networks.get(irc.network)
|
||||
def rejoin():
|
||||
irc.queueMsg(networkGroup.channels.join(target))
|
||||
# We don't need to schedule something because we'll get another
|
||||
# 437 when we try to join later.
|
||||
schedule.addEvent(rejoin, t)
|
||||
self.log.info('Scheduling a rejoin to %s at %s; '
|
||||
'Channel temporarily unavailable.', target, t)
|
||||
|
||||
def do471(self, irc, msg):
|
||||
try:
|
||||
channel = msg.args[1]
|
||||
(irc, msg) = self.joins.pop(channel)
|
||||
irc.error('Cannot join %s, it\'s full.' % channel)
|
||||
except KeyError:
|
||||
self.log.debug('Got 471 without Admin.join being called.')
|
||||
|
||||
def do473(self, irc, msg):
|
||||
try:
|
||||
channel = msg.args[1]
|
||||
(irc, msg) = self.joins.pop(channel)
|
||||
irc.error('Cannot join %s, I was not invited.' % channel)
|
||||
except KeyError:
|
||||
self.log.debug('Got 473 without Admin.join being called.')
|
||||
|
||||
def do474(self, irc, msg):
|
||||
try:
|
||||
channel = msg.args[1]
|
||||
(irc, msg) = self.joins.pop(channel)
|
||||
irc.error('Cannot join %s, it\'s banned me.' % channel)
|
||||
except KeyError:
|
||||
self.log.debug('Got 474 without Admin.join being called.')
|
||||
|
||||
def do475(self, irc, msg):
|
||||
try:
|
||||
channel = msg.args[1]
|
||||
(irc, msg) = self.joins.pop(channel)
|
||||
irc.error('Cannot join %s, my keyword was wrong.' % channel)
|
||||
except KeyError:
|
||||
self.log.debug('Got 475 without Admin.join being called.')
|
||||
|
||||
def do515(self, irc, msg):
|
||||
try:
|
||||
channel = msg.args[1]
|
||||
(irc, msg) = self.joins.pop(channel)
|
||||
irc.error('Cannot join %s, I\'m not identified with the NickServ.'
|
||||
% channel)
|
||||
except KeyError:
|
||||
self.log.debug('Got 515 without Admin.join being called.')
|
||||
|
||||
def doJoin(self, irc, msg):
|
||||
if msg.prefix == irc.prefix:
|
||||
try:
|
||||
del self.joins[msg.args[0]]
|
||||
except KeyError:
|
||||
s = 'Joined a channel without Admin.join being called.'
|
||||
self.log.debug(s)
|
||||
|
||||
def doInvite(self, irc, msg):
|
||||
channel = msg.args[1]
|
||||
if channel not in irc.state.channels:
|
||||
if conf.supybot.alwaysJoinOnInvite() or \
|
||||
ircdb.checkCapability(msg.prefix, 'admin'):
|
||||
self.log.info('Invited to %s by %s.', channel, msg.prefix)
|
||||
networkGroup = conf.supybot.networks.get(irc.network)
|
||||
irc.queueMsg(networkGroup.channels.join(channel))
|
||||
conf.supybot.networks.get(irc.network).channels().add(channel)
|
||||
else:
|
||||
self.log.warning('Invited to %s by %s, but '
|
||||
'supybot.alwaysJoinOnInvite was False and '
|
||||
'the user lacked the "admin" capability.',
|
||||
channel, msg.prefix)
|
||||
|
||||
def join(self, irc, msg, args, channel, key):
|
||||
"""<channel> [<key>]
|
||||
|
||||
Tell the bot to join the given channel. If <key> is given, it is used
|
||||
when attempting to join the channel.
|
||||
"""
|
||||
if not irc.isChannel(channel):
|
||||
irc.errorInvalid('channel', channel, Raise=True)
|
||||
networkGroup = conf.supybot.networks.get(irc.network)
|
||||
networkGroup.channels().add(channel)
|
||||
if key:
|
||||
networkGroup.channels.key.get(channel).setValue(key)
|
||||
maxchannels = irc.state.supported.get('maxchannels', sys.maxint)
|
||||
if len(irc.state.channels) + 1 > maxchannels:
|
||||
irc.error('I\'m already too close to maximum number of '
|
||||
'channels for this network.', Raise=True)
|
||||
irc.queueMsg(networkGroup.channels.join(channel))
|
||||
irc.noReply()
|
||||
self.joins[channel] = (irc, msg)
|
||||
join = wrap(join, ['validChannel', additional('something')])
|
||||
|
||||
def channels(self, irc, msg, args):
|
||||
"""takes no arguments
|
||||
|
||||
Returns the channels the bot is on. Must be given in private, in order
|
||||
to protect the secrecy of secret channels.
|
||||
"""
|
||||
L = irc.state.channels.keys()
|
||||
if L:
|
||||
utils.sortBy(ircutils.toLower, L)
|
||||
irc.reply(format('%L', L))
|
||||
else:
|
||||
irc.reply('I\'m not currently in any channels.')
|
||||
channels = wrap(channels, ['private'])
|
||||
|
||||
def do484(self, irc, msg):
|
||||
irc = self.pendingNickChanges.get(irc, None)
|
||||
if irc is not None:
|
||||
irc.error('My connection is restricted, I can\'t change nicks.')
|
||||
else:
|
||||
self.log.debug('Got 484 without Admin.nick being called.')
|
||||
|
||||
def do433(self, irc, msg):
|
||||
irc = self.pendingNickChanges.get(irc, None)
|
||||
if irc is not None:
|
||||
irc.error('Someone else is already using that nick.')
|
||||
else:
|
||||
self.log.debug('Got 433 without Admin.nick being called.')
|
||||
|
||||
def do435(self, irc, msg):
|
||||
irc = self.pendingNickChanges.get(irc, None)
|
||||
if irc is not None:
|
||||
irc.error('That nick is currently banned.')
|
||||
else:
|
||||
self.log.debug('Got 435 without Admin.nick being called.')
|
||||
|
||||
def do438(self, irc, msg):
|
||||
irc = self.pendingNickChanges.get(irc, None)
|
||||
if irc is not None:
|
||||
irc.error(format('I can\'t change nicks, the server said %q.',
|
||||
msg.args[2]), private=True)
|
||||
else:
|
||||
self.log.debug('Got 438 without Admin.nick being called.')
|
||||
|
||||
def doNick(self, irc, msg):
|
||||
if msg.nick == irc.nick or msg.args[0] == irc.nick:
|
||||
try:
|
||||
del self.pendingNickChanges[irc]
|
||||
except KeyError:
|
||||
self.log.debug('Got NICK without Admin.nick being called.')
|
||||
|
||||
def nick(self, irc, msg, args, nick):
|
||||
"""[<nick>]
|
||||
|
||||
Changes the bot's nick to <nick>. If no nick is given, returns the
|
||||
bot's current nick.
|
||||
"""
|
||||
if nick:
|
||||
conf.supybot.nick.setValue(nick)
|
||||
irc.queueMsg(ircmsgs.nick(nick))
|
||||
self.pendingNickChanges[irc.getRealIrc()] = irc
|
||||
else:
|
||||
irc.reply(irc.nick)
|
||||
nick = wrap(nick, [additional('nick')])
|
||||
|
||||
def part(self, irc, msg, args, channel, reason):
|
||||
"""[<channel>] [<reason>]
|
||||
|
||||
Tells the bot to part the list of channels you give it. <channel> is
|
||||
only necessary if you want the bot to part a channel other than the
|
||||
current channel. If <reason> is specified, use it as the part
|
||||
message.
|
||||
"""
|
||||
if channel is None:
|
||||
if irc.isChannel(msg.args[0]):
|
||||
channel = msg.args[0]
|
||||
else:
|
||||
irc.error(Raise=True)
|
||||
try:
|
||||
network = conf.supybot.networks.get(irc.network)
|
||||
network.channels().remove(channel)
|
||||
except KeyError:
|
||||
pass
|
||||
if channel not in irc.state.channels:
|
||||
irc.error('I\'m not in %s.' % channel, Raise=True)
|
||||
irc.queueMsg(ircmsgs.part(channel, reason or msg.nick))
|
||||
if msg.nick in irc.state.channels[channel].users:
|
||||
irc.noReply()
|
||||
else:
|
||||
irc.replySuccess()
|
||||
part = wrap(part, [optional('validChannel'), additional('text')])
|
||||
|
||||
class capability(callbacks.Commands):
|
||||
|
||||
def add(self, irc, msg, args, user, capability):
|
||||
"""<name|hostmask> <capability>
|
||||
|
||||
Gives the user specified by <name> (or the user to whom <hostmask>
|
||||
currently maps) the specified capability <capability>
|
||||
"""
|
||||
# Ok, the concepts that are important with capabilities:
|
||||
#
|
||||
### 1) No user should be able to elevate his privilege to owner.
|
||||
### 2) Admin users are *not* superior to #channel.ops, and don't
|
||||
### have God-like powers over channels.
|
||||
### 3) We assume that Admin users are two things: non-malicious and
|
||||
### and greedy for power. So they'll try to elevate their
|
||||
### privilege to owner, but they won't try to crash the bot for
|
||||
### no reason.
|
||||
|
||||
# Thus, the owner capability can't be given in the bot. Admin
|
||||
# users can only give out capabilities they have themselves (which
|
||||
# will depend on supybot.capabilities and its child default) but
|
||||
# generally means they can't mess with channel capabilities.
|
||||
if ircutils.strEqual(capability, 'owner'):
|
||||
irc.error('The "owner" capability can\'t be added in the bot.'
|
||||
' Use the supybot-adduser program (or edit the '
|
||||
'users.conf file yourself) to add an owner '
|
||||
'capability.')
|
||||
return
|
||||
if ircdb.isAntiCapability(capability) or \
|
||||
ircdb.checkCapability(msg.prefix, capability):
|
||||
user.addCapability(capability)
|
||||
ircdb.users.setUser(user)
|
||||
irc.replySuccess()
|
||||
else:
|
||||
irc.error('You can\'t add capabilities you don\'t have.')
|
||||
add = wrap(add, ['otherUser', 'lowered'])
|
||||
|
||||
def remove(self, irc, msg, args, user, capability):
|
||||
"""<name|hostmask> <capability>
|
||||
|
||||
Takes from the user specified by <name> (or the user to whom
|
||||
<hostmask> currently maps) the specified capability <capability>
|
||||
"""
|
||||
if ircdb.checkCapability(msg.prefix, capability) or \
|
||||
ircdb.isAntiCapability(capability):
|
||||
try:
|
||||
user.removeCapability(capability)
|
||||
ircdb.users.setUser(user)
|
||||
irc.replySuccess()
|
||||
except KeyError:
|
||||
irc.error('That user doesn\'t have that capability.')
|
||||
else:
|
||||
s = 'You can\'t remove capabilities you don\'t have.'
|
||||
irc.error(s)
|
||||
remove = wrap(remove, ['otherUser','lowered'])
|
||||
|
||||
class ignore(callbacks.Commands):
|
||||
|
||||
def add(self, irc, msg, args, hostmask, expires):
|
||||
"""<hostmask|nick> [<expires>]
|
||||
|
||||
Ignores <hostmask> or, if a nick is given, ignores whatever
|
||||
hostmask that nick is currently using. <expires> is a "seconds
|
||||
from now" value that determines when the ignore will expire; if,
|
||||
for instance, you wish for the ignore to expire in an hour, you
|
||||
could give an <expires> of 3600. If no <expires> is given, the
|
||||
ignore will never automatically expire.
|
||||
"""
|
||||
ircdb.ignores.add(hostmask, expires)
|
||||
irc.replySuccess()
|
||||
add = wrap(add, ['hostmask', additional('expiry', 0)])
|
||||
|
||||
def remove(self, irc, msg, args, hostmask):
|
||||
"""<hostmask|nick>
|
||||
|
||||
Ignores <hostmask> or, if a nick is given, ignores whatever
|
||||
hostmask that nick is currently using.
|
||||
"""
|
||||
try:
|
||||
ircdb.ignores.remove(hostmask)
|
||||
irc.replySuccess()
|
||||
except KeyError:
|
||||
irc.error('%s wasn\'t in the ignores database.' % hostmask)
|
||||
remove = wrap(remove, ['hostmask'])
|
||||
|
||||
def list(self, irc, msg, args):
|
||||
"""takes no arguments
|
||||
|
||||
Returns the hostmasks currently being globally ignored.
|
||||
"""
|
||||
# XXX Add the expirations.
|
||||
if ircdb.ignores.hostmasks:
|
||||
irc.reply(format('%L', (map(repr,ircdb.ignores.hostmasks))))
|
||||
else:
|
||||
irc.reply('I\'m not currently globally ignoring anyone.')
|
||||
list = wrap(list)
|
||||
|
||||
|
||||
Class = Admin
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1,127 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2002-2005, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
from supybot.test import *
|
||||
|
||||
class AdminTestCase(PluginTestCase):
|
||||
plugins = ('Admin',)
|
||||
def testChannels(self):
|
||||
def getAfterJoinMessages():
|
||||
m = self.irc.takeMsg()
|
||||
self.assertEqual(m.command, 'MODE')
|
||||
m = self.irc.takeMsg()
|
||||
self.assertEqual(m.command, 'WHO')
|
||||
self.assertRegexp('channels', 'not.*in any')
|
||||
self.irc.feedMsg(ircmsgs.join('#foo', prefix=self.prefix))
|
||||
getAfterJoinMessages()
|
||||
self.assertRegexp('channels', '#foo')
|
||||
self.irc.feedMsg(ircmsgs.join('#bar', prefix=self.prefix))
|
||||
getAfterJoinMessages()
|
||||
self.assertRegexp('channels', '#bar and #foo')
|
||||
self.irc.feedMsg(ircmsgs.join('#Baz', prefix=self.prefix))
|
||||
getAfterJoinMessages()
|
||||
self.assertRegexp('channels', '#bar, #Baz, and #foo')
|
||||
|
||||
def testIgnoreAddRemove(self):
|
||||
self.assertNotError('admin ignore add foo!bar@baz')
|
||||
self.assertError('admin ignore add alsdkfjlasd')
|
||||
self.assertNotError('admin ignore remove foo!bar@baz')
|
||||
self.assertError('admin ignore remove foo!bar@baz')
|
||||
|
||||
def testIgnoreList(self):
|
||||
self.assertNotError('admin ignore list')
|
||||
self.assertNotError('admin ignore add foo!bar@baz')
|
||||
self.assertNotError('admin ignore list')
|
||||
self.assertNotError('admin ignore add foo!bar@baz')
|
||||
self.assertRegexp('admin ignore list', 'foo')
|
||||
|
||||
def testCapabilityAdd(self):
|
||||
self.assertError('capability add foo bar')
|
||||
u = ircdb.users.newUser()
|
||||
u.name = 'foo'
|
||||
ircdb.users.setUser(u)
|
||||
self.assertNotError('capability add foo bar')
|
||||
self.assertError('addcapability foo baz')
|
||||
self.assert_('bar' in u.capabilities)
|
||||
ircdb.users.delUser(u.id)
|
||||
|
||||
def testCapabilityRemove(self):
|
||||
self.assertError('capability remove foo bar')
|
||||
u = ircdb.users.newUser()
|
||||
u.name = 'foo'
|
||||
ircdb.users.setUser(u)
|
||||
self.assertNotError('capability add foo bar')
|
||||
self.assert_('bar' in u.capabilities)
|
||||
self.assertError('removecapability foo bar')
|
||||
self.assertNotError('capability remove foo bar')
|
||||
self.assert_(not 'bar' in u.capabilities)
|
||||
ircdb.users.delUser(u.id)
|
||||
|
||||
def testJoin(self):
|
||||
m = self.getMsg('join #foo')
|
||||
self.assertEqual(m.command, 'JOIN')
|
||||
self.assertEqual(m.args[0], '#foo')
|
||||
m = self.getMsg('join #foo key')
|
||||
self.assertEqual(m.command, 'JOIN')
|
||||
self.assertEqual(m.args[0], '#foo')
|
||||
self.assertEqual(m.args[1], 'key')
|
||||
|
||||
def testPart(self):
|
||||
def getAfterJoinMessages():
|
||||
m = self.irc.takeMsg()
|
||||
self.assertEqual(m.command, 'MODE')
|
||||
m = self.irc.takeMsg()
|
||||
self.assertEqual(m.command, 'WHO')
|
||||
self.assertError('part #foo')
|
||||
self.assertRegexp('part #foo', 'not in')
|
||||
self.irc.feedMsg(ircmsgs.join('#foo', prefix=self.prefix))
|
||||
getAfterJoinMessages()
|
||||
m = self.getMsg('part #foo')
|
||||
self.assertEqual(m.command, 'PART')
|
||||
self.irc.feedMsg(ircmsgs.join('#foo', prefix=self.prefix))
|
||||
getAfterJoinMessages()
|
||||
m = self.getMsg('part #foo reason')
|
||||
self.assertEqual(m.command, 'PART')
|
||||
self.assertEqual(m.args[0], '#foo')
|
||||
self.assertEqual(m.args[1], 'reason')
|
||||
|
||||
def testNick(self):
|
||||
original = conf.supybot.nick()
|
||||
try:
|
||||
m = self.getMsg('nick foobar')
|
||||
self.assertEqual(m.command, 'NICK')
|
||||
self.assertEqual(m.args[0], 'foobar')
|
||||
finally:
|
||||
conf.supybot.nick.setValue(original)
|
||||
|
||||
def testAddCapabilityOwner(self):
|
||||
self.assertError('admin capability add %s owner' % self.nick)
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
||||
|
@ -1 +0,0 @@
|
||||
Insert a description of your plugin here, with any notes, etc. about using it.
|
@ -1,61 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2005, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
"""
|
||||
Allows aliases for other commands.
|
||||
"""
|
||||
|
||||
import supybot
|
||||
import supybot.world as world
|
||||
|
||||
# Use this for the version of this plugin. You may wish to put a CVS keyword
|
||||
# in here if you're keeping the plugin in CVS or some similar system.
|
||||
__version__ = ""
|
||||
|
||||
__author__ = supybot.authors.jemfinch
|
||||
|
||||
# This is a dictionary mapping supybot.Author instances to lists of
|
||||
# contributions.
|
||||
__contributors__ = {}
|
||||
|
||||
import config
|
||||
import plugin
|
||||
reload(plugin) # In case we're being reloaded.
|
||||
# Add more reloads here if you add third-party modules and want them to be
|
||||
# reloaded when this plugin is reloaded. Don't forget to import them as well!
|
||||
from plugin import findBiggestDollar, AliasError # for the tests.
|
||||
|
||||
if world.testing:
|
||||
import test
|
||||
|
||||
Class = plugin.Class
|
||||
configure = config.configure
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1,44 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2005, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
import supybot.conf as conf
|
||||
import supybot.registry as registry
|
||||
|
||||
def configure(advanced):
|
||||
# This will be called by supybot to configure this module. advanced is
|
||||
# a bool that specifies whether the user identified himself as an advanced
|
||||
# user or not. You should effect your configuration by manipulating the
|
||||
# registry as appropriate.
|
||||
from supybot.questions import expect, anything, something, yn
|
||||
conf.registerPlugin('Alias', True)
|
||||
|
||||
Alias = conf.registerPlugin('Alias')
|
||||
conf.registerGroup(Alias, 'aliases')
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1,325 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2002-2004, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
import re
|
||||
import new
|
||||
|
||||
import supybot.conf as conf
|
||||
import supybot.utils as utils
|
||||
from supybot.commands import *
|
||||
import supybot.ircutils as ircutils
|
||||
import supybot.registry as registry
|
||||
import supybot.callbacks as callbacks
|
||||
|
||||
# Copied from the old privmsgs.py.
|
||||
def getChannel(msg, args=()):
|
||||
"""Returns the channel the msg came over or the channel given in args.
|
||||
|
||||
If the channel was given in args, args is modified (the channel is
|
||||
removed).
|
||||
"""
|
||||
if args and ircutils.isChannel(args[0]):
|
||||
if conf.supybot.reply.requireChannelCommandsToBeSentInChannel():
|
||||
if args[0] != msg.args[0]:
|
||||
s = 'Channel commands must be sent in the channel to which ' \
|
||||
'they apply; if this is not the behavior you desire, ' \
|
||||
'ask the bot\'s administrator to change the registry ' \
|
||||
'variable ' \
|
||||
'supybot.reply.requireChannelCommandsToBeSentInChannel ' \
|
||||
'to False.'
|
||||
raise callbacks.Error, s
|
||||
return args.pop(0)
|
||||
elif ircutils.isChannel(msg.args[0]):
|
||||
return msg.args[0]
|
||||
else:
|
||||
raise callbacks.Error, 'Command must be sent in a channel or ' \
|
||||
'include a channel in its arguments.'
|
||||
|
||||
def getArgs(args, required=1, optional=0):
|
||||
if len(args) < required:
|
||||
raise callbacks.ArgumentError
|
||||
if len(args) < required + optional:
|
||||
ret = list(args) + ([''] * (required + optional - len(args)))
|
||||
elif len(args) >= required + optional:
|
||||
ret = list(args[:required + optional - 1])
|
||||
ret.append(' '.join(args[required + optional - 1:]))
|
||||
if len(ret) == 1:
|
||||
return ret[0]
|
||||
else:
|
||||
return ret
|
||||
|
||||
class AliasError(Exception):
|
||||
pass
|
||||
|
||||
class RecursiveAlias(AliasError):
|
||||
pass
|
||||
|
||||
dollarRe = re.compile(r'\$(\d+)')
|
||||
def findBiggestDollar(alias):
|
||||
dollars = dollarRe.findall(alias)
|
||||
dollars = map(int, dollars)
|
||||
dollars.sort()
|
||||
if dollars:
|
||||
return dollars[-1]
|
||||
else:
|
||||
return 0
|
||||
|
||||
atRe = re.compile(r'@(\d+)')
|
||||
def findBiggestAt(alias):
|
||||
ats = atRe.findall(alias)
|
||||
ats = map(int, ats)
|
||||
ats.sort()
|
||||
if ats:
|
||||
return ats[-1]
|
||||
else:
|
||||
return 0
|
||||
|
||||
def makeNewAlias(name, alias):
|
||||
original = alias
|
||||
biggestDollar = findBiggestDollar(original)
|
||||
biggestAt = findBiggestAt(original)
|
||||
wildcard = '$*' in original
|
||||
if biggestAt and wildcard:
|
||||
raise AliasError, 'Can\'t mix $* and optional args (@1, etc.)'
|
||||
if original.count('$*') > 1:
|
||||
raise AliasError, 'There can be only one $* in an alias.'
|
||||
testTokens = callbacks.tokenize(original)
|
||||
if testTokens and isinstance(testTokens[0], list):
|
||||
raise AliasError, 'Commands may not be the result of nesting.'
|
||||
def f(self, irc, msg, args):
|
||||
alias = original.replace('$nick', msg.nick)
|
||||
if '$channel' in original:
|
||||
channel = getChannel(msg, args)
|
||||
alias = alias.replace('$channel', channel)
|
||||
tokens = callbacks.tokenize(alias)
|
||||
if not wildcard and biggestDollar or biggestAt:
|
||||
args = getArgs(args, required=biggestDollar, optional=biggestAt)
|
||||
# Gotta have a mutable sequence (for replace).
|
||||
if biggestDollar + biggestAt == 1: # We got a string, no tuple.
|
||||
args = [args]
|
||||
def regexpReplace(m):
|
||||
idx = int(m.group(1))
|
||||
return args[idx-1]
|
||||
def replace(tokens, replacer):
|
||||
for (i, token) in enumerate(tokens):
|
||||
if isinstance(token, list):
|
||||
replace(token, replacer)
|
||||
else:
|
||||
tokens[i] = replacer(token)
|
||||
replace(tokens, lambda s: dollarRe.sub(regexpReplace, s))
|
||||
if biggestAt:
|
||||
assert not wildcard
|
||||
args = args[biggestDollar:]
|
||||
replace(tokens, lambda s: atRe.sub(regexpReplace, s))
|
||||
if wildcard:
|
||||
assert not biggestAt
|
||||
# Gotta remove the things that have already been subbed in.
|
||||
i = biggestDollar
|
||||
while i:
|
||||
args.pop(0)
|
||||
i -= 1
|
||||
def everythingReplace(tokens):
|
||||
for (i, token) in enumerate(tokens):
|
||||
if isinstance(token, list):
|
||||
if everythingReplace(token):
|
||||
return
|
||||
if token == '$*':
|
||||
tokens[i:i+1] = args
|
||||
return True
|
||||
elif '$*' in token:
|
||||
tokens[i] = token.replace('$*', ' '.join(args))
|
||||
return True
|
||||
return False
|
||||
everythingReplace(tokens)
|
||||
self.Proxy(irc, msg, tokens)
|
||||
doc =format('<an alias, %n>\n\nAlias for %q.',
|
||||
(biggestDollar, 'argument'), alias)
|
||||
f = utils.python.changeFunctionName(f, name, doc)
|
||||
return f
|
||||
|
||||
class Alias(callbacks.Plugin):
|
||||
def __init__(self, irc):
|
||||
self.__parent = super(Alias, self)
|
||||
self.__parent.__init__(irc)
|
||||
# Schema: {alias: [command, locked, commandMethod]}
|
||||
self.aliases = {}
|
||||
# XXX This should go. aliases should be a space separate list, etc.
|
||||
group = conf.supybot.plugins.Alias.aliases
|
||||
for (name, alias) in registry._cache.iteritems():
|
||||
name = name.lower()
|
||||
if name.startswith('supybot.plugins.alias.aliases.'):
|
||||
name = name[len('supybot.plugins.alias.aliases.'):]
|
||||
if '.' in name:
|
||||
continue
|
||||
conf.registerGlobalValue(group, name, registry.String('', ''))
|
||||
conf.registerGlobalValue(group.get(name), 'locked',
|
||||
registry.Boolean(False, ''))
|
||||
for (name, value) in group.getValues(fullNames=False):
|
||||
name = name.lower() # Just in case.
|
||||
command = value()
|
||||
locked = value.locked()
|
||||
self.aliases[name] = [command, locked, None]
|
||||
for (alias, (command, locked, _)) in self.aliases.items():
|
||||
try:
|
||||
self.addAlias(irc, alias, command, locked)
|
||||
except Exception, e:
|
||||
self.log.exception('Exception when trying to add alias %s. '
|
||||
'Removing from the Alias database.', alias)
|
||||
del self.aliases[alias]
|
||||
|
||||
def isCommandMethod(self, name):
|
||||
if not self.__parent.isCommandMethod(name):
|
||||
if name in self.aliases:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
def listCommands(self):
|
||||
commands = self.__parent.listCommands()
|
||||
commands.extend(self.aliases.keys())
|
||||
commands.sort()
|
||||
return commands
|
||||
|
||||
def getCommandMethod(self, command):
|
||||
try:
|
||||
return self.__parent.getCommandMethod(command)
|
||||
except AttributeError:
|
||||
return self.aliases[command[0]][2]
|
||||
|
||||
def lock(self, irc, msg, args, name):
|
||||
"""<alias>
|
||||
|
||||
Locks an alias so that no one else can change it.
|
||||
"""
|
||||
if hasattr(self, name) and self.isCommandMethod(name):
|
||||
self.aliases[name][1] = True
|
||||
conf.supybot.plugins.Alias.aliases.get(name).locked.setValue(True)
|
||||
irc.replySuccess()
|
||||
else:
|
||||
irc.error('There is no such alias.')
|
||||
lock = wrap(lock, [('checkCapability', 'admin'), 'commandName'])
|
||||
|
||||
def unlock(self, irc, msg, args, name):
|
||||
"""<alias>
|
||||
|
||||
Unlocks an alias so that people can define new aliases over it.
|
||||
"""
|
||||
if hasattr(self, name) and self.isCommandMethod(name):
|
||||
self.aliases[name][1] = False
|
||||
conf.supybot.plugins.Alias.aliases.get(name).locked.setValue(False)
|
||||
irc.replySuccess()
|
||||
else:
|
||||
irc.error('There is no such alias.')
|
||||
unlock = wrap(unlock, [('checkCapability', 'admin'), 'commandName'])
|
||||
|
||||
_invalidCharsRe = re.compile(r'[\[\]\s]')
|
||||
def addAlias(self, irc, name, alias, lock=False):
|
||||
if self._invalidCharsRe.search(name):
|
||||
raise AliasError, 'Names cannot contain spaces or square brackets.'
|
||||
if '|' in name:
|
||||
raise AliasError, 'Names cannot contain pipes.'
|
||||
realName = callbacks.canonicalName(name)
|
||||
if name != realName:
|
||||
s = format('That name isn\'t valid. Try %q instead.', realName)
|
||||
raise AliasError, s
|
||||
name = realName
|
||||
if self.isCommandMethod(name):
|
||||
if realName not in self.aliases:
|
||||
s = 'You can\'t overwrite commands in this plugin.'
|
||||
raise AliasError, s
|
||||
if name in self.aliases:
|
||||
(currentAlias, locked, _) = self.aliases[name]
|
||||
if locked and currentAlias != alias:
|
||||
raise AliasError, format('Alias %q is locked.', name)
|
||||
try:
|
||||
f = makeNewAlias(name, alias)
|
||||
f = new.instancemethod(f, self, Alias)
|
||||
except RecursiveAlias:
|
||||
raise AliasError, 'You can\'t define a recursive alias.'
|
||||
if name in self.aliases:
|
||||
# We gotta remove it so its value gets updated.
|
||||
conf.supybot.plugins.Alias.aliases.unregister(name)
|
||||
conf.supybot.plugins.Alias.aliases.register(name,
|
||||
registry.String(alias, ''))
|
||||
conf.supybot.plugins.Alias.aliases.get(name).register('locked',
|
||||
registry.Boolean(lock, ''))
|
||||
self.aliases[name] = [alias, lock, f]
|
||||
|
||||
def removeAlias(self, name, evenIfLocked=False):
|
||||
name = callbacks.canonicalName(name)
|
||||
if name in self.aliases and self.isCommandMethod(name):
|
||||
if evenIfLocked or not self.aliases[name][1]:
|
||||
del self.aliases[name]
|
||||
conf.supybot.plugins.Alias.aliases.unregister(name)
|
||||
else:
|
||||
raise AliasError, 'That alias is locked.'
|
||||
else:
|
||||
raise AliasError, 'There is no such alias.'
|
||||
|
||||
def add(self, irc, msg, args, name, alias):
|
||||
"""<name> <alias>
|
||||
|
||||
Defines an alias <name> that executes <alias>. The <alias>
|
||||
should be in the standard "command argument [nestedcommand argument]"
|
||||
arguments to the alias; they'll be filled with the first, second, etc.
|
||||
arguments. $1, $2, etc. can be used for required arguments. @1, @2,
|
||||
etc. can be used for optional arguments. $* simply means "all
|
||||
remaining arguments," and cannot be combined with optional arguments.
|
||||
"""
|
||||
if ' ' not in alias:
|
||||
# If it's a single word, they probably want $*.
|
||||
alias += ' $*'
|
||||
try:
|
||||
self.addAlias(irc, name, alias)
|
||||
self.log.info('Adding alias %q for %q (from %s)',
|
||||
name, alias, msg.prefix)
|
||||
irc.replySuccess()
|
||||
except AliasError, e:
|
||||
irc.error(str(e))
|
||||
add = wrap(add, ['commandName', 'text'])
|
||||
|
||||
def remove(self, irc, msg, args, name):
|
||||
"""<name>
|
||||
|
||||
Removes the given alias, if unlocked.
|
||||
"""
|
||||
try:
|
||||
self.removeAlias(name)
|
||||
self.log.info('Removing alias %q (from %s)', name, msg.prefix)
|
||||
irc.replySuccess()
|
||||
except AliasError, e:
|
||||
irc.error(str(e))
|
||||
remove = wrap(remove, ['commandName'])
|
||||
|
||||
|
||||
Class = Alias
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1,125 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2002-2004, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
from supybot.test import *
|
||||
|
||||
import supybot.plugin as plugin
|
||||
|
||||
Alias = plugin.loadPluginModule('Alias')
|
||||
|
||||
class FunctionsTest(SupyTestCase):
|
||||
def testFindBiggestDollar(self):
|
||||
self.assertEqual(Alias.findBiggestDollar(''), 0)
|
||||
self.assertEqual(Alias.findBiggestDollar('foo'), 0)
|
||||
self.assertEqual(Alias.findBiggestDollar('$0'), 0)
|
||||
self.assertEqual(Alias.findBiggestDollar('$1'), 1)
|
||||
self.assertEqual(Alias.findBiggestDollar('$2'), 2)
|
||||
self.assertEqual(Alias.findBiggestDollar('$2 $10'), 10)
|
||||
self.assertEqual(Alias.findBiggestDollar('$3'), 3)
|
||||
self.assertEqual(Alias.findBiggestDollar('$3 $2 $1'), 3)
|
||||
self.assertEqual(Alias.findBiggestDollar('foo bar $1'), 1)
|
||||
self.assertEqual(Alias.findBiggestDollar('foo $2 $1'), 2)
|
||||
self.assertEqual(Alias.findBiggestDollar('foo $0 $1'), 1)
|
||||
self.assertEqual(Alias.findBiggestDollar('foo $1 $3'), 3)
|
||||
self.assertEqual(Alias.findBiggestDollar('$10 bar $1'), 10)
|
||||
|
||||
|
||||
class AliasTestCase(ChannelPluginTestCase):
|
||||
plugins = ('Alias', 'Filter', 'Utilities', 'Format', 'Reply')
|
||||
def testNoAliasWithNestedCommandName(self):
|
||||
self.assertError('alias add foo "[bar] baz"')
|
||||
|
||||
def testDoesNotOverwriteCommands(self):
|
||||
# We don't have dispatcher commands anymore
|
||||
#self.assertError('alias add alias "echo foo bar baz"')
|
||||
self.assertError('alias add add "echo foo bar baz"')
|
||||
self.assertError('alias add remove "echo foo bar baz"')
|
||||
self.assertError('alias add lock "echo foo bar baz"')
|
||||
self.assertError('alias add unlock "echo foo bar baz"')
|
||||
|
||||
def testAliasHelp(self):
|
||||
self.assertNotError('alias add slashdot foo')
|
||||
self.assertRegexp('help slashdot', "Alias for .*foo")
|
||||
|
||||
def testRemove(self):
|
||||
self.assertNotError('alias add foo echo bar')
|
||||
self.assertResponse('foo', 'bar')
|
||||
self.assertNotError('alias remove foo')
|
||||
self.assertError('foo')
|
||||
|
||||
def testDollars(self):
|
||||
self.assertNotError('alias add rot26 "rot13 [rot13 $1]"')
|
||||
self.assertResponse('rot26 foobar', 'foobar')
|
||||
|
||||
def testMoreDollars(self):
|
||||
self.assertNotError('alias add rev "echo $3 $2 $1"')
|
||||
self.assertResponse('rev foo bar baz', 'baz bar foo')
|
||||
|
||||
def testAllArgs(self):
|
||||
self.assertNotError('alias add swap "echo $2 $1 $*"')
|
||||
self.assertResponse('swap 1 2 3 4 5', '2 1 3 4 5')
|
||||
self.assertError('alias add foo "echo $1 @1 $*"')
|
||||
|
||||
def testChannel(self):
|
||||
self.assertNotError('alias add channel echo $channel')
|
||||
self.assertResponse('alias channel', self.channel)
|
||||
|
||||
def testNick(self):
|
||||
self.assertNotError('alias add sendingnick "rot13 [rot13 $nick]"')
|
||||
self.assertResponse('sendingnick', self.nick)
|
||||
|
||||
def testAddRemoveAlias(self):
|
||||
cb = self.irc.getCallback('Alias')
|
||||
cb.addAlias(self.irc, 'foobar', 'echo sbbone', lock=True)
|
||||
self.assertResponse('foobar', 'sbbone')
|
||||
self.assertRaises(Alias.AliasError, cb.removeAlias, 'foobar')
|
||||
cb.removeAlias('foobar', evenIfLocked=True)
|
||||
self.failIf('foobar' in cb.aliases)
|
||||
self.assertError('foobar')
|
||||
|
||||
def testOptionalArgs(self):
|
||||
self.assertNotError('alias add myrepr "repr @1"')
|
||||
self.assertResponse('myrepr foo', '"foo"')
|
||||
self.assertResponse('myrepr ""', '""')
|
||||
|
||||
def testNoExtraSpaces(self):
|
||||
self.assertNotError('alias add foo "action takes $1\'s money"')
|
||||
self.assertResponse('foo bar', '\x01ACTION takes bar\'s money\x01')
|
||||
|
||||
def testNoExtraQuotes(self):
|
||||
self.assertNotError('alias add myre "echo s/$1/$2/g"')
|
||||
self.assertResponse('myre foo bar', 's/foo/bar/g')
|
||||
|
||||
def testSimpleAliasWithoutArgsImpliesDollarStar(self):
|
||||
self.assertNotError('alias add exo echo')
|
||||
self.assertResponse('exo foo bar baz', 'foo bar baz')
|
||||
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1 +0,0 @@
|
||||
Insert a description of your plugin here, with any notes, etc. about using it.
|
@ -1,61 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2005, Daniel DiPaolo
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
"""
|
||||
Allows folks to talk through the bot anonymously.
|
||||
"""
|
||||
|
||||
import supybot
|
||||
import supybot.world as world
|
||||
|
||||
# Use this for the version of this plugin. You may wish to put a CVS keyword
|
||||
# in here if you're keeping the plugin in CVS or some similar system.
|
||||
__version__ = "%%VERSION%%"
|
||||
|
||||
# XXX Replace this with an appropriate author or supybot.Author instance.
|
||||
__author__ = supybot.authors.strike
|
||||
|
||||
# This is a dictionary mapping supybot.Author instances to lists of
|
||||
# contributions.
|
||||
__contributors__ = {}
|
||||
|
||||
import config
|
||||
import plugin
|
||||
reload(plugin) # In case we're being reloaded.
|
||||
# Add more reloads here if you add third-party modules and want them to be
|
||||
# reloaded when this plugin is reloaded. Don't forget to import them as well!
|
||||
|
||||
if world.testing:
|
||||
import test
|
||||
|
||||
Class = plugin.Class
|
||||
configure = config.configure
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1,63 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2005, Daniel DiPaolo
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
import supybot.conf as conf
|
||||
import supybot.registry as registry
|
||||
|
||||
def configure(advanced):
|
||||
# This will be called by supybot to configure this module. advanced is
|
||||
# a bool that specifies whether the user identified himself as an advanced
|
||||
# user or not. You should effect your configuration by manipulating the
|
||||
# registry as appropriate.
|
||||
from supybot.questions import expect, anything, something, yn
|
||||
conf.registerPlugin('Anonymous', True)
|
||||
|
||||
|
||||
Anonymous = conf.registerPlugin('Anonymous')
|
||||
# This is where your configuration variables (if any) should go. For example:
|
||||
# conf.registerGlobalValue(Anonymous, 'someConfigVariableName',
|
||||
# registry.Boolean(False, """Help for someConfigVariableName."""))
|
||||
conf.registerChannelValue(conf.supybot.plugins.Anonymous,
|
||||
'requirePresenceInChannel', registry.Boolean(True, """Determines whether
|
||||
the bot should require people trying to use this plugin to be in the
|
||||
channel they wish to anonymously send to."""))
|
||||
conf.registerGlobalValue(conf.supybot.plugins.Anonymous, 'requireRegistration',
|
||||
registry.Boolean(True, """Determines whether the bot should require people
|
||||
trying to use this plugin to be registered."""))
|
||||
conf.registerGlobalValue(conf.supybot.plugins.Anonymous, 'requireCapability',
|
||||
registry.String('', """Determines what capability (if any) the bot should
|
||||
require people trying to use this plugin to have."""))
|
||||
conf.registerGlobalValue(conf.supybot.plugins.Anonymous, 'allowPrivateTarget',
|
||||
registry.Boolean(False, """Determines whether the bot will require targets
|
||||
of the "say" command to be public (i.e., channels). If this is True, the
|
||||
bot will allow people to use the "say" command to send private messages to
|
||||
other users."""))
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1,96 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2005, Daniel DiPaolo
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
import supybot.ircdb as ircdb
|
||||
import supybot.utils as utils
|
||||
from supybot.commands import *
|
||||
import supybot.ircmsgs as ircmsgs
|
||||
import supybot.callbacks as callbacks
|
||||
|
||||
class Anonymous(callbacks.Plugin):
|
||||
"""This plugin allows users to act through the bot anonymously. The 'do'
|
||||
command has the bot perform an anonymous action in a given channel, and
|
||||
the 'say' command allows other people to speak through the bot. Since
|
||||
this can be fairly well abused, you might want to set
|
||||
supybot.plugins.Anonymous.requireCapability so only users with that
|
||||
capability can use this plugin. For extra security, you can require that
|
||||
the user be *in* the channel they are trying to address anonymously with
|
||||
supybot.plugins.Anonymous.requirePresenceInChannel, or you can require
|
||||
that the user be registered by setting
|
||||
supybot.plugins.Anonymous.requireRegistration.
|
||||
"""
|
||||
def _preCheck(self, irc, msg, channel):
|
||||
if self.registryValue('requireRegistration'):
|
||||
try:
|
||||
_ = ircdb.users.getUser(msg.prefix)
|
||||
except KeyError:
|
||||
irc.errorNotRegistered(Raise=True)
|
||||
capability = self.registryValue('requireCapability')
|
||||
if capability:
|
||||
if not ircdb.checkCapability(msg.prefix, capability):
|
||||
irc.errorNoCapability(capability, Raise=True)
|
||||
if self.registryValue('requirePresenceInChannel', channel) and \
|
||||
msg.nick not in irc.state.channels[channel].users:
|
||||
irc.error(format('You must be in %s to %q in there.',
|
||||
channel, 'say'), Raise=True)
|
||||
c = ircdb.channels.getChannel(channel)
|
||||
if c.lobotomized:
|
||||
irc.error(format('I\'m lobotomized in %s.', channel), Raise=True)
|
||||
if not c._checkCapability(self.name()):
|
||||
irc.error('That channel has set its capabilities so as to '
|
||||
'disallow the use of this plugin.', Raise=True)
|
||||
|
||||
def say(self, irc, msg, args, channel, text):
|
||||
"""<channel> <text>
|
||||
|
||||
Sends <text> to <channel>.
|
||||
"""
|
||||
self._preCheck(irc, msg, channel)
|
||||
self.log.info('Saying %q in %s due to %s.',
|
||||
text, channel, msg.prefix)
|
||||
irc.queueMsg(ircmsgs.privmsg(channel, text))
|
||||
irc.noReply()
|
||||
say = wrap(say, ['inChannel', 'text'])
|
||||
|
||||
def do(self, irc, msg, args, channel, text):
|
||||
"""<channel> <action>
|
||||
|
||||
Performs <action> in <channel>.
|
||||
"""
|
||||
self._preCheck(irc, msg, channel)
|
||||
self.log.info('Performing %q in %s due to %s.',
|
||||
text, channel, msg.prefix)
|
||||
irc.queueMsg(ircmsgs.action(channel, text))
|
||||
irc.noReply()
|
||||
do = wrap(do, ['inChannel', 'text'])
|
||||
|
||||
Class = Anonymous
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1,56 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2005, Daniel DiPaolo
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
from supybot.test import *
|
||||
|
||||
class AnonymousTestCase(ChannelPluginTestCase):
|
||||
plugins = ('Anonymous',)
|
||||
def testSay(self):
|
||||
m = self.assertError('anonymous say %s I love you!' % self.channel)
|
||||
try:
|
||||
orig = conf.supybot.plugins.Anonymous.requireRegistration()
|
||||
conf.supybot.plugins.Anonymous.requireRegistration.setValue(False)
|
||||
m = self.assertNotError('anonymous say %s foo!'%self.channel)
|
||||
self.failUnless(m.args[1] == 'foo!')
|
||||
finally:
|
||||
conf.supybot.plugins.Anonymous.requireRegistration.setValue(orig)
|
||||
|
||||
def testAction(self):
|
||||
m = self.assertError('anonymous do %s loves you!' % self.channel)
|
||||
try:
|
||||
orig = conf.supybot.plugins.Anonymous.requireRegistration()
|
||||
conf.supybot.plugins.Anonymous.requireRegistration.setValue(False)
|
||||
m = self.assertNotError('anonymous do %s loves you!'%self.channel)
|
||||
self.assertEqual(m.args, ircmsgs.action(self.channel,
|
||||
'loves you!').args)
|
||||
finally:
|
||||
conf.supybot.plugins.Anonymous.requireRegistration.setValue(orig)
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1 +0,0 @@
|
||||
Insert a description of your plugin here, with any notes, etc. about using it.
|
@ -1,62 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2005, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
"""
|
||||
Automatically ops, voices, or halfops, or bans people when they join a channel,
|
||||
according to their capabilities. If you want your bot automatically op users
|
||||
when they join your channel, this is the plugin to load.
|
||||
"""
|
||||
|
||||
import supybot
|
||||
import supybot.world as world
|
||||
|
||||
# Use this for the version of this plugin. You may wish to put a CVS keyword
|
||||
# in here if you're keeping the plugin in CVS or some similar system.
|
||||
__version__ = "%%VERSION%%"
|
||||
|
||||
__author__ = supybot.authors.jemfinch
|
||||
|
||||
# This is a dictionary mapping supybot.Author instances to lists of
|
||||
# contributions.
|
||||
__contributors__ = {}
|
||||
|
||||
import config
|
||||
import plugin
|
||||
reload(plugin) # In case we're being reloaded.
|
||||
# Add more reloads here if you add third-party modules and want them to be
|
||||
# reloaded when this plugin is reloaded. Don't forget to import them as well!
|
||||
|
||||
if world.testing:
|
||||
import test
|
||||
|
||||
Class = plugin.Class
|
||||
configure = config.configure
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1,69 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2005, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
import supybot.conf as conf
|
||||
import supybot.registry as registry
|
||||
|
||||
def configure(advanced):
|
||||
# This will be called by supybot to configure this module. advanced is
|
||||
# a bool that specifies whether the user identified himself as an advanced
|
||||
# user or not. You should effect your configuration by manipulating the
|
||||
# registry as appropriate.
|
||||
from supybot.questions import expect, anything, something, yn
|
||||
conf.registerPlugin('AutoMode', True)
|
||||
|
||||
|
||||
AutoMode = conf.registerPlugin('AutoMode')
|
||||
conf.registerChannelValue(AutoMode, 'enable',
|
||||
registry.Boolean(True, """Determines whether this plugin is enabled."""))
|
||||
conf.registerChannelValue(AutoMode, 'fallthrough',
|
||||
registry.Boolean(False, """Determines whether the bot will "fall through" to
|
||||
halfop/voicing when auto-opping is turned off but auto-halfopping/voicing
|
||||
are turned on."""))
|
||||
conf.registerChannelValue(AutoMode, 'op',
|
||||
registry.Boolean(True, """Determines whether the bot will automatically op
|
||||
people with the <channel>,op capability when they join the channel."""))
|
||||
conf.registerChannelValue(AutoMode, 'halfop',
|
||||
registry.Boolean(True, """Determines whether the bot will automatically
|
||||
halfop people with the <channel>,halfop capability when they join the
|
||||
channel."""))
|
||||
conf.registerChannelValue(AutoMode, 'voice',
|
||||
registry.Boolean(True, """Determines whether the bot will automatically
|
||||
voice people with the <channel>,voice capability when they join the
|
||||
channel."""))
|
||||
conf.registerChannelValue(AutoMode, 'ban',
|
||||
registry.Boolean(True, """Determines whether the bot will automatically ban
|
||||
people who join the channel and are on the banlist."""))
|
||||
conf.registerChannelValue(AutoMode.ban, 'period',
|
||||
registry.PositiveInteger(86400, """Determines how many seconds the bot will
|
||||
automatically ban a person when banning."""))
|
||||
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1,88 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2004, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
import time
|
||||
|
||||
import supybot.ircdb as ircdb
|
||||
import supybot.ircmsgs as ircmsgs
|
||||
import supybot.ircutils as ircutils
|
||||
import supybot.schedule as schedule
|
||||
import supybot.callbacks as callbacks
|
||||
|
||||
class Continue(Exception):
|
||||
pass # Used below, look in the "do" function nested in doJoin.
|
||||
|
||||
class AutoMode(callbacks.Plugin):
|
||||
def doJoin(self, irc, msg):
|
||||
channel = msg.args[0]
|
||||
if ircutils.strEqual(irc.nick, msg.nick):
|
||||
return
|
||||
if not self.registryValue('enable', channel):
|
||||
return
|
||||
fallthrough = self.registryValue('fallthrough', channel)
|
||||
def do(type):
|
||||
cap = ircdb.makeChannelCapability(channel, type)
|
||||
if ircdb.checkCapability(msg.prefix, cap):
|
||||
if self.registryValue(type, channel):
|
||||
self.log.info('Sending auto-%s of %s in %s.',
|
||||
type, msg.prefix, channel)
|
||||
msgmaker = getattr(ircmsgs, type)
|
||||
irc.queueMsg(msgmaker(channel, msg.nick))
|
||||
raise Continue # Even if fallthrough, let's only do one.
|
||||
elif not fallthrough:
|
||||
self.log.debug('%s has %s, but supybot.plugins.AutoMode.%s'
|
||||
' is not enabled in %s, refusing to fall '
|
||||
'through.', msg.prefix, cap, type, channel)
|
||||
raise Continue
|
||||
try:
|
||||
do('op')
|
||||
if 'h' in irc.state.supported['prefix']:
|
||||
do('halfop')
|
||||
do('voice')
|
||||
except Continue:
|
||||
return
|
||||
c = ircdb.channels.getChannel(channel)
|
||||
if c.checkBan(msg.prefix) and self.registryValue('ban', channel):
|
||||
period = self.registryValue('ban.period', channel)
|
||||
if period:
|
||||
def unban():
|
||||
try:
|
||||
if msg.prefix in irc.state.channels[channel].bans:
|
||||
irc.queueMsg(ircmsgs.unban(channel, msg.prefix))
|
||||
except KeyError:
|
||||
# We're not in the channel anymore.
|
||||
pass
|
||||
schedule.addEvent(unban, time.time()+period)
|
||||
irc.queueMsg(ircmsgs.ban(channel, msg.prefix))
|
||||
irc.queueMsg(ircmsgs.kick(channel, msg.nick))
|
||||
|
||||
|
||||
Class = AutoMode
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1,36 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2005, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
from supybot.test import *
|
||||
|
||||
class AutoModeTestCase(PluginTestCase):
|
||||
plugins = ('AutoMode',)
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1,58 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2004-2005, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
"""
|
||||
Basic channel management commands. Many of these commands require their caller
|
||||
to have the <channel>.op capability. This plugin is loaded by default.
|
||||
"""
|
||||
|
||||
import supybot
|
||||
import supybot.world as world
|
||||
|
||||
# Use this for the version of this plugin. You may wish to put a CVS keyword
|
||||
# in here if you\'re keeping the plugin in CVS or some similar system.
|
||||
__version__ = "%%VERSION%%"
|
||||
|
||||
__author__ = supybot.authors.jemfinch
|
||||
|
||||
# This is a dictionary mapping supybot.Author instances to lists of
|
||||
# contributions.
|
||||
__contributors__ = {
|
||||
supybot.authors.skorobeus: ['enable', 'disable'],
|
||||
}
|
||||
|
||||
import config
|
||||
import plugin
|
||||
reload(plugin) # In case we're being reloaded.
|
||||
|
||||
if world.testing:
|
||||
import test
|
||||
|
||||
Class = plugin.Class
|
||||
configure = config.configure
|
@ -1,81 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2004-2005, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
|
||||
import supybot.conf as conf
|
||||
import supybot.utils as utils
|
||||
import supybot.registry as registry
|
||||
|
||||
def configure(advanced):
|
||||
# This will be called by supybot to configure this module. advanced is
|
||||
# a bool that specifies whether the user identified himself as an advanced
|
||||
# user or not. You should effect your configuration by manipulating the
|
||||
# registry as appropriate.
|
||||
from supybot.questions import expect, anything, something, yn
|
||||
conf.registerPlugin('Channel', True)
|
||||
|
||||
class BanmaskStyle(registry.SpaceSeparatedSetOfStrings):
|
||||
validStrings = ('exact', 'nick', 'user', 'host')
|
||||
def __init__(self, *args, **kwargs):
|
||||
assert self.validStrings, 'There must be some valid strings. ' \
|
||||
'This is a bug.'
|
||||
registry.SpaceSeparatedSetOfStrings.__init__(self, *args, **kwargs)
|
||||
self.__doc__ = format('Valid values include %L.',
|
||||
map(repr, self.validStrings))
|
||||
|
||||
def help(self):
|
||||
strings = [s for s in self.validStrings if s]
|
||||
return format('%s Valid strings: %L.', self._help, strings)
|
||||
|
||||
def normalize(self, s):
|
||||
lowered = s.lower()
|
||||
L = list(map(str.lower, self.validStrings))
|
||||
try:
|
||||
i = L.index(lowered)
|
||||
except ValueError:
|
||||
return s # This is handled in setValue.
|
||||
return self.validStrings[i]
|
||||
|
||||
def setValue(self, v):
|
||||
v = map(self.normalize, v)
|
||||
for s in v:
|
||||
if s not in self.validStrings:
|
||||
self.error()
|
||||
registry.SpaceSeparatedSetOfStrings.setValue(self, self.List(v))
|
||||
|
||||
Channel = conf.registerPlugin('Channel')
|
||||
conf.registerChannelValue(Channel, 'alwaysRejoin',
|
||||
registry.Boolean(True, """Determines whether the bot will always try to
|
||||
rejoin a channel whenever it's kicked from the channel."""))
|
||||
conf.registerChannelValue(Channel, 'banmask',
|
||||
BanmaskStyle(['user', 'host'], """Determines what will be used as the
|
||||
default banmask style."""))
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1,811 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2002-2005, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
import sys
|
||||
|
||||
import supybot.conf as conf
|
||||
import supybot.ircdb as ircdb
|
||||
import supybot.utils as utils
|
||||
from supybot.commands import *
|
||||
import supybot.ircmsgs as ircmsgs
|
||||
import supybot.schedule as schedule
|
||||
import supybot.ircutils as ircutils
|
||||
import supybot.callbacks as callbacks
|
||||
|
||||
class Channel(callbacks.Plugin):
|
||||
def __init__(self, irc):
|
||||
self.__parent = super(Channel, self)
|
||||
self.__parent.__init__(irc)
|
||||
self.invites = {}
|
||||
|
||||
def doKick(self, irc, msg):
|
||||
channel = msg.args[0]
|
||||
if msg.args[1] == irc.nick:
|
||||
if self.registryValue('alwaysRejoin', channel):
|
||||
networkGroup = conf.supybot.networks.get(irc.network)
|
||||
irc.sendMsg(networkGroup.channels.join(channel))
|
||||
|
||||
def _sendMsg(self, irc, msg):
|
||||
irc.queueMsg(msg)
|
||||
irc.noReply()
|
||||
|
||||
def mode(self, irc, msg, args, channel, modes):
|
||||
"""[<channel>] <mode> [<arg> ...]
|
||||
|
||||
Sets the mode in <channel> to <mode>, sending the arguments given.
|
||||
<channel> is only necessary if the message isn't sent in the channel
|
||||
itself.
|
||||
"""
|
||||
self._sendMsg(irc, ircmsgs.mode(channel, modes))
|
||||
mode = wrap(mode, ['op', ('haveOp', 'change the mode'), many('something')])
|
||||
|
||||
def limit(self, irc, msg, args, channel, limit):
|
||||
"""[<channel>] [<limit>]
|
||||
|
||||
Sets the channel limit to <limit>. If <limit> is 0, or isn't given,
|
||||
removes the channel limit. <channel> is only necessary if the message
|
||||
isn't sent in the channel itself.
|
||||
"""
|
||||
if limit:
|
||||
self._sendMsg(irc, ircmsgs.mode(channel, ['+l', limit]))
|
||||
else:
|
||||
self._sendMsg(irc, ircmsgs.mode(channel, ['-l']))
|
||||
limit = wrap(limit, ['op', ('haveOp', 'change the limit'),
|
||||
additional('nonNegativeInt', 0)])
|
||||
|
||||
def moderate(self, irc, msg, args, channel):
|
||||
"""[<channel>]
|
||||
|
||||
Sets +m on <channel>, making it so only ops and voiced users can
|
||||
send messages to the channel. <channel> is only necessary if the
|
||||
message isn't sent in the channel itself.
|
||||
"""
|
||||
self._sendMsg(irc, ircmsgs.mode(channel, ['+m']))
|
||||
moderate = wrap(moderate, ['op', ('haveOp', 'moderate the channel')])
|
||||
|
||||
def unmoderate(self, irc, msg, args, channel):
|
||||
"""[<channel>]
|
||||
|
||||
Sets -m on <channel>, making it so everyone can
|
||||
send messages to the channel. <channel> is only necessary if the
|
||||
message isn't sent in the channel itself.
|
||||
"""
|
||||
self._sendMsg(irc, ircmsgs.mode(channel, ['-m']))
|
||||
unmoderate = wrap(unmoderate, ['op', ('haveOp', 'unmoderate the channel')])
|
||||
|
||||
def key(self, irc, msg, args, channel, key):
|
||||
"""[<channel>] [<key>]
|
||||
|
||||
Sets the keyword in <channel> to <key>. If <key> is not given, removes
|
||||
the keyword requirement to join <channel>. <channel> is only necessary
|
||||
if the message isn't sent in the channel itself.
|
||||
"""
|
||||
networkGroup = conf.supybot.networks.get(irc.network)
|
||||
networkGroup.channels.key.get(channel).setValue(key)
|
||||
if key:
|
||||
self._sendMsg(irc, ircmsgs.mode(channel, ['+k', key]))
|
||||
else:
|
||||
self._sendMsg(irc, ircmsgs.mode(channel, ['-k']))
|
||||
key = wrap(key, ['op', ('haveOp', 'change the keyword'),
|
||||
additional('somethingWithoutSpaces', '')])
|
||||
|
||||
def op(self, irc, msg, args, channel, nicks):
|
||||
"""[<channel>] [<nick> ...]
|
||||
|
||||
If you have the #channel,op capability, this will give all the <nick>s
|
||||
you provide ops. If you don't provide any <nick>s, this will op you.
|
||||
<channel> is only necessary if the message isn't sent in the channel
|
||||
itself.
|
||||
"""
|
||||
if not nicks:
|
||||
nicks = [msg.nick]
|
||||
self._sendMsg(irc, ircmsgs.ops(channel, nicks))
|
||||
op = wrap(op, ['op', ('haveOp', 'op someone'), any('nickInChannel')])
|
||||
|
||||
def halfop(self, irc, msg, args, channel, nicks):
|
||||
"""[<channel>] [<nick> ...]
|
||||
|
||||
If you have the #channel,halfop capability, this will give all the
|
||||
<nick>s you provide halfops. If you don't provide any <nick>s, this
|
||||
will give you halfops. <channel> is only necessary if the message isn't
|
||||
sent in the channel itself.
|
||||
"""
|
||||
if not nicks:
|
||||
nicks = [msg.nick]
|
||||
self._sendMsg(irc, ircmsgs.halfops(channel, nicks))
|
||||
halfop = wrap(halfop, ['halfop', ('haveOp', 'halfop someone'),
|
||||
any('nickInChannel')])
|
||||
|
||||
def voice(self, irc, msg, args, channel, nicks):
|
||||
"""[<channel>] [<nick> ...]
|
||||
|
||||
If you have the #channel,voice capability, this will voice all the
|
||||
<nick>s you provide. If you don't provide any <nick>s, this will
|
||||
voice you. <channel> is only necessary if the message isn't sent in the
|
||||
channel itself.
|
||||
"""
|
||||
if nicks:
|
||||
if len(nicks) == 1 and msg.nick in nicks:
|
||||
capability = 'voice'
|
||||
else:
|
||||
capability = 'op'
|
||||
else:
|
||||
nicks = [msg.nick]
|
||||
capability = 'voice'
|
||||
capability = ircdb.makeChannelCapability(channel, capability)
|
||||
if ircdb.checkCapability(msg.prefix, capability):
|
||||
self._sendMsg(irc, ircmsgs.voices(channel, nicks))
|
||||
else:
|
||||
irc.errorNoCapability(capability)
|
||||
voice = wrap(voice, ['channel', ('haveOp', 'voice someone'),
|
||||
any('nickInChannel')])
|
||||
|
||||
def deop(self, irc, msg, args, channel, nicks):
|
||||
"""[<channel>] [<nick> ...]
|
||||
|
||||
If you have the #channel,op capability, this will remove operator
|
||||
privileges from all the nicks given. If no nicks are given, removes
|
||||
operator privileges from the person sending the message.
|
||||
"""
|
||||
if irc.nick in nicks:
|
||||
irc.error('I cowardly refuse to deop myself. If you really want '
|
||||
'me deopped, tell me to op you and then deop me '
|
||||
'yourself.', Raise=True)
|
||||
if not nicks:
|
||||
nicks = [msg.nick]
|
||||
self._sendMsg(irc, ircmsgs.deops(channel, nicks))
|
||||
deop = wrap(deop, ['op', ('haveOp', 'deop someone'),
|
||||
any('nickInChannel')])
|
||||
|
||||
def dehalfop(self, irc, msg, args, channel, nicks):
|
||||
"""[<channel>] [<nick> ...]
|
||||
|
||||
If you have the #channel,op capability, this will remove half-operator
|
||||
privileges from all the nicks given. If no nicks are given, removes
|
||||
half-operator privileges from the person sending the message.
|
||||
"""
|
||||
if irc.nick in nicks:
|
||||
irc.error('I cowardly refuse to dehalfop myself. If you really '
|
||||
'want me dehalfopped, tell me to op you and then '
|
||||
'dehalfop me yourself.', Raise=True)
|
||||
if not nicks:
|
||||
nicks = [msg.nick]
|
||||
self._sendMsg(irc, ircmsgs.dehalfops(channel, nicks))
|
||||
dehalfop = wrap(dehalfop, ['halfop', ('haveOp', 'dehalfop someone'),
|
||||
any('nickInChannel')])
|
||||
|
||||
# XXX We should respect the MODES part of an 005 here. Helper function
|
||||
# material.
|
||||
def devoice(self, irc, msg, args, channel, nicks):
|
||||
"""[<channel>] [<nick> ...]
|
||||
|
||||
If you have the #channel,op capability, this will remove voice from all
|
||||
the nicks given. If no nicks are given, removes voice from the person
|
||||
sending the message.
|
||||
"""
|
||||
if irc.nick in nicks:
|
||||
irc.error('I cowardly refuse to devoice myself. If you really '
|
||||
'want me devoiced, tell me to op you and then devoice '
|
||||
'me yourself.', Raise=True)
|
||||
if not nicks:
|
||||
nicks = [msg.nick]
|
||||
self._sendMsg(irc, ircmsgs.devoices(channel, nicks))
|
||||
devoice = wrap(devoice, ['voice', ('haveOp', 'devoice someone'),
|
||||
any('nickInChannel')])
|
||||
|
||||
def cycle(self, irc, msg, args, channel):
|
||||
"""[<channel>]
|
||||
|
||||
If you have the #channel,op capability, this will cause the bot to
|
||||
"cycle", or PART and then JOIN the channel. <channel> is only necessary
|
||||
if the message isn't sent in the channel itself.
|
||||
"""
|
||||
self._sendMsg(irc, ircmsgs.part(channel, msg.nick))
|
||||
networkGroup = conf.supybot.networks.get(irc.network)
|
||||
self._sendMsg(irc, networkGroup.channels.join(channel))
|
||||
cycle = wrap(cycle, ['op'])
|
||||
|
||||
def kick(self, irc, msg, args, channel, nick, reason):
|
||||
"""[<channel>] <nick> [<reason>]
|
||||
|
||||
Kicks <nick> from <channel> for <reason>. If <reason> isn't given,
|
||||
uses the nick of the person making the command as the reason.
|
||||
<channel> is only necessary if the message isn't sent in the channel
|
||||
itself.
|
||||
"""
|
||||
if ircutils.strEqual(nick, irc.nick):
|
||||
irc.error('I cowardly refuse to kick myself.', Raise=True)
|
||||
if not reason:
|
||||
reason = msg.nick
|
||||
kicklen = irc.state.supported.get('kicklen', sys.maxint)
|
||||
if len(reason) > kicklen:
|
||||
irc.error('The reason you gave is longer than the allowed '
|
||||
'length for a KICK reason on this server.')
|
||||
return
|
||||
self._sendMsg(irc, ircmsgs.kick(channel, nick, reason))
|
||||
kick = wrap(kick, ['op', ('haveOp', 'kick someone'),
|
||||
'nickInChannel', additional('text')])
|
||||
|
||||
def kban(self, irc, msg, args,
|
||||
channel, optlist, bannedNick, expiry, reason):
|
||||
"""[<channel>] [--{exact,nick,user,host}] <nick> [<seconds>] [<reason>]
|
||||
|
||||
If you have the #channel,op capability, this will kickban <nick> for
|
||||
as many seconds as you specify, or else (if you specify 0 seconds or
|
||||
don't specify a number of seconds) it will ban the person indefinitely.
|
||||
--exact bans only the exact hostmask; --nick bans just the nick;
|
||||
--user bans just the user, and --host bans just the host. You can
|
||||
combine these options as you choose. <reason> is a reason to give for
|
||||
the kick.
|
||||
<channel> is only necessary if the message isn't sent in the channel
|
||||
itself.
|
||||
"""
|
||||
# Check that they're not trying to make us kickban ourself.
|
||||
self.log.debug('In kban')
|
||||
if not irc.isNick(bannedNick):
|
||||
self.log.warning('%q tried to kban a non nick: %q',
|
||||
msg.prefix, bannedNick)
|
||||
raise callbacks.ArgumentError
|
||||
elif bannedNick == irc.nick:
|
||||
self.log.warning('%q tried to make me kban myself.', msg.prefix)
|
||||
irc.error('I cowardly refuse to kickban myself.')
|
||||
return
|
||||
if not reason:
|
||||
reason = msg.nick
|
||||
try:
|
||||
bannedHostmask = irc.state.nickToHostmask(bannedNick)
|
||||
except KeyError:
|
||||
irc.error(format('I haven\'t seen %s.', bannedNick), Raise=True)
|
||||
capability = ircdb.makeChannelCapability(channel, 'op')
|
||||
def makeBanmask(bannedHostmask, options):
|
||||
(nick, user, host) = ircutils.splitHostmask(bannedHostmask)
|
||||
self.log.debug('*** nick: %s', nick)
|
||||
self.log.debug('*** user: %s', user)
|
||||
self.log.debug('*** host: %s', host)
|
||||
bnick = '*'
|
||||
buser = '*'
|
||||
bhost = '*'
|
||||
for option in options:
|
||||
if option == 'nick':
|
||||
bnick = nick
|
||||
elif option == 'user':
|
||||
buser = user
|
||||
elif option == 'host':
|
||||
bhost = host
|
||||
elif option == 'exact':
|
||||
(bnick, buser, bhost) = \
|
||||
ircutils.splitHostmask(bannedHostmask)
|
||||
return ircutils.joinHostmask(bnick, buser, bhost)
|
||||
if optlist:
|
||||
banmask = makeBanmask(bannedHostmask, [o[0] for o in optlist])
|
||||
else:
|
||||
banmask = makeBanmask(bannedHostmask,
|
||||
self.registryValue('banmask', channel))
|
||||
# Check (again) that they're not trying to make us kickban ourself.
|
||||
if ircutils.hostmaskPatternEqual(banmask, irc.prefix):
|
||||
if ircutils.hostmaskPatternEqual(banmask, irc.prefix):
|
||||
self.log.warning('%q tried to make me kban myself.',msg.prefix)
|
||||
irc.error('I cowardly refuse to ban myself.')
|
||||
return
|
||||
else:
|
||||
banmask = bannedHostmask
|
||||
# Now, let's actually get to it. Check to make sure they have
|
||||
# #channel,op and the bannee doesn't have #channel,op; or that the
|
||||
# bannee and the banner are both the same person.
|
||||
def doBan():
|
||||
if irc.state.channels[channel].isOp(bannedNick):
|
||||
irc.queueMsg(ircmsgs.deop(channel, bannedNick))
|
||||
irc.queueMsg(ircmsgs.ban(channel, banmask))
|
||||
irc.queueMsg(ircmsgs.kick(channel, bannedNick, reason))
|
||||
if expiry > 0:
|
||||
def f():
|
||||
if channel in irc.state.channels and \
|
||||
banmask in irc.state.channels[channel].bans:
|
||||
irc.queueMsg(ircmsgs.unban(channel, banmask))
|
||||
schedule.addEvent(f, expiry)
|
||||
if bannedNick == msg.nick:
|
||||
doBan()
|
||||
elif ircdb.checkCapability(msg.prefix, capability):
|
||||
if ircdb.checkCapability(bannedHostmask, capability):
|
||||
self.log.warning('%s tried to ban %q, but both have %s',
|
||||
msg.prefix, bannedHostmask, capability)
|
||||
irc.error(format('%s has %s too, you can\'t ban him/her/it.',
|
||||
bannedNick, capability))
|
||||
else:
|
||||
doBan()
|
||||
else:
|
||||
self.log.warning('%q attempted kban without %s',
|
||||
msg.prefix, capability)
|
||||
irc.errorNoCapability(capability)
|
||||
exact,nick,user,host
|
||||
kban = wrap(kban,
|
||||
['op',
|
||||
getopts({'exact':'', 'nick':'', 'user':'', 'host':''}),
|
||||
('haveOp', 'kick or ban someone'),
|
||||
'nickInChannel',
|
||||
optional('expiry', 0),
|
||||
additional('text')])
|
||||
|
||||
def unban(self, irc, msg, args, channel, hostmask):
|
||||
"""[<channel>] [<hostmask>]
|
||||
|
||||
Unbans <hostmask> on <channel>. If <hostmask> is not given, unbans
|
||||
any hostmask currently banned on <channel> that matches your current
|
||||
hostmask. Especially useful for unbanning yourself when you get
|
||||
unexpectedly (or accidentally) banned from the channel. <channel> is
|
||||
only necessary if the message isn't sent in the channel itself.
|
||||
"""
|
||||
if hostmask:
|
||||
self._sendMsg(irc, ircmsgs.unban(channel, hostmask))
|
||||
else:
|
||||
bans = []
|
||||
for banmask in irc.state.channels[channel].bans:
|
||||
if ircutils.hostmaskPatternEqual(banmask, msg.prefix):
|
||||
bans.append(banmask)
|
||||
if bans:
|
||||
irc.queueMsg(ircmsgs.unbans(channel, bans))
|
||||
irc.replySuccess(format('All bans on %s matching %s '
|
||||
'have been removed.',
|
||||
channel, msg.prefix))
|
||||
else:
|
||||
irc.error('No bans matching %s were found on %s.' %
|
||||
(msg.prefix, channel))
|
||||
unban = wrap(unban, ['op',
|
||||
('haveOp', 'unban someone'),
|
||||
additional('hostmask')])
|
||||
|
||||
def invite(self, irc, msg, args, channel, nick):
|
||||
"""[<channel>] <nick>
|
||||
|
||||
If you have the #channel,op capability, this will invite <nick>
|
||||
to join <channel>. <channel> is only necessary if the message isn't
|
||||
sent in the channel itself.
|
||||
"""
|
||||
nick = nick or msg.nick
|
||||
self._sendMsg(irc, ircmsgs.invite(nick, channel))
|
||||
self.invites[(irc.getRealIrc(), ircutils.toLower(nick))] = irc
|
||||
invite = wrap(invite, ['op', ('haveOp', 'invite someone'),
|
||||
additional('nick')])
|
||||
|
||||
def do341(self, irc, msg):
|
||||
(_, nick, channel) = msg.args
|
||||
nick = ircutils.toLower(nick)
|
||||
replyIrc = self.invites.pop((irc, nick), None)
|
||||
if replyIrc is not None:
|
||||
self.log.info('Inviting %s to %s by command of %s.',
|
||||
nick, channel, replyIrc.msg.prefix)
|
||||
replyIrc.replySuccess()
|
||||
else:
|
||||
self.log.info('Inviting %s to %s.', nick, channel)
|
||||
|
||||
def do443(self, irc, msg):
|
||||
(_, nick, channel, _) = msg.args
|
||||
nick = ircutils.toLower(nick)
|
||||
replyIrc = self.invites.pop((irc, nick), None)
|
||||
if replyIrc is not None:
|
||||
replyIrc.error(format('%s is already in %s.', nick, channel))
|
||||
|
||||
def do401(self, irc, msg):
|
||||
nick = msg.args[1]
|
||||
nick = ircutils.toLower(nick)
|
||||
replyIrc = self.invites.pop((irc, nick), None)
|
||||
if replyIrc is not None:
|
||||
replyIrc.error(format('There is no %s on this network.', nick))
|
||||
|
||||
def do504(self, irc, msg):
|
||||
nick = msg.args[1]
|
||||
nick = ircutils.toLower(nick)
|
||||
replyIrc = self.invites.pop((irc, nick), None)
|
||||
if replyirc is not None:
|
||||
replyIrc.error(format('There is no %s on this server.', nick))
|
||||
|
||||
class lobotomy(callbacks.Commands):
|
||||
def add(self, irc, msg, args, channel):
|
||||
"""[<channel>]
|
||||
|
||||
If you have the #channel,op capability, this will "lobotomize" the
|
||||
bot, making it silent and unanswering to all requests made in the
|
||||
channel. <channel> is only necessary if the message isn't sent in
|
||||
the channel itself.
|
||||
"""
|
||||
c = ircdb.channels.getChannel(channel)
|
||||
c.lobotomized = True
|
||||
ircdb.channels.setChannel(channel, c)
|
||||
irc.replySuccess()
|
||||
add = wrap(add, ['op'])
|
||||
|
||||
def remove(self, irc, msg, args, channel):
|
||||
"""[<channel>]
|
||||
|
||||
If you have the #channel,op capability, this will unlobotomize the
|
||||
bot, making it respond to requests made in the channel again.
|
||||
<channel> is only necessary if the message isn't sent in the channel
|
||||
itself.
|
||||
"""
|
||||
c = ircdb.channels.getChannel(channel)
|
||||
c.lobotomized = False
|
||||
ircdb.channels.setChannel(channel, c)
|
||||
irc.replySuccess()
|
||||
remove = wrap(remove, ['op'])
|
||||
|
||||
def list(self, irc, msg, args):
|
||||
"""takes no arguments
|
||||
|
||||
Returns the channels in which this bot is lobotomized.
|
||||
"""
|
||||
L = []
|
||||
for (channel, c) in ircdb.channels.iteritems():
|
||||
if c.lobotomized:
|
||||
chancap = ircdb.makeChannelCapability(channel, 'op')
|
||||
if ircdb.checkCapability(msg.prefix, 'admin') or \
|
||||
ircdb.checkCapability(msg.prefix, chancap) or \
|
||||
(channel in irc.state.channels and \
|
||||
msg.nick in irc.state.channels[channel].users):
|
||||
L.append(channel)
|
||||
if L:
|
||||
L.sort()
|
||||
s = format('I\'m currently lobotomized in %L.', L)
|
||||
irc.reply(s)
|
||||
else:
|
||||
irc.reply('I\'m not currently lobotomized in any channels '
|
||||
'that you\'re in.')
|
||||
list = wrap(list)
|
||||
|
||||
class ban(callbacks.Commands):
|
||||
def add(self, irc, msg, args, channel, banmask, expires):
|
||||
"""[<channel>] <nick|hostmask> [<expires>]
|
||||
|
||||
If you have the #channel,op capability, this will effect a
|
||||
persistent ban from interacting with the bot on the given
|
||||
<hostmask> (or the current hostmask associated with <nick>. Other
|
||||
plugins may enforce this ban by actually banning users with
|
||||
matching hostmasks when they join. <expires> is an optional
|
||||
argument specifying when (in "seconds from now") the ban should
|
||||
expire; if none is given, the ban will never automatically expire.
|
||||
<channel> is only necessary if the message isn't sent in the
|
||||
channel itself.
|
||||
"""
|
||||
c = ircdb.channels.getChannel(channel)
|
||||
c.addBan(banmask, expires)
|
||||
ircdb.channels.setChannel(channel, c)
|
||||
irc.replySuccess()
|
||||
add = wrap(add, ['op', 'hostmask', additional('expiry', 0)])
|
||||
|
||||
def remove(self, irc, msg, args, channel, banmask):
|
||||
"""[<channel>] <hostmask>
|
||||
|
||||
If you have the #channel,op capability, this will remove the
|
||||
persistent ban on <hostmask>. <channel> is only necessary if the
|
||||
message isn't sent in the channel itself.
|
||||
"""
|
||||
c = ircdb.channels.getChannel(channel)
|
||||
try:
|
||||
c.removeBan(banmask)
|
||||
ircdb.channels.setChannel(channel, c)
|
||||
irc.replySuccess()
|
||||
except KeyError:
|
||||
irc.error('There are no persistent bans for that hostmask.')
|
||||
remove = wrap(remove, ['op', 'hostmask'])
|
||||
|
||||
def list(self, irc, msg, args, channel):
|
||||
"""[<channel>]
|
||||
|
||||
If you have the #channel,op capability, this will show you the
|
||||
current bans on #channel.
|
||||
"""
|
||||
# XXX Add the expirations.
|
||||
c = ircdb.channels.getChannel(channel)
|
||||
if c.bans:
|
||||
irc.reply(format('%L', map(utils.str.dqrepr, c.bans)))
|
||||
else:
|
||||
irc.reply(format('There are no persistent bans on %s.',
|
||||
channel))
|
||||
list = wrap(list, ['op'])
|
||||
|
||||
class ignore(callbacks.Commands):
|
||||
def add(self, irc, msg, args, channel, banmask, expires):
|
||||
"""[<channel>] <nick|hostmask> [<expires>]
|
||||
|
||||
If you have the #channel,op capability, this will set a persistent
|
||||
ignore on <hostmask> or the hostmask currently
|
||||
associated with <nick>. <expires> is an optional argument
|
||||
specifying when (in "seconds from now") the ignore will expire; if
|
||||
it isn't given, the ignore will never automatically expire.
|
||||
<channel> is only necessary if the message isn't sent in the
|
||||
channel itself.
|
||||
"""
|
||||
c = ircdb.channels.getChannel(channel)
|
||||
c.addIgnore(banmask, expires)
|
||||
ircdb.channels.setChannel(channel, c)
|
||||
irc.replySuccess()
|
||||
add = wrap(add, ['op', 'hostmask', additional('expiry', 0)])
|
||||
|
||||
def remove(self, irc, msg, args, channel, banmask):
|
||||
"""[<channel>] <hostmask>
|
||||
|
||||
If you have the #channel,op capability, this will remove the
|
||||
persistent ignore on <hostmask> in the channel. <channel> is only
|
||||
necessary if the message isn't sent in the channel itself.
|
||||
"""
|
||||
c = ircdb.channels.getChannel(channel)
|
||||
try:
|
||||
c.removeIgnore(banmask)
|
||||
ircdb.channels.setChannel(channel, c)
|
||||
irc.replySuccess()
|
||||
except KeyError:
|
||||
irc.error('There are no ignores for that hostmask.')
|
||||
remove = wrap(remove, ['op', 'hostmask'])
|
||||
|
||||
def list(self, irc, msg, args, channel):
|
||||
"""[<channel>]
|
||||
|
||||
Lists the hostmasks that the bot is ignoring on the given channel.
|
||||
<channel> is only necessary if the message isn't sent in the
|
||||
channel itself.
|
||||
"""
|
||||
# XXX Add the expirations.
|
||||
c = ircdb.channels.getChannel(channel)
|
||||
if len(c.ignores) == 0:
|
||||
s = format('I\'m not currently ignoring any hostmasks in %q',
|
||||
channel)
|
||||
irc.reply(s)
|
||||
else:
|
||||
L = sorted(c.ignores)
|
||||
irc.reply(utils.str.commaAndify(map(repr, L)))
|
||||
list = wrap(list, ['op'])
|
||||
|
||||
class capability(callbacks.Commands):
|
||||
def add(self, irc, msg, args, channel, user, capabilities):
|
||||
"""[<channel>] <nick|username> <capability> [<capability> ...]
|
||||
|
||||
If you have the #channel,op capability, this will give the user
|
||||
<name> (or the user to whom <nick> maps)
|
||||
the capability <capability> in the channel. <channel> is only
|
||||
necessary if the message isn't sent in the channel itself.
|
||||
"""
|
||||
for c in capabilities.split():
|
||||
c = ircdb.makeChannelCapability(channel, c)
|
||||
user.addCapability(c)
|
||||
ircdb.users.setUser(user)
|
||||
irc.replySuccess()
|
||||
add = wrap(add, ['op', 'otherUser', 'capability'])
|
||||
|
||||
def remove(self, irc, msg, args, channel, user, capabilities):
|
||||
"""[<channel>] <name|hostmask> <capability> [<capability> ...]
|
||||
|
||||
If you have the #channel,op capability, this will take from the
|
||||
user currently identified as <name> (or the user to whom <hostmask>
|
||||
maps) the capability <capability> in the channel. <channel> is only
|
||||
necessary if the message isn't sent in the channel itself.
|
||||
"""
|
||||
fail = []
|
||||
for c in capabilities.split():
|
||||
cap = ircdb.makeChannelCapability(channel, c)
|
||||
try:
|
||||
user.removeCapability(cap)
|
||||
except KeyError:
|
||||
fail.append(c)
|
||||
ircdb.users.setUser(user)
|
||||
if fail:
|
||||
s = 'capability'
|
||||
if len(fail) > 1:
|
||||
s = utils.str.pluralize(s)
|
||||
irc.error(format('That user didn\'t have the %L %s.', fail, s),
|
||||
Raise=True)
|
||||
irc.replySuccess()
|
||||
remove = wrap(remove, ['op', 'otherUser', 'capability'])
|
||||
|
||||
# XXX This needs to be fix0red to be like Owner.defaultcapability. Or
|
||||
# something else. This is a horrible interface.
|
||||
def setdefault(self, irc, msg, args, channel, v):
|
||||
"""[<channel>] {True|False}
|
||||
|
||||
If you have the #channel,op capability, this will set the default
|
||||
response to non-power-related (that is, not {op, halfop, voice}
|
||||
capabilities to be the value you give. <channel> is only necessary
|
||||
if the message isn't sent in the channel itself.
|
||||
"""
|
||||
c = ircdb.channels.getChannel(channel)
|
||||
if v:
|
||||
c.setDefaultCapability(True)
|
||||
else:
|
||||
c.setDefaultCapability(False)
|
||||
ircdb.channels.setChannel(channel, c)
|
||||
irc.replySuccess()
|
||||
setdefault = wrap(setdefault, ['op', 'boolean'])
|
||||
|
||||
def set(self, irc, msg, args, channel, capabilities):
|
||||
"""[<channel>] <capability> [<capability> ...]
|
||||
|
||||
If you have the #channel,op capability, this will add the channel
|
||||
capability <capability> for all users in the channel. <channel> is
|
||||
only necessary if the message isn't sent in the channel itself.
|
||||
"""
|
||||
chan = ircdb.channels.getChannel(channel)
|
||||
for c in capabilities:
|
||||
chan.addCapability(c)
|
||||
ircdb.channels.setChannel(channel, chan)
|
||||
irc.replySuccess()
|
||||
set = wrap(set, ['op', many('capability')])
|
||||
|
||||
def unset(self, irc, msg, args, channel, capabilities):
|
||||
"""[<channel>] <capability> [<capability> ...]
|
||||
|
||||
If you have the #channel,op capability, this will unset the channel
|
||||
capability <capability> so each user's specific capability or the
|
||||
channel default capability will take precedence. <channel> is only
|
||||
necessary if the message isn't sent in the channel itself.
|
||||
"""
|
||||
chan = ircdb.channels.getChannel(channel)
|
||||
fail = []
|
||||
for c in capabilities:
|
||||
try:
|
||||
chan.removeCapability(c)
|
||||
except KeyError:
|
||||
fail.append(c)
|
||||
ircdb.channels.setChannel(channel, chan)
|
||||
if fail:
|
||||
s = 'capability'
|
||||
if len(fail) > 1:
|
||||
s = utils.str.pluralize(s)
|
||||
irc.error(format('I do not know about the %L %s.', fail, s),
|
||||
Raise=True)
|
||||
irc.replySuccess()
|
||||
unset = wrap(unset, ['op', many('capability')])
|
||||
|
||||
def list(self, irc, msg, args, channel):
|
||||
"""[<channel>]
|
||||
|
||||
Returns the capabilities present on the <channel>. <channel> is
|
||||
only necessary if the message isn't sent in the channel itself.
|
||||
"""
|
||||
c = ircdb.channels.getChannel(channel)
|
||||
L = sorted(c.capabilities)
|
||||
irc.reply(' '.join(L))
|
||||
list = wrap(list, ['channel'])
|
||||
|
||||
def disable(self, irc, msg, args, channel, plugin, command):
|
||||
"""[<channel>] [<plugin>] [<command>]
|
||||
|
||||
If you have the #channel,op capability, this will disable the <command>
|
||||
in <channel>. If <plugin> is provided, <command> will be disabled only
|
||||
for that plugin. If only <plugin> is provided, all commands in the
|
||||
given plugin will be disabled. <channel> is only necessary if the
|
||||
message isn't sent in the channel itself.
|
||||
"""
|
||||
chan = ircdb.channels.getChannel(channel)
|
||||
failMsg = ''
|
||||
if plugin:
|
||||
s = '-%s' % plugin.name()
|
||||
if command:
|
||||
if plugin.isCommand(command):
|
||||
s = '-%s.%s' % (plugin.name(), command)
|
||||
else:
|
||||
failMsg = format('The %s plugin does not have a command '
|
||||
'called %s.', plugin.name(), command)
|
||||
elif command:
|
||||
# findCallbackForCommand
|
||||
if filter(None, irc.findCallbacksForArgs([command])):
|
||||
s = '-%s' % command
|
||||
else:
|
||||
failMsg = format('No plugin or command named %s could be '
|
||||
'found.', command)
|
||||
else:
|
||||
raise callbacks.ArgumentError
|
||||
if failMsg:
|
||||
irc.error(failMsg)
|
||||
else:
|
||||
chan.addCapability(s)
|
||||
ircdb.channels.setChannel(channel, chan)
|
||||
irc.replySuccess()
|
||||
disable = wrap(disable, ['op',
|
||||
optional(('plugin', False)),
|
||||
additional('commandName')])
|
||||
|
||||
def enable(self, irc, msg, args, channel, plugin, command):
|
||||
"""[<channel>] [<plugin>] [<command>]
|
||||
|
||||
If you have the #channel,op capability, this will enable the <command>
|
||||
in <channel> if it has been disabled. If <plugin> is provided,
|
||||
<command> will be enabled only for that plugin. If only <plugin> is
|
||||
provided, all commands in the given plugin will be enabled. <channel>
|
||||
is only necessary if the message isn't sent in the channel itself.
|
||||
"""
|
||||
chan = ircdb.channels.getChannel(channel)
|
||||
failMsg = ''
|
||||
if plugin:
|
||||
s = '-%s' % plugin.name()
|
||||
if command:
|
||||
if plugin.isCommand(command):
|
||||
s = '-%s.%s' % (plugin.name(), command)
|
||||
else:
|
||||
failMsg = format('The %s plugin does not have a command '
|
||||
'called %s.', plugin.name(), command)
|
||||
elif command:
|
||||
# findCallbackForCommand
|
||||
if filter(None, irc.findCallbacksForArgs([command])):
|
||||
s = '-%s' % command
|
||||
else:
|
||||
failMsg = format('No plugin or command named %s could be '
|
||||
'found.', command)
|
||||
else:
|
||||
raise callbacks.ArgumentError
|
||||
if failMsg:
|
||||
irc.error(failMsg)
|
||||
else:
|
||||
fail = []
|
||||
try:
|
||||
chan.removeCapability(s)
|
||||
except KeyError:
|
||||
fail.append(s)
|
||||
ircdb.channels.setChannel(channel, chan)
|
||||
if fail:
|
||||
irc.error(format('%s was not disabled.', s[1:]))
|
||||
else:
|
||||
irc.replySuccess()
|
||||
enable = wrap(enable, ['op',
|
||||
optional(('plugin', False)),
|
||||
additional('commandName')])
|
||||
|
||||
def nicks(self, irc, msg, args, channel):
|
||||
"""[<channel>]
|
||||
|
||||
Returns the nicks in <channel>. <channel> is only necessary if the
|
||||
message isn't sent in the channel itself.
|
||||
"""
|
||||
L = list(irc.state.channels[channel].users)
|
||||
utils.sortBy(str.lower, L)
|
||||
irc.reply(utils.str.commaAndify(L))
|
||||
nicks = wrap(nicks, ['inChannel']) # XXX Check that the caller is in chan.
|
||||
|
||||
def alertOps(self, irc, channel, s, frm=None):
|
||||
"""Internal message for notifying all the #channel,ops in a channel of
|
||||
a given situation."""
|
||||
capability = ircdb.makeChannelCapability(channel, 'op')
|
||||
s = format('Alert to all %s ops: %s', channel, s)
|
||||
if frm is not None:
|
||||
s += format(' (from %s)', frm)
|
||||
for nick in irc.state.channels[channel].users:
|
||||
hostmask = irc.state.nickToHostmask(nick)
|
||||
if ircdb.checkCapability(hostmask, capability):
|
||||
irc.reply(s, to=nick, private=True)
|
||||
|
||||
def alert(self, irc, msg, args, channel, text):
|
||||
"""[<channel>] <text>
|
||||
|
||||
Sends <text> to all the users in <channel> who have the <channel>,op
|
||||
capability.
|
||||
"""
|
||||
self.alertOps(irc, channel, text, frm=msg.nick)
|
||||
alert = wrap(alert, ['op', 'text'])
|
||||
|
||||
|
||||
Class = Channel
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1,191 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2002-2005, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
from supybot.test import *
|
||||
|
||||
import supybot.conf as conf
|
||||
import supybot.ircdb as ircdb
|
||||
import supybot.ircmsgs as ircmsgs
|
||||
|
||||
class ChannelTestCase(ChannelPluginTestCase):
|
||||
plugins = ('Channel', 'User')
|
||||
|
||||
def setUp(self):
|
||||
super(ChannelTestCase, self).setUp()
|
||||
self.irc.state.channels[self.channel].addUser('foo')
|
||||
self.irc.state.channels[self.channel].addUser('bar')
|
||||
|
||||
def testLobotomies(self):
|
||||
self.assertRegexp('lobotomy list', 'not.*any')
|
||||
|
||||
## def testCapabilities(self):
|
||||
## self.prefix = 'foo!bar@baz'
|
||||
## self.irc.feedMsg(ircmsgs.privmsg(self.irc.nick, 'register foo bar',
|
||||
## prefix=self.prefix))
|
||||
## u = ircdb.users.getUser(0)
|
||||
## u.addCapability('%s.op' % self.channel)
|
||||
## ircdb.users.setUser(u)
|
||||
## self.assertNotError(' ')
|
||||
## self.assertResponse('user capabilities foo', '[]')
|
||||
## self.assertNotError('channel addcapability foo op')
|
||||
## self.assertRegexp('channel capabilities foo', 'op')
|
||||
## self.assertNotError('channel removecapability foo op')
|
||||
## self.assertResponse('user capabilities foo', '[]')
|
||||
|
||||
def testCapabilities(self):
|
||||
self.assertNotError('channel capability list')
|
||||
self.assertNotError('channel capability set -foo')
|
||||
self.assertNotError('channel capability unset -foo')
|
||||
self.assertError('channel capability unset -foo')
|
||||
self.assertNotError('channel capability set -foo bar baz')
|
||||
self.assertRegexp('channel capability list', 'baz')
|
||||
self.assertNotError('channel capability unset -foo baz')
|
||||
self.assertError('channel capability unset baz')
|
||||
|
||||
def testEnableDisable(self):
|
||||
self.assertNotRegexp('channel capability list', '-Channel')
|
||||
self.assertError('channel enable channel')
|
||||
self.assertNotError('channel disable channel')
|
||||
self.assertRegexp('channel capability list', '-Channel')
|
||||
self.assertNotError('channel enable channel')
|
||||
self.assertNotRegexp('channel capability list', '-Channel')
|
||||
self.assertNotError('channel disable channel nicks')
|
||||
self.assertRegexp('channel capability list', '-Channel.nicks')
|
||||
self.assertNotError('channel enable channel nicks')
|
||||
self.assertNotRegexp('channel capability list', '-Channel.nicks')
|
||||
self.assertNotRegexp('channel capability list', 'nicks')
|
||||
self.assertNotError('channel disable nicks')
|
||||
self.assertRegexp('channel capability list', 'nicks')
|
||||
self.assertNotError('channel enable nicks')
|
||||
self.assertError('channel disable invalidPlugin')
|
||||
self.assertError('channel disable channel invalidCommand')
|
||||
|
||||
def testUnban(self):
|
||||
self.assertError('unban foo!bar@baz')
|
||||
self.irc.feedMsg(ircmsgs.op(self.channel, self.nick))
|
||||
m = self.getMsg('unban foo!bar@baz')
|
||||
self.assertEqual(m.command, 'MODE')
|
||||
self.assertEqual(m.args, (self.channel, '-b', 'foo!bar@baz'))
|
||||
self.assertNoResponse(' ', 2)
|
||||
|
||||
def testErrorsWithoutOps(self):
|
||||
for s in 'op deop halfop dehalfop voice devoice kick invite'.split():
|
||||
self.assertError('%s foo' % s)
|
||||
self.irc.feedMsg(ircmsgs.op(self.channel, self.nick))
|
||||
self.assertNotError('%s foo' % s)
|
||||
self.irc.feedMsg(ircmsgs.deop(self.channel, self.nick))
|
||||
|
||||
def testWontDeItself(self):
|
||||
for s in 'deop dehalfop devoice'.split():
|
||||
self.irc.feedMsg(ircmsgs.op(self.channel, self.nick))
|
||||
self.assertError('%s %s' % (s, self.nick))
|
||||
|
||||
def testOp(self):
|
||||
self.assertError('op')
|
||||
self.irc.feedMsg(ircmsgs.op(self.channel, self.nick))
|
||||
self.assertNotError('op')
|
||||
m = self.getMsg('op foo')
|
||||
self.failUnless(m.command == 'MODE' and
|
||||
m.args == (self.channel, '+o', 'foo'))
|
||||
m = self.getMsg('op foo bar')
|
||||
self.failUnless(m.command == 'MODE' and
|
||||
m.args == (self.channel, '+oo', 'foo', 'bar'))
|
||||
|
||||
def testHalfOp(self):
|
||||
self.assertError('halfop')
|
||||
self.irc.feedMsg(ircmsgs.op(self.channel, self.nick))
|
||||
self.assertNotError('halfop')
|
||||
m = self.getMsg('halfop foo')
|
||||
self.failUnless(m.command == 'MODE' and
|
||||
m.args == (self.channel, '+h', 'foo'))
|
||||
m = self.getMsg('halfop foo bar')
|
||||
self.failUnless(m.command == 'MODE' and
|
||||
m.args == (self.channel, '+hh', 'foo', 'bar'))
|
||||
|
||||
def testVoice(self):
|
||||
self.assertError('voice')
|
||||
self.irc.feedMsg(ircmsgs.op(self.channel, self.nick))
|
||||
self.assertNotError('voice')
|
||||
m = self.getMsg('voice foo')
|
||||
self.failUnless(m.command == 'MODE' and
|
||||
m.args == (self.channel, '+v', 'foo'))
|
||||
m = self.getMsg('voice foo bar')
|
||||
self.failUnless(m.command == 'MODE' and
|
||||
m.args == (self.channel, '+vv', 'foo', 'bar'))
|
||||
|
||||
def assertBan(self, query, hostmask, **kwargs):
|
||||
m = self.getMsg(query, **kwargs)
|
||||
self.assertEqual(m, ircmsgs.ban(self.channel, hostmask))
|
||||
m = self.getMsg(' ')
|
||||
self.assertEqual(m.command, 'KICK')
|
||||
|
||||
## def testKban(self):
|
||||
## self.irc.prefix = 'something!else@somehwere.else'
|
||||
## self.irc.nick = 'something'
|
||||
## self.irc.feedMsg(ircmsgs.join(self.channel,
|
||||
## prefix='foobar!user@host.domain.tld'))
|
||||
## self.assertError('kban foobar')
|
||||
## self.irc.feedMsg(ircmsgs.op(self.channel, self.irc.nick))
|
||||
## self.assertError('kban foobar -1')
|
||||
## self.assertBan('kban foobar', '*!*@*.domain.tld')
|
||||
## self.assertBan('kban --exact foobar', 'foobar!user@host.domain.tld')
|
||||
## self.assertBan('kban --host foobar', '*!*@host.domain.tld')
|
||||
## self.assertBan('kban --user foobar', '*!user@*')
|
||||
## self.assertBan('kban --nick foobar', 'foobar!*@*')
|
||||
## self.assertBan('kban --nick --user foobar', 'foobar!user@*')
|
||||
## self.assertBan('kban --nick --host foobar',
|
||||
## 'foobar!*@host.domain.tld')
|
||||
## self.assertBan('kban --user --host foobar', '*!user@host.domain.tld')
|
||||
## self.assertBan('kban --nick --user --host foobar',
|
||||
## 'foobar!user@host.domain.tld')
|
||||
## self.assertNotRegexp('kban adlkfajsdlfkjsd', 'KeyError')
|
||||
## self.assertNotRegexp('kban foobar time', 'ValueError')
|
||||
## self.assertError('kban %s' % self.irc.nick)
|
||||
|
||||
def testBan(self):
|
||||
self.assertNotError('ban add foo!bar@baz')
|
||||
self.assertNotError('ban remove foo!bar@baz')
|
||||
orig = conf.supybot.protocols.irc.strictRfc()
|
||||
try:
|
||||
conf.supybot.protocols.irc.strictRfc.setValue(True)
|
||||
# something wonky is going on here. irc.error (src/Channel.py|449)
|
||||
# is being called but the assert is failing
|
||||
self.assertError('ban add not!a.hostmask')
|
||||
self.assertNotRegexp('ban add not!a.hostmask', 'KeyError')
|
||||
finally:
|
||||
conf.supybot.protocols.irc.strictRfc.setValue(orig)
|
||||
|
||||
def testIgnore(self):
|
||||
self.assertNotError('channel ignore add foo!bar@baz')
|
||||
self.assertResponse('channel ignore list', "'foo!bar@baz'")
|
||||
self.assertNotError('channel ignore remove foo!bar@baz')
|
||||
self.assertError('ban add not!a.hostmask')
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
||||
|
@ -1 +0,0 @@
|
||||
Insert a description of your plugin here, with any notes, etc. about using it.
|
@ -1,60 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2005, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
"""
|
||||
Logs each channel to its own individual logfile.
|
||||
"""
|
||||
|
||||
import supybot
|
||||
import supybot.world as world
|
||||
|
||||
# Use this for the version of this plugin. You may wish to put a CVS keyword
|
||||
# in here if you're keeping the plugin in CVS or some similar system.
|
||||
__version__ = "%%VERSION%%"
|
||||
|
||||
__author__ = supybot.authors.jemfinch
|
||||
|
||||
# This is a dictionary mapping supybot.Author instances to lists of
|
||||
# contributions.
|
||||
__contributors__ = {}
|
||||
|
||||
import config
|
||||
import plugin
|
||||
reload(plugin) # In case we're being reloaded.
|
||||
# Add more reloads here if you add third-party modules and want them to be
|
||||
# reloaded when this plugin is reloaded. Don't forget to import them as well!
|
||||
|
||||
if world.testing:
|
||||
import test
|
||||
|
||||
Class = plugin.Class
|
||||
configure = config.configure
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1,87 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2005, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
import supybot.conf as conf
|
||||
import supybot.registry as registry
|
||||
|
||||
def configure(advanced):
|
||||
# This will be called by supybot to configure this module. advanced is
|
||||
# a bool that specifies whether the user identified himself as an advanced
|
||||
# user or not. You should effect your configuration by manipulating the
|
||||
# registry as appropriate.
|
||||
from supybot.questions import expect, anything, something, yn
|
||||
conf.registerPlugin('ChannelLogger', True)
|
||||
|
||||
ChannelLogger = conf.registerPlugin('ChannelLogger')
|
||||
conf.registerGlobalValue(ChannelLogger, 'flushImmediately',
|
||||
registry.Boolean(False, """Determines whether channel logfiles will be
|
||||
flushed anytime they're written to, rather than being buffered by the
|
||||
operating system."""))
|
||||
conf.registerChannelValue(ChannelLogger, 'stripFormatting',
|
||||
registry.Boolean(True, """Determines whether formatting characters (such
|
||||
as bolding, color, etc.) are removed when writing the logs to disk."""))
|
||||
conf.registerChannelValue(ChannelLogger, 'timestamp',
|
||||
registry.Boolean(True, """Determines whether the logs for this channel are
|
||||
timestamped with the timestamp in supybot.log.timestampFormat."""))
|
||||
conf.registerChannelValue(ChannelLogger, 'noLogPrefix',
|
||||
registry.String('[nolog]', """Determines what string a message should be
|
||||
prefixed with in order not to be logged. If you don't want any such
|
||||
prefix, just set it to the empty string."""))
|
||||
conf.registerChannelValue(ChannelLogger, 'rotateLogs',
|
||||
registry.Boolean(False, """Determines whether the bot will automatically
|
||||
rotate the logs for this channel. The bot will rotate logs when the
|
||||
timestamp for the log changes. The timestamp is set according to
|
||||
the 'filenameTimestamp' configuration variable."""))
|
||||
conf.registerChannelValue(ChannelLogger, 'filenameTimestamp',
|
||||
registry.String('%d-%a-%Y', """Determines how to represent the timestamp
|
||||
used for the filename in rotated logs. When this timestamp changes, the
|
||||
old logfiles will be closed and a new one started. The format characters
|
||||
for the timestamp are in the time.strftime docs at python.org. In order
|
||||
for your logs to be rotated, you'll also have to enable
|
||||
supybot.plugins.ChannelLogger.rotateLogs."""))
|
||||
|
||||
conf.registerGlobalValue(ChannelLogger, 'directories',
|
||||
registry.Boolean(True, """Determines whether the bot will partition its
|
||||
channel logs into separate directories based on different criteria."""))
|
||||
conf.registerGlobalValue(ChannelLogger.directories, 'network',
|
||||
registry.Boolean(True, """Determines whether the bot will use a network
|
||||
directory if using directories."""))
|
||||
conf.registerGlobalValue(ChannelLogger.directories, 'channel',
|
||||
registry.Boolean(True, """Determines whether the bot will use a channel
|
||||
directory if using directories."""))
|
||||
conf.registerGlobalValue(ChannelLogger.directories, 'timestamp',
|
||||
registry.Boolean(False, """Determines whether the bot will use a timestamp
|
||||
(determined by supybot.plugins.ChannelLogger.directories.timestamp.format)
|
||||
if using directories."""))
|
||||
conf.registerGlobalValue(ChannelLogger.timestamp, 'format',
|
||||
registry.String('%B', """Determines what timestamp format will be used in
|
||||
the directory stucture for channel logs if
|
||||
supybot.plugins.ChannelLogger.directories.timestamp is True."""))
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1,262 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2002-2004, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
import os
|
||||
import time
|
||||
from cStringIO import StringIO
|
||||
|
||||
import supybot.conf as conf
|
||||
import supybot.world as world
|
||||
import supybot.irclib as irclib
|
||||
import supybot.ircmsgs as ircmsgs
|
||||
import supybot.ircutils as ircutils
|
||||
import supybot.registry as registry
|
||||
import supybot.callbacks as callbacks
|
||||
|
||||
class FakeLog(object):
|
||||
def flush(self):
|
||||
return
|
||||
def close(self):
|
||||
return
|
||||
def write(self, s):
|
||||
return
|
||||
|
||||
class ChannelLogger(callbacks.Plugin):
|
||||
noIgnore = True
|
||||
def __init__(self, irc):
|
||||
self.__parent = super(ChannelLogger, self)
|
||||
self.__parent.__init__(irc)
|
||||
self.lastMsgs = {}
|
||||
self.lastStates = {}
|
||||
self.logs = {}
|
||||
world.flushers.append(self.flush)
|
||||
|
||||
def die(self):
|
||||
for log in self._logs():
|
||||
log.close()
|
||||
world.flushers = [x for x in world.flushers
|
||||
if hasattr(x, 'im_class') and
|
||||
x.im_class is not self.__class__]
|
||||
|
||||
def __call__(self, irc, msg):
|
||||
try:
|
||||
# I don't know why I put this in, but it doesn't work, because it
|
||||
# doesn't call doNick or doQuit.
|
||||
# if msg.args and irc.isChannel(msg.args[0]):
|
||||
self.__parent.__call__(irc, msg)
|
||||
if irc in self.lastMsgs:
|
||||
if irc not in self.lastStates:
|
||||
self.lastStates[irc] = irc.state.copy()
|
||||
self.lastStates[irc].addMsg(irc, self.lastMsgs[irc])
|
||||
finally:
|
||||
# We must make sure this always gets updated.
|
||||
self.lastMsgs[irc] = msg
|
||||
|
||||
def reset(self):
|
||||
for log in self._logs():
|
||||
log.close()
|
||||
self.logs.clear()
|
||||
self.lastMsgs.clear()
|
||||
self.lastStates.clear()
|
||||
|
||||
def _logs(self):
|
||||
for logs in self.logs.itervalues():
|
||||
for log in logs.itervalues():
|
||||
yield log
|
||||
|
||||
def flush(self):
|
||||
self.checkLogNames()
|
||||
for log in self._logs():
|
||||
try:
|
||||
log.flush()
|
||||
except ValueError, e:
|
||||
if e.args[0] != 'I/O operation on a closed file':
|
||||
self.log.exception('Odd exception:')
|
||||
|
||||
def logNameTimestamp(self, channel):
|
||||
format = self.registryValue('filenameTimestamp', channel)
|
||||
return time.strftime(format)
|
||||
|
||||
def getLogName(self, channel):
|
||||
if self.registryValue('rotateLogs', channel):
|
||||
return '%s.%s.log' % (channel, self.logNameTimestamp(channel))
|
||||
else:
|
||||
return '%s.log' % channel
|
||||
|
||||
def getLogDir(self, irc, channel):
|
||||
logDir = conf.supybot.directories.log.dirize(self.name())
|
||||
if self.registryValue('directories'):
|
||||
if self.registryValue('directories.network'):
|
||||
logDir = os.path.join(logDir, irc.network)
|
||||
if self.registryValue('directories.channel'):
|
||||
logDir = os.path.join(logDir, channel)
|
||||
if self.registryValue('directories.timestamp'):
|
||||
format = self.registryValue('directories.timestamp.format')
|
||||
timeDir =time.strftime(format)
|
||||
logDir = os.path.join(logDir, timeDir)
|
||||
if not os.path.exists(logDir):
|
||||
os.makedirs(logDir)
|
||||
return logDir
|
||||
|
||||
def checkLogNames(self):
|
||||
for (irc, logs) in self.logs.items():
|
||||
for (channel, log) in logs.items():
|
||||
if self.registryValue('rotateLogs', channel):
|
||||
name = self.getLogName(channel)
|
||||
if name != log.name:
|
||||
log.close()
|
||||
del logs[channel]
|
||||
|
||||
def getLog(self, irc, channel):
|
||||
self.checkLogNames()
|
||||
try:
|
||||
logs = self.logs[irc]
|
||||
except KeyError:
|
||||
logs = ircutils.IrcDict()
|
||||
self.logs[irc] = logs
|
||||
if channel in logs:
|
||||
return logs[channel]
|
||||
else:
|
||||
try:
|
||||
name = self.getLogName(channel)
|
||||
logDir = self.getLogDir(irc, channel)
|
||||
log = file(os.path.join(logDir, name), 'a')
|
||||
logs[channel] = log
|
||||
return log
|
||||
except IOError:
|
||||
self.log.exception('Error opening log:')
|
||||
return FakeLog()
|
||||
|
||||
def timestamp(self, log):
|
||||
format = conf.supybot.log.timestampFormat()
|
||||
if format:
|
||||
log.write(time.strftime(format))
|
||||
log.write(' ')
|
||||
|
||||
def normalizeChannel(self, irc, channel):
|
||||
return ircutils.toLower(channel)
|
||||
|
||||
def doLog(self, irc, channel, s, *args):
|
||||
s = format(s, *args)
|
||||
channel = self.normalizeChannel(irc, channel)
|
||||
log = self.getLog(irc, channel)
|
||||
if self.registryValue('timestamp', channel):
|
||||
self.timestamp(log)
|
||||
if self.registryValue('stripFormatting', channel):
|
||||
s = ircutils.stripFormatting(s)
|
||||
log.write(s)
|
||||
if self.registryValue('flushImmediately'):
|
||||
log.flush()
|
||||
|
||||
def doPrivmsg(self, irc, msg):
|
||||
(recipients, text) = msg.args
|
||||
for channel in recipients.split(','):
|
||||
if irc.isChannel(channel):
|
||||
noLogPrefix = self.registryValue('noLogPrefix', channel)
|
||||
if noLogPrefix and text.startswith(noLogPrefix):
|
||||
text = '-= THIS MESSAGE NOT LOGGED =-'
|
||||
nick = msg.nick or irc.nick
|
||||
if ircmsgs.isAction(msg):
|
||||
self.doLog(irc, channel,
|
||||
'* %s %s\n', nick, ircmsgs.unAction(msg))
|
||||
else:
|
||||
self.doLog(irc, channel, '<%s> %s\n', nick, text)
|
||||
|
||||
def doNotice(self, irc, msg):
|
||||
(recipients, text) = msg.args
|
||||
for channel in recipients.split(','):
|
||||
if irc.isChannel(channel):
|
||||
self.doLog(irc, channel, '-%s- %s\n', msg.nick, text)
|
||||
|
||||
def doNick(self, irc, msg):
|
||||
oldNick = msg.nick
|
||||
newNick = msg.args[0]
|
||||
for (channel, c) in irc.state.channels.iteritems():
|
||||
if newNick in c.users:
|
||||
self.doLog(irc, channel,
|
||||
'*** %s is now known as %s\n', oldNick, newNick)
|
||||
def doJoin(self, irc, msg):
|
||||
for channel in msg.args[0].split(','):
|
||||
self.doLog(irc, channel,
|
||||
'*** %s has joined %s\n',
|
||||
msg.nick or msg.prefix, channel)
|
||||
|
||||
def doKick(self, irc, msg):
|
||||
if len(msg.args) == 3:
|
||||
(channel, target, kickmsg) = msg.args
|
||||
else:
|
||||
(channel, target) = msg.args
|
||||
kickmsg = ''
|
||||
if kickmsg:
|
||||
self.doLog(irc, channel,
|
||||
'*** %s was kicked by %s (%s)\n',
|
||||
target, msg.nick, kickmsg)
|
||||
else:
|
||||
self.doLog(irc, channel,
|
||||
'*** %s was kicked by %s\n', target, msg.nick)
|
||||
|
||||
def doPart(self, irc, msg):
|
||||
for channel in msg.args[0].split(','):
|
||||
self.doLog(irc, channel,
|
||||
'*** %s has left %s\n', msg.nick, channel)
|
||||
|
||||
def doMode(self, irc, msg):
|
||||
channel = msg.args[0]
|
||||
if irc.isChannel(channel) and msg.args[1:]:
|
||||
self.doLog(irc, channel,
|
||||
'*** %s sets mode: %s %s\n',
|
||||
msg.nick or msg.prefix, msg.args[1],
|
||||
' '.join(msg.args[2:]))
|
||||
|
||||
def doTopic(self, irc, msg):
|
||||
if len(msg.args) == 1:
|
||||
return # It's an empty TOPIC just to get the current topic.
|
||||
channel = msg.args[0]
|
||||
self.doLog(irc, channel,
|
||||
'*** %s changes topic to "%s"\n', msg.nick, msg.args[1])
|
||||
|
||||
def doQuit(self, irc, msg):
|
||||
if not isinstance(irc, irclib.Irc):
|
||||
irc = irc.getRealIrc()
|
||||
for (channel, chan) in self.lastStates[irc].channels.iteritems():
|
||||
if msg.nick in chan.users:
|
||||
self.doLog(irc, channel, '*** %s has quit IRC\n', msg.nick)
|
||||
|
||||
def outFilter(self, irc, msg):
|
||||
# Gotta catch my own messages *somehow* :)
|
||||
# Let's try this little trick...
|
||||
if msg.command in ('PRIVMSG', 'NOTICE'):
|
||||
# Other messages should be sent back to us.
|
||||
m = ircmsgs.IrcMsg(msg=msg, prefix=irc.prefix)
|
||||
self(irc, m)
|
||||
return msg
|
||||
|
||||
|
||||
Class = ChannelLogger
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1,36 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2005, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
from supybot.test import *
|
||||
|
||||
class ChannelLoggerTestCase(PluginTestCase):
|
||||
plugins = ('ChannelLogger',)
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1 +0,0 @@
|
||||
Insert a description of your plugin here, with any notes, etc. about using it.
|
@ -1,62 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2005, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
"""
|
||||
Silently listens to every message received on a channel and keeps statistics
|
||||
concerning joins, parts, and various other commands in addition to tracking
|
||||
statistics about smileys, actions, characters, and words.
|
||||
"""
|
||||
|
||||
import supybot
|
||||
import supybot.world as world
|
||||
|
||||
# Use this for the version of this plugin. You may wish to put a CVS keyword
|
||||
# in here if you're keeping the plugin in CVS or some similar system.
|
||||
__version__ = ""
|
||||
|
||||
__author__ = supybot.authors.jemfinch
|
||||
|
||||
# This is a dictionary mapping supybot.Author instances to lists of
|
||||
# contributions.
|
||||
__contributors__ = {}
|
||||
|
||||
import config
|
||||
import plugin
|
||||
reload(plugin) # In case we're being reloaded.
|
||||
# Add more reloads here if you add third-party modules and want them to be
|
||||
# reloaded when this plugin is reloaded. Don't forget to import them as well!
|
||||
|
||||
if world.testing:
|
||||
import test
|
||||
|
||||
Class = plugin.Class
|
||||
configure = config.configure
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1,69 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2005, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
import re
|
||||
|
||||
import supybot.conf as conf
|
||||
import supybot.registry as registry
|
||||
|
||||
def configure(advanced):
|
||||
# This will be called by supybot to configure this module. advanced is
|
||||
# a bool that specifies whether the user identified himself as an advanced
|
||||
# user or not. You should effect your configuration by manipulating the
|
||||
# registry as appropriate.
|
||||
from supybot.questions import expect, anything, something, yn
|
||||
conf.registerPlugin('ChannelStats', True)
|
||||
|
||||
class Smileys(registry.Value):
|
||||
def set(self, s):
|
||||
L = s.split()
|
||||
self.setValue(L)
|
||||
|
||||
def setValue(self, v):
|
||||
self.s = ' '.join(v)
|
||||
self.value = re.compile('|'.join(map(re.escape, v)))
|
||||
|
||||
def __str__(self):
|
||||
return self.s
|
||||
|
||||
ChannelStats = conf.registerPlugin('ChannelStats')
|
||||
conf.registerChannelValue(ChannelStats, 'selfStats',
|
||||
registry.Boolean(True, """Determines whether the bot will keep channel
|
||||
statistics on itself, possibly skewing the channel stats (especially in
|
||||
cases where the bot is relaying between channels on a network)."""))
|
||||
conf.registerChannelValue(ChannelStats, 'smileys',
|
||||
Smileys(':) ;) ;] :-) :-D :D :P :p (= =)'.split(), """Determines what
|
||||
words (i.e., pieces of text with no spaces in them) are considered
|
||||
'smileys' for the purposes of stats-keeping."""))
|
||||
conf.registerChannelValue(ChannelStats, 'frowns',
|
||||
Smileys(':| :-/ :-\\ :\\ :/ :( :-( :\'('.split(), """Determines what words
|
||||
(i.e., pieces of text with no spaces in them ) are considered 'frowns' for
|
||||
the purposes of stats-keeping."""))
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1,307 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2002-2004, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
import re
|
||||
|
||||
import supybot.log as log
|
||||
import supybot.conf as conf
|
||||
import supybot.utils as utils
|
||||
import supybot.world as world
|
||||
import supybot.ircdb as ircdb
|
||||
from supybot.commands import *
|
||||
import supybot.irclib as irclib
|
||||
import supybot.ircmsgs as ircmsgs
|
||||
import supybot.plugins as plugins
|
||||
import supybot.ircutils as ircutils
|
||||
import supybot.callbacks as callbacks
|
||||
|
||||
class ChannelStat(irclib.IrcCommandDispatcher):
|
||||
def __init__(self, actions=0, chars=0, frowns=0, joins=0, kicks=0, modes=0,
|
||||
msgs=0, parts=0, quits=0, smileys=0, topics=0, words=0):
|
||||
self.actions = actions
|
||||
self.chars = chars
|
||||
self.frowns = frowns
|
||||
self.joins = joins
|
||||
self.kicks = kicks
|
||||
self.modes = modes
|
||||
self.msgs = msgs
|
||||
self.parts = parts
|
||||
self.quits = quits
|
||||
self.smileys = smileys
|
||||
self.topics = topics
|
||||
self.words = words
|
||||
self._values = ['actions', 'chars', 'frowns', 'joins', 'kicks','modes',
|
||||
'msgs', 'parts', 'quits', 'smileys', 'topics', 'words']
|
||||
def values(self):
|
||||
return [getattr(self, s) for s in self._values]
|
||||
|
||||
def addMsg(self, msg):
|
||||
self.msgs += 1
|
||||
method = self.dispatchCommand(msg.command)
|
||||
if method is not None:
|
||||
method(msg)
|
||||
|
||||
def doPayload(self, channel, payload):
|
||||
channel = plugins.getChannel(channel)
|
||||
self.chars += len(payload)
|
||||
self.words += len(payload.split())
|
||||
fRe = conf.supybot.plugins.ChannelStats.get('frowns').get(channel)()
|
||||
sRe =conf.supybot.plugins.ChannelStats.get('smileys').get(channel)()
|
||||
self.frowns += len(fRe.findall(payload))
|
||||
self.smileys += len(sRe.findall(payload))
|
||||
|
||||
def doPrivmsg(self, msg):
|
||||
self.doPayload(*msg.args)
|
||||
if ircmsgs.isAction(msg):
|
||||
self.actions += 1
|
||||
|
||||
def doTopic(self, msg):
|
||||
self.doPayload(*msg.args)
|
||||
self.topics += 1
|
||||
|
||||
def doKick(self, msg):
|
||||
self.kicks += 1
|
||||
|
||||
def doPart(self, msg):
|
||||
if len(msg.args) == 2:
|
||||
self.doPayload(*msg.args)
|
||||
self.parts += 1
|
||||
|
||||
def doJoin(self, msg):
|
||||
if len(msg.args) == 2:
|
||||
self.doPayload(*msg.args)
|
||||
self.joins += 1
|
||||
|
||||
def doMode(self, msg):
|
||||
self.modes += 1
|
||||
|
||||
# doQuit is handled by the plugin.
|
||||
|
||||
|
||||
class UserStat(ChannelStat):
|
||||
def __init__(self, kicked=0, *args):
|
||||
ChannelStat.__init__(self, *args)
|
||||
self.kicked = kicked
|
||||
self._values.insert(0, 'kicked')
|
||||
|
||||
def doKick(self, msg):
|
||||
self.doPayload(msg.args[0], msg.args[2])
|
||||
self.kicks += 1
|
||||
|
||||
class StatsDB(plugins.ChannelUserDB):
|
||||
def __init__(self, *args, **kwargs):
|
||||
plugins.ChannelUserDB.__init__(self, *args, **kwargs)
|
||||
|
||||
def serialize(self, v):
|
||||
return v.values()
|
||||
|
||||
def deserialize(self, channel, id, L):
|
||||
L = map(int, L)
|
||||
if id == 'channelStats':
|
||||
return ChannelStat(*L)
|
||||
else:
|
||||
return UserStat(*L)
|
||||
|
||||
def addMsg(self, msg, id=None):
|
||||
if ircutils.isChannel(msg.args[0]):
|
||||
channel = plugins.getChannel(msg.args[0])
|
||||
if (channel, 'channelStats') not in self:
|
||||
self[channel, 'channelStats'] = ChannelStat()
|
||||
self[channel, 'channelStats'].addMsg(msg)
|
||||
try:
|
||||
if id is None:
|
||||
id = ircdb.users.getUserId(msg.prefix)
|
||||
except KeyError:
|
||||
return
|
||||
if (channel, id) not in self:
|
||||
self[channel, id] = UserStat()
|
||||
self[channel, id].addMsg(msg)
|
||||
|
||||
def getChannelStats(self, channel):
|
||||
return self[channel, 'channelStats']
|
||||
|
||||
def getUserStats(self, channel, id):
|
||||
return self[channel, id]
|
||||
|
||||
filename = conf.supybot.directories.data.dirize('ChannelStats.db')
|
||||
class ChannelStats(callbacks.Plugin):
|
||||
noIgnore = True
|
||||
def __init__(self, irc):
|
||||
self.__parent = super(ChannelStats, self)
|
||||
self.__parent.__init__(irc)
|
||||
self.lastmsg = None
|
||||
self.laststate = None
|
||||
self.outFiltering = False
|
||||
self.db = StatsDB(filename)
|
||||
self._flush = self.db.flush
|
||||
world.flushers.append(self._flush)
|
||||
|
||||
def die(self):
|
||||
world.flushers.remove(self._flush)
|
||||
self.db.close()
|
||||
self.__parent.die()
|
||||
|
||||
def __call__(self, irc, msg):
|
||||
try:
|
||||
if self.lastmsg:
|
||||
self.laststate.addMsg(irc, self.lastmsg)
|
||||
else:
|
||||
self.laststate = irc.state.copy()
|
||||
finally:
|
||||
self.lastmsg = msg
|
||||
self.db.addMsg(msg)
|
||||
super(ChannelStats, self).__call__(irc, msg)
|
||||
|
||||
def outFilter(self, irc, msg):
|
||||
if msg.command == 'PRIVMSG':
|
||||
if ircutils.isChannel(msg.args[0]):
|
||||
if self.registryValue('selfStats', msg.args[0]):
|
||||
try:
|
||||
self.outFiltering = True
|
||||
self.db.addMsg(msg, 0)
|
||||
finally:
|
||||
self.outFiltering = False
|
||||
return msg
|
||||
|
||||
def doQuit(self, irc, msg):
|
||||
try:
|
||||
id = ircdb.users.getUserId(msg.prefix)
|
||||
except KeyError:
|
||||
id = None
|
||||
for (channel, c) in self.laststate.channels.iteritems():
|
||||
if msg.nick in c.users:
|
||||
if (channel, 'channelStats') not in self.db:
|
||||
self.db[channel, 'channelStats'] = ChannelStat()
|
||||
self.db[channel, 'channelStats'].quits += 1
|
||||
if id is not None:
|
||||
if (channel, id) not in self.db:
|
||||
self.db[channel, id] = UserStat()
|
||||
self.db[channel, id].quits += 1
|
||||
|
||||
def doKick(self, irc, msg):
|
||||
(channel, nick, _) = msg.args
|
||||
hostmask = irc.state.nickToHostmask(nick)
|
||||
try:
|
||||
id = ircdb.users.getUserId(hostmask)
|
||||
except KeyError:
|
||||
return
|
||||
if channel not in self.db.channels:
|
||||
self.db.channels[channel] = {}
|
||||
if id not in self.db.channels[channel]:
|
||||
self.db.channels[channel][id] = UserStat()
|
||||
self.db.channels[channel][id].kicked += 1
|
||||
|
||||
def stats(self, irc, msg, args, channel, name):
|
||||
"""[<channel>] [<name>]
|
||||
|
||||
Returns the statistics for <name> on <channel>. <channel> is only
|
||||
necessary if the message isn't sent on the channel itself. If <name>
|
||||
isn't given, it defaults to the user sending the command.
|
||||
"""
|
||||
if name and ircutils.strEqual(name, irc.nick):
|
||||
id = 0
|
||||
elif not name:
|
||||
try:
|
||||
id = ircdb.users.getUserId(msg.prefix)
|
||||
name = ircdb.users.getUser(id).name
|
||||
except KeyError:
|
||||
irc.error('I couldn\'t find you in my user database.')
|
||||
return
|
||||
elif not ircdb.users.hasUser(name):
|
||||
try:
|
||||
hostmask = irc.state.nickToHostmask(name)
|
||||
id = ircdb.users.getUserId(hostmask)
|
||||
except KeyError:
|
||||
irc.errorNoUser()
|
||||
return
|
||||
else:
|
||||
id = ircdb.users.getUserId(name)
|
||||
try:
|
||||
stats = self.db.getUserStats(channel, id)
|
||||
s = format('%s has sent %n; a total of %n, %n, '
|
||||
'%n, and %n; %s of those messages %s'
|
||||
'%s has joined %n, parted %n, quit %n, '
|
||||
'kicked someone %n, been kicked %n, '
|
||||
'changed the topic %n, and changed the '
|
||||
'mode %n.',
|
||||
name, (stats.msgs, 'message'),
|
||||
(stats.chars, 'character'),
|
||||
(stats.words, 'word'),
|
||||
(stats.smileys, 'smiley'),
|
||||
(stats.frowns, 'frown'),
|
||||
stats.actions,
|
||||
stats.actions == 1 and 'was an ACTION. '
|
||||
or 'were ACTIONs. ',
|
||||
name,
|
||||
(stats.joins, 'time'),
|
||||
(stats.parts, 'time'),
|
||||
(stats.quits, 'time'),
|
||||
(stats.kicks, 'time'),
|
||||
(stats.kicked, 'time'),
|
||||
(stats.topics, 'time'),
|
||||
(stats.modes, 'time'))
|
||||
irc.reply(s)
|
||||
except KeyError:
|
||||
irc.error(format('I have no stats for that %s in %s.',
|
||||
name, channel))
|
||||
stats = wrap(stats, ['channeldb', additional('something')])
|
||||
|
||||
def channelstats(self, irc, msg, args, channel):
|
||||
"""[<channel>]
|
||||
|
||||
Returns the statistics for <channel>. <channel> is only necessary if
|
||||
the message isn't sent on the channel itself.
|
||||
"""
|
||||
try:
|
||||
stats = self.db.getChannelStats(channel)
|
||||
s = format('On %s there have been %i messages, containing %i '
|
||||
'characters, %n, %n, and %n; '
|
||||
'%i of those messages %s. There have been '
|
||||
'%n, %n, %n, %n, %n, and %n.',
|
||||
channel, stats.msgs, stats.chars,
|
||||
(stats.words, 'word'),
|
||||
(stats.smileys, 'smiley'),
|
||||
(stats.frowns, 'frown'),
|
||||
stats.actions, stats.actions == 1 and 'was an ACTION'
|
||||
or 'were ACTIONs',
|
||||
(stats.joins, 'join'),
|
||||
(stats.parts, 'part'),
|
||||
(stats.quits, 'quit'),
|
||||
(stats.kicks, 'kick'),
|
||||
(stats.modes, 'mode', 'change'),
|
||||
(stats.topics, 'topic', 'change'))
|
||||
irc.reply(s)
|
||||
except KeyError:
|
||||
irc.error(format('I\'ve never been on %s.', channel))
|
||||
channelstats = wrap(channelstats, ['channeldb'])
|
||||
|
||||
|
||||
Class = ChannelStats
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1,80 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2002-2004, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
from supybot.test import *
|
||||
|
||||
import supybot.ircdb as ircdb
|
||||
|
||||
class ChannelStatsTestCase(ChannelPluginTestCase):
|
||||
plugins = ('ChannelStats', 'User')
|
||||
def setUp(self):
|
||||
ChannelPluginTestCase.setUp(self)
|
||||
self.prefix = 'foo!bar@baz'
|
||||
self.nick = 'foo'
|
||||
self.irc.feedMsg(ircmsgs.privmsg(self.irc.nick,
|
||||
'register foo bar',
|
||||
prefix=self.prefix))
|
||||
_ = self.irc.takeMsg()
|
||||
chanop = ircdb.makeChannelCapability(self.channel, 'op')
|
||||
ircdb.users.getUser(self.nick).addCapability(chanop)
|
||||
|
||||
def test(self):
|
||||
self.assertNotError('channelstats')
|
||||
self.assertNotError('channelstats')
|
||||
self.assertNotError('channelstats')
|
||||
|
||||
def testStats(self):
|
||||
self.assertError('channelstats stats %s' % self.nick)
|
||||
self.assertNotError('channelstats stats %s' % self.nick)
|
||||
self.assertNotError('channelstats stats %s' % self.nick.upper())
|
||||
self.assertNotError('channelstats stats')
|
||||
self.assertRegexp('channelstats stats', self.nick)
|
||||
|
||||
def testSelfStats(self):
|
||||
self.assertError('channelstats stats %s' % self.irc.nick)
|
||||
self.assertNotError('channelstats stats %s' % self.irc.nick)
|
||||
self.assertNotError('channelstats stats %s' % self.irc.nick)
|
||||
self.assertNotError('channelstats stats %s' % self.irc.nick.upper())
|
||||
u = ircdb.users.getUser(self.prefix)
|
||||
u.addCapability(ircdb.makeChannelCapability(self.channel, 'op'))
|
||||
ircdb.users.setUser(u)
|
||||
try:
|
||||
conf.supybot.plugins.ChannelStats.selfStats.setValue(False)
|
||||
m1 = self.getMsg('channelstats stats %s' % self.irc.nick)
|
||||
m2 = self.getMsg('channelstats stats %s' % self.irc.nick)
|
||||
self.assertEqual(m1.args[1], m2.args[1])
|
||||
finally:
|
||||
conf.supybot.plugins.ChannelStats.selfStats.setValue(True)
|
||||
|
||||
def testNoKeyErrorStats(self):
|
||||
self.assertNotRegexp('stats sweede', 'KeyError')
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
||||
|
@ -1,55 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2004-2005, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
"""
|
||||
Handles configuration of the bot while it is running.
|
||||
"""
|
||||
|
||||
import supybot
|
||||
import supybot.world as world
|
||||
|
||||
# Use this for the version of this plugin. You may wish to put a CVS keyword
|
||||
# in here if you\'re keeping the plugin in CVS or some similar system.
|
||||
__version__ = "%%VERSION%%"
|
||||
|
||||
__author__ = supybot.authors.jemfinch
|
||||
|
||||
# This is a dictionary mapping supybot.Author instances to lists of
|
||||
# contributions.
|
||||
__contributors__ = {}
|
||||
|
||||
import config
|
||||
import plugin
|
||||
reload(plugin) # In case we're being reloaded.
|
||||
|
||||
if world.testing:
|
||||
import test
|
||||
|
||||
Class = plugin.Class
|
||||
configure = config.configure
|
@ -1,48 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2004-2005, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
|
||||
import supybot.conf as conf
|
||||
import supybot.registry as registry
|
||||
|
||||
def configure(advanced):
|
||||
# This will be called by supybot to configure this module. advanced is
|
||||
# a bool that specifies whether the user identified himself as an advanced
|
||||
# user or not. You should effect your configuration by manipulating the
|
||||
# registry as appropriate.
|
||||
from supybot.questions import expect, anything, something, yn
|
||||
conf.registerPlugin('Config', True)
|
||||
|
||||
|
||||
Config = conf.registerPlugin('Config')
|
||||
# This is where your configuration variables (if any) should go. For example:
|
||||
# conf.registerGlobalValue(Config, 'someConfigVariableName',
|
||||
# registry.Boolean(False, """Help for someConfigVariableName."""))
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1,267 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2002-2005, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
import os
|
||||
import signal
|
||||
|
||||
import supybot.log as log
|
||||
import supybot.conf as conf
|
||||
import supybot.utils as utils
|
||||
import supybot.world as world
|
||||
import supybot.ircdb as ircdb
|
||||
from supybot.commands import *
|
||||
from supybot.utils.iter import all
|
||||
import supybot.ircutils as ircutils
|
||||
import supybot.registry as registry
|
||||
import supybot.callbacks as callbacks
|
||||
|
||||
###
|
||||
# Now, to setup the registry.
|
||||
###
|
||||
|
||||
def getWrapper(name):
|
||||
parts = registry.split(name)
|
||||
if not parts or parts[0] not in ('supybot', 'users'):
|
||||
raise InvalidRegistryName, name
|
||||
group = getattr(conf, parts.pop(0))
|
||||
while parts:
|
||||
try:
|
||||
group = group.get(parts.pop(0))
|
||||
# We'll catch registry.InvalidRegistryName and re-raise it here so
|
||||
# that we have a useful error message for the user.
|
||||
except (registry.NonExistentRegistryEntry,
|
||||
registry.InvalidRegistryName):
|
||||
raise registry.InvalidRegistryName, name
|
||||
return group
|
||||
|
||||
def getCapability(name):
|
||||
capability = 'owner' # Default to requiring the owner capability.
|
||||
parts = registry.split(name)
|
||||
while parts:
|
||||
part = parts.pop()
|
||||
if ircutils.isChannel(part):
|
||||
# If a registry value has a channel in it, it requires a channel.op
|
||||
# capability, or so we assume. We'll see if we're proven wrong.
|
||||
capability = ircdb.makeChannelCapability(part, 'op')
|
||||
### Do more later, for specific capabilities/sections.
|
||||
return capability
|
||||
|
||||
def _reload():
|
||||
ircdb.users.reload()
|
||||
ircdb.ignores.reload()
|
||||
ircdb.channels.reload()
|
||||
registry.open(world.registryFilename)
|
||||
|
||||
def _hupHandler(sig, frame):
|
||||
log.info('Received SIGHUP, reloading configuration.')
|
||||
_reload()
|
||||
|
||||
if os.name == 'posix':
|
||||
signal.signal(signal.SIGHUP, _hupHandler)
|
||||
|
||||
|
||||
def getConfigVar(irc, msg, args, state):
|
||||
name = args[0]
|
||||
if name.startswith('conf.'):
|
||||
name = name[5:]
|
||||
if not name.startswith('supybot') and not name.startswith('users'):
|
||||
name = 'supybot.' + name
|
||||
try:
|
||||
group = getWrapper(name)
|
||||
state.args.append(group)
|
||||
del args[0]
|
||||
except registry.InvalidRegistryName, e:
|
||||
state.errorInvalid('configuration variable', str(e))
|
||||
addConverter('configVar', getConfigVar)
|
||||
|
||||
class Config(callbacks.Plugin):
|
||||
def callCommand(self, command, irc, msg, *args, **kwargs):
|
||||
try:
|
||||
super(Config, self).callCommand(command, irc, msg, *args, **kwargs)
|
||||
except registry.InvalidRegistryValue, e:
|
||||
irc.error(str(e))
|
||||
|
||||
def _list(self, group):
|
||||
L = []
|
||||
for (vname, v) in group._children.iteritems():
|
||||
if hasattr(group, 'channelValue') and group.channelValue and \
|
||||
ircutils.isChannel(vname) and not v._children:
|
||||
continue
|
||||
if hasattr(v, 'channelValue') and v.channelValue:
|
||||
vname = '#' + vname
|
||||
if v._added and not all(ircutils.isChannel, v._added):
|
||||
vname = '@' + vname
|
||||
L.append(vname)
|
||||
utils.sortBy(str.lower, L)
|
||||
return L
|
||||
|
||||
def list(self, irc, msg, args, group):
|
||||
"""<group>
|
||||
|
||||
Returns the configuration variables available under the given
|
||||
configuration <group>. If a variable has values under it, it is
|
||||
preceded by an '@' sign. If a variable is a 'ChannelValue', that is,
|
||||
it can be separately configured for each channel using the 'channel'
|
||||
command in this plugin, it is preceded by an '#' sign.
|
||||
"""
|
||||
L = self._list(group)
|
||||
if L:
|
||||
irc.reply(format('%L', L))
|
||||
else:
|
||||
irc.error('There don\'t seem to be any values in %s.' % group._name)
|
||||
list = wrap(list, ['configVar'])
|
||||
|
||||
def search(self, irc, msg, args, word):
|
||||
"""<word>
|
||||
|
||||
Searches for <word> in the current configuration variables.
|
||||
"""
|
||||
L = []
|
||||
for (name, _) in conf.supybot.getValues(getChildren=True):
|
||||
if word in name.lower():
|
||||
possibleChannel = registry.split(name)[-1]
|
||||
if not ircutils.isChannel(possibleChannel):
|
||||
L.append(name)
|
||||
if L:
|
||||
irc.reply(format('%L', L))
|
||||
else:
|
||||
irc.reply('There were no matching configuration variables.')
|
||||
search = wrap(search, ['lowered']) # XXX compose with withoutSpaces?
|
||||
|
||||
def _getValue(self, irc, msg, group):
|
||||
value = str(group) or ' '
|
||||
if hasattr(group, 'value'):
|
||||
if not group._private:
|
||||
irc.reply(value)
|
||||
else:
|
||||
capability = getCapability(group._name)
|
||||
if ircdb.checkCapability(msg.prefix, capability):
|
||||
irc.reply(value, private=True)
|
||||
else:
|
||||
irc.errorNoCapability(capability)
|
||||
else:
|
||||
irc.error('That registry variable has no value. Use the list '
|
||||
'command in this plugin to see what variables are '
|
||||
'available in this group.')
|
||||
|
||||
def _setValue(self, irc, msg, group, value):
|
||||
capability = getCapability(group._name)
|
||||
if ircdb.checkCapability(msg.prefix, capability):
|
||||
# I think callCommand catches exceptions here. Should it?
|
||||
group.set(value)
|
||||
irc.replySuccess()
|
||||
else:
|
||||
irc.errorNoCapability(capability)
|
||||
|
||||
def channel(self, irc, msg, args, channel, group, value):
|
||||
"""[<channel>] <name> [<value>]
|
||||
|
||||
If <value> is given, sets the channel configuration variable for <name>
|
||||
to <value> for <channel>. Otherwise, returns the current channel
|
||||
configuration value of <name>. <channel> is only necessary if the
|
||||
message isn't sent in the channel itself."""
|
||||
if not group.channelValue:
|
||||
irc.error('That configuration variable is not a channel-specific '
|
||||
'configuration variable.')
|
||||
return
|
||||
group = group.get(channel)
|
||||
if value is not None:
|
||||
self._setValue(irc, msg, group, value)
|
||||
else:
|
||||
self._getValue(irc, msg, group)
|
||||
channel = wrap(channel, ['channel', 'configVar', additional('text')])
|
||||
|
||||
def config(self, irc, msg, args, group, value):
|
||||
"""<name> [<value>]
|
||||
|
||||
If <value> is given, sets the value of <name> to <value>. Otherwise,
|
||||
returns the current value of <name>. You may omit the leading
|
||||
"supybot." in the name if you so choose.
|
||||
"""
|
||||
if value is not None:
|
||||
self._setValue(irc, msg, group, value)
|
||||
else:
|
||||
self._getValue(irc, msg, group)
|
||||
config = wrap(config, ['configVar', additional('text')])
|
||||
|
||||
def help(self, irc, msg, args, group):
|
||||
"""<name>
|
||||
|
||||
Returns the description of the configuration variable <name>.
|
||||
"""
|
||||
if hasattr(group, '_help'):
|
||||
s = group.help()
|
||||
if s:
|
||||
if hasattr(group, 'value') and not group._private:
|
||||
s += ' (Current value: %s)' % group
|
||||
irc.reply(s)
|
||||
else:
|
||||
irc.reply('That configuration group exists, but seems to have '
|
||||
'no help. Try "config list %s" to see if it has '
|
||||
'any children values.')
|
||||
else:
|
||||
irc.error('%s has no help.' % name)
|
||||
help = wrap(help, ['configVar'])
|
||||
|
||||
def default(self, irc, msg, args, group):
|
||||
"""<name>
|
||||
|
||||
Returns the default value of the configuration variable <name>.
|
||||
"""
|
||||
v = group.__class__(group._default, '')
|
||||
irc.reply(str(v))
|
||||
default = wrap(default, ['configVar'])
|
||||
|
||||
def reload(self, irc, msg, args):
|
||||
"""takes no arguments
|
||||
|
||||
Reloads the various configuration files (user database, channel
|
||||
database, registry, etc.).
|
||||
"""
|
||||
_reload() # This was factored out for SIGHUP handling.
|
||||
irc.replySuccess()
|
||||
reload = wrap(reload, [('checkCapability', 'owner')])
|
||||
|
||||
def export(self, irc, msg, args, filename):
|
||||
"""<filename>
|
||||
|
||||
Exports the public variables of your configuration to <filename>.
|
||||
If you want to show someone your configuration file, but you don't
|
||||
want that person to be able to see things like passwords, etc., this
|
||||
command will export a "sanitized" configuration file suitable for
|
||||
showing publicly.
|
||||
"""
|
||||
registry.close(conf.supybot, filename, private=False)
|
||||
irc.replySuccess()
|
||||
export = wrap(export, [('checkCapability', 'owner'), 'filename'])
|
||||
|
||||
|
||||
Class = Config
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1,83 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2002-2005, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
from supybot.test import *
|
||||
|
||||
import supybot.conf as conf
|
||||
|
||||
class ConfigTestCase(ChannelPluginTestCase):
|
||||
# We add utilities so there's something in supybot.plugins.
|
||||
plugins = ('Config', 'Utilities')
|
||||
def testGet(self):
|
||||
self.assertNotRegexp('config get supybot.reply', r'registry\.Group')
|
||||
self.assertResponse('config supybot.protocols.irc.throttleTime', '0.0')
|
||||
|
||||
def testList(self):
|
||||
self.assertError('config list asldfkj')
|
||||
self.assertError('config list supybot.asdfkjsldf')
|
||||
self.assertNotError('config list supybot')
|
||||
self.assertNotError('config list supybot.replies')
|
||||
self.assertRegexp('config list supybot', r'@plugins.*@replies.*@reply')
|
||||
|
||||
def testHelp(self):
|
||||
self.assertError('config help alsdkfj')
|
||||
self.assertError('config help supybot.alsdkfj')
|
||||
self.assertNotError('config help supybot') # We tell the user to list.
|
||||
self.assertNotError('config help supybot.plugins')
|
||||
self.assertNotError('config help supybot.replies.success')
|
||||
self.assertNotError('config help replies.success')
|
||||
|
||||
def testHelpDoesNotAssertionError(self):
|
||||
self.assertNotRegexp('config help ' # Cont'd.
|
||||
'supybot.commands.defaultPlugins.help',
|
||||
'AssertionError')
|
||||
|
||||
def testHelpExhaustively(self):
|
||||
L = conf.supybot.getValues(getChildren=True)
|
||||
for (name, v) in L:
|
||||
self.assertNotError('config help %s' % name)
|
||||
|
||||
def testSearch(self):
|
||||
self.assertNotError('config search chars')
|
||||
self.assertNotError('config channel reply.whenAddressedBy.chars @')
|
||||
self.assertNotRegexp('config search chars', self.channel)
|
||||
|
||||
def testDefault(self):
|
||||
self.assertNotError('config default '
|
||||
'supybot.replies.genericNoCapability')
|
||||
|
||||
def testConfigErrors(self):
|
||||
self.assertRegexp('config supybot.replies.', 'not a valid')
|
||||
self.assertRegexp('config supybot.repl', 'not a valid')
|
||||
self.assertRegexp('config supybot.reply.withNickPrefix 123',
|
||||
'True or False')
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
||||
|
@ -1 +0,0 @@
|
||||
Insert a description of your plugin here, with any notes, etc. about using it.
|
@ -1,59 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2005, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
"""
|
||||
Handles standard CTCP responses to PING, TIME, SOURCE, VERSION, USERINFO,
|
||||
and FINGER.
|
||||
"""
|
||||
|
||||
import supybot
|
||||
import supybot.world as world
|
||||
|
||||
__version__ = "%%VERSION%%"
|
||||
|
||||
__author__ = supybot.authors.jemfinch
|
||||
|
||||
# This is a dictionary mapping supybot.Author instances to lists of
|
||||
# contributions.
|
||||
__contributors__ = {}
|
||||
|
||||
import config
|
||||
import plugin
|
||||
reload(plugin) # In case we're being reloaded.
|
||||
# Add more reloads here if you add third-party modules and want them to be
|
||||
# reloaded when this plugin is reloaded. Don't forget to import them as well!
|
||||
|
||||
if world.testing:
|
||||
import test
|
||||
|
||||
Class = plugin.Class
|
||||
configure = config.configure
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1,68 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2005, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
import supybot.conf as conf
|
||||
import supybot.registry as registry
|
||||
|
||||
def configure(advanced):
|
||||
# This will be called by supybot to configure this module. advanced is
|
||||
# a bool that specifies whether the user identified himself as an advanced
|
||||
# user or not. You should effect your configuration by manipulating the
|
||||
# registry as appropriate.
|
||||
from supybot.questions import expect, anything, something, yn
|
||||
conf.registerPlugin('Ctcp', True)
|
||||
|
||||
|
||||
###
|
||||
# Ctcp plugin configuration variables.
|
||||
###
|
||||
Ctcp = conf.registerPlugin('Ctcp')
|
||||
conf.registerGlobalValue(Ctcp, 'versionWait',
|
||||
registry.PositiveInteger(10, """Determines how many seconds the bot will
|
||||
wait after getting a version command (not a CTCP VERSION, but an actual
|
||||
call of the command in this plugin named "version") before replying with
|
||||
the results it has collected."""))
|
||||
|
||||
###
|
||||
# supybot.abuse configuration variables.
|
||||
###
|
||||
conf.registerGlobalValue(conf.supybot.abuse.flood, 'ctcp',
|
||||
registry.Boolean(True, """Determines whether the bot will defend itself
|
||||
against CTCP flooding."""))
|
||||
conf.registerGlobalValue(conf.supybot.abuse.flood.ctcp, 'maximum',
|
||||
registry.PositiveInteger(5, """Determines how many CTCP messages (not
|
||||
including actions) the bot will reply to from a given user in a minute.
|
||||
If a user sends more than this many CTCP messages in a 60 second period,
|
||||
the bot will ignore CTCP messages from this user for
|
||||
supybot.abuse.flood.ctcp.punishment seconds."""))
|
||||
conf.registerGlobalValue(conf.supybot.abuse.flood.ctcp, 'punishment',
|
||||
registry.PositiveInteger(300, """Determines how many seconds the bot will
|
||||
ignore CTCP messages from users who flood it with CTCP messages."""))
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1,150 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2002-2004, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
import time
|
||||
|
||||
import supybot.conf as conf
|
||||
import supybot.utils as utils
|
||||
from supybot.commands import *
|
||||
import supybot.ircmsgs as ircmsgs
|
||||
import supybot.ircutils as ircutils
|
||||
import supybot.schedule as schedule
|
||||
import supybot.callbacks as callbacks
|
||||
|
||||
class Ctcp(callbacks.PluginRegexp):
|
||||
public = False
|
||||
regexps = ('ctcpPing', 'ctcpVersion', 'ctcpUserinfo',
|
||||
'ctcpTime', 'ctcpFinger', 'ctcpSource')
|
||||
def __init__(self, irc):
|
||||
self.__parent = super(Ctcp, self)
|
||||
self.__parent.__init__(irc)
|
||||
self.ignores = ircutils.IrcDict()
|
||||
self.floods = ircutils.FloodQueue(60)
|
||||
|
||||
def callCommand(self, command, irc, msg, *args, **kwargs):
|
||||
if conf.supybot.abuse.flood.ctcp():
|
||||
now = time.time()
|
||||
for (ignore, expiration) in self.ignores.items():
|
||||
if expiration < now:
|
||||
del self.ignores[ignore]
|
||||
elif ircutils.hostmaskPatternEqual(ignore, msg.prefix):
|
||||
return
|
||||
self.floods.enqueue(msg)
|
||||
max = conf.supybot.abuse.flood.ctcp.maximum()
|
||||
if self.floods.len(msg) > max:
|
||||
expires = conf.supybot.abuse.flood.ctcp.punishment()
|
||||
self.log.warning('Apparent CTCP flood from %s, '
|
||||
'ignoring CTCP messages for %s seconds.',
|
||||
msg.prefix, expires)
|
||||
ignoreMask = '*!%s@%s' % (msg.user, msg.host)
|
||||
self.ignores[ignoreMask] = now + expires
|
||||
return
|
||||
self.__parent.callCommand(command, irc, msg, *args, **kwargs)
|
||||
|
||||
def _reply(self, irc, msg, s):
|
||||
s = '\x01%s\x01' % s
|
||||
irc.reply(s, notice=True, private=True, to=msg.nick)
|
||||
|
||||
def ctcpPing(self, irc, msg, match):
|
||||
"\x01PING ?(.*)\x01"
|
||||
self.log.info('Received CTCP PING from %s', msg.prefix)
|
||||
payload = match.group(1)
|
||||
if payload:
|
||||
self._reply(irc, msg, 'PING %s' % match.group(1))
|
||||
else:
|
||||
self._reply(irc, msg, 'PING')
|
||||
|
||||
def ctcpVersion(self, irc, msg, match):
|
||||
"\x01VERSION\x01"
|
||||
self.log.info('Received CTCP VERSION from %s', msg.prefix)
|
||||
self._reply(irc, msg, 'VERSION Supybot %s' % conf.version)
|
||||
|
||||
def ctcpUserinfo(self, irc, msg, match):
|
||||
"\x01USERINFO\x01"
|
||||
self.log.info('Received CTCP USERINFO from %s', msg.prefix)
|
||||
self._reply(irc, msg, 'USERINFO')
|
||||
|
||||
def ctcpTime(self, irc, msg, match):
|
||||
"\x01TIME\x01"
|
||||
self.log.info('Received CTCP TIME from %s', msg.prefix)
|
||||
self._reply(irc, msg, 'TIME %s' % time.ctime())
|
||||
|
||||
def ctcpFinger(self, irc, msg, match):
|
||||
"\x01FINGER\x01"
|
||||
self.log.info('Received CTCP FINGER from %s', msg.prefix)
|
||||
self._reply(irc, msg,
|
||||
'FINGER Supybot, the best Python IRC bot in existence!')
|
||||
|
||||
def ctcpSource(self, irc, msg, match):
|
||||
"\x01SOURCE\x01"
|
||||
self.log.info('Received CTCP SOURCE from %s', msg.prefix)
|
||||
self._reply(irc, msg,
|
||||
'SOURCE http://www.sourceforge.net/projects/supybot/')
|
||||
|
||||
def doNotice(self, irc, msg):
|
||||
if ircmsgs.isCtcp(msg):
|
||||
try:
|
||||
(version, payload) = msg.args[1][1:-1].split(None, 1)
|
||||
except ValueError:
|
||||
return
|
||||
if version == 'VERSION':
|
||||
self.versions.setdefault(payload, []).append(msg.nick)
|
||||
|
||||
def version(self, irc, msg, args, channel, optlist):
|
||||
"""[<channel>] [--nicks]
|
||||
|
||||
Sends a CTCP VERSION to <channel>, returning the various
|
||||
version strings returned. It waits for 10 seconds before returning
|
||||
the versions received at that point. If --nicks is given, nicks are
|
||||
associated with the version strings; otherwise, only the version
|
||||
strings are given.
|
||||
"""
|
||||
self.versions = ircutils.IrcDict()
|
||||
nicks = False
|
||||
for (option, arg) in optlist:
|
||||
if option == 'nicks':
|
||||
nicks = True
|
||||
irc.queueMsg(ircmsgs.privmsg(channel, '\x01VERSION\x01'))
|
||||
def doReply():
|
||||
if self.versions:
|
||||
L = []
|
||||
for (reply, nicks) in self.versions.iteritems():
|
||||
if nicks:
|
||||
L.append(format('%L responded with %q', nicks, reply))
|
||||
else:
|
||||
L.append(reply)
|
||||
irc.reply(format('%L', L))
|
||||
else:
|
||||
irc.reply('I received no version responses.')
|
||||
wait = self.registryValue('versionWait')
|
||||
schedule.addEvent(doReply, time.time()+wait)
|
||||
version = wrap(version, ['channel', getopts({'nicks':''})])
|
||||
|
||||
Class = Ctcp
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1,37 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2002-2004, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
from supybot.test import *
|
||||
|
||||
class CtcpTestCase(PluginTestCase):
|
||||
plugins = ('Ctcp',)
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
||||
|
@ -1 +0,0 @@
|
||||
Insert a description of your plugin here, with any notes, etc. about using it.
|
@ -1,58 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2004, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
"""
|
||||
Commands that use the dictd protocol to define word.
|
||||
"""
|
||||
|
||||
import supybot
|
||||
import supybot.world as world
|
||||
|
||||
# Use this for the version of this plugin. You may wish to put a CVS keyword
|
||||
# in here if you\'re keeping the plugin in CVS or some similar system.
|
||||
__version__ = "%%VERSION%%"
|
||||
|
||||
__author__ = supybot.authors.jemfinch
|
||||
|
||||
# This is a dictionary mapping supybot.Author instances to lists of
|
||||
# contributions.
|
||||
__contributors__ = {}
|
||||
|
||||
import config
|
||||
import plugin
|
||||
reload(plugin) # In case we're being reloaded.
|
||||
|
||||
if world.testing:
|
||||
import test
|
||||
|
||||
Class = plugin.Class
|
||||
configure = config.configure
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1,50 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2004, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
import supybot.conf as conf
|
||||
import supybot.registry as registry
|
||||
|
||||
def configure(advanced):
|
||||
from supybot.questions import output, expect, anything, something, yn
|
||||
conf.registerPlugin('Dict', True)
|
||||
output('The default dictd server is dict.org.')
|
||||
if yn('Would you like to specify a different dictd server?'):
|
||||
server = something('What server?')
|
||||
conf.supybot.plugins.Dict.server.set(server)
|
||||
|
||||
Dict = conf.registerPlugin('Dict')
|
||||
conf.registerGlobalValue(Dict, 'server',
|
||||
registry.String('dict.org', """Determines what server the bot will
|
||||
retrieve definitions from."""))
|
||||
conf.registerChannelValue(Dict, 'default',
|
||||
registry.String('', """Determines the default dictionary the bot will
|
||||
ask for definitions in. If this value is '*' (without the quotes) the bot
|
||||
will use all dictionaries to define words."""))
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1,323 +0,0 @@
|
||||
# Client for the DICT protocol (RFC2229)
|
||||
#
|
||||
# Copyright (C) 2002 John Goerzen
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
# Retrieved from: http://gopher.quux.org:80/devel
|
||||
|
||||
import socket, re
|
||||
|
||||
version = '1.0'
|
||||
|
||||
def dequote(s):
|
||||
"""Will remove single or double quotes from the start and end of a string
|
||||
and return the result."""
|
||||
quotechars = "'\""
|
||||
while len(s) and s[0] in quotechars:
|
||||
s = s[1:]
|
||||
while len(s) and s[-1] in quotechars:
|
||||
s = s[0:-1]
|
||||
return s
|
||||
|
||||
def enquote(s):
|
||||
"""This function will put a string in double quotes, properly
|
||||
escaping any existing double quotes with a backslash. It will
|
||||
return the result."""
|
||||
return '"%s"' % s.replace('"', "\\\"")
|
||||
|
||||
class Connection:
|
||||
"""This class is used to establish a connection to a database server.
|
||||
You will usually use this as the first call into the dictclient library.
|
||||
Instantiating it takes two optional arguments: a hostname (a string)
|
||||
and a port (an int). The hostname defaults to localhost
|
||||
and the port to 2628, the port specified in RFC."""
|
||||
def __init__(self, hostname='localhost', port=2628):
|
||||
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
self.sock.connect((hostname, port))
|
||||
self.rfile = self.sock.makefile("rt")
|
||||
self.wfile = self.sock.makefile("wt", 0)
|
||||
self.saveconnectioninfo()
|
||||
|
||||
def getresultcode(self):
|
||||
"""Generic function to get a result code. It will return a list
|
||||
consisting of two items: the integer result code and the text
|
||||
following. You will not usually use this function directly."""
|
||||
line = self.rfile.readline().strip()
|
||||
code, text = line.split(' ', 1)
|
||||
return [int(code), text]
|
||||
|
||||
def get200result(self):
|
||||
"""Used when expecting a single line of text -- a 200-class
|
||||
result. Returns [intcode, remaindertext]"""
|
||||
|
||||
code, text = self.getresultcode()
|
||||
if code < 200 or code >= 300:
|
||||
raise Exception, "Got '%s' when 200-class response expected" % \
|
||||
line
|
||||
return [code, text]
|
||||
|
||||
def get100block(self):
|
||||
"""Used when expecting multiple lines of text -- gets the block
|
||||
part only. Does not get any codes or anything! Returns a string."""
|
||||
data = []
|
||||
while 1:
|
||||
line = self.rfile.readline().strip()
|
||||
if line == '.':
|
||||
break
|
||||
data.append(line)
|
||||
return "\n".join(data)
|
||||
|
||||
def get100result(self):
|
||||
"""Used when expecting multiple lines of text, terminated by a period
|
||||
and a 200 code. Returns: [initialcode, [bodytext_1lineperentry],
|
||||
finalcode]"""
|
||||
code, text = self.getresultcode()
|
||||
if code < 100 or code >= 200:
|
||||
raise Exception, "Got '%s' when 100-class response expected" % \
|
||||
code
|
||||
|
||||
bodylines = self.get100block().split("\n")
|
||||
|
||||
code2 = self.get200result()[0]
|
||||
return [code, bodylines, code2]
|
||||
|
||||
def get100dict(self):
|
||||
"""Used when expecting a dictionary of results. Will read from
|
||||
the initial 100 code, to a period and the 200 code."""
|
||||
dict = {}
|
||||
for line in self.get100result()[1]:
|
||||
key, val = line.split(' ', 1)
|
||||
dict[key] = dequote(val)
|
||||
return dict
|
||||
|
||||
def saveconnectioninfo(self):
|
||||
"""Called by __init__ to handle the initial connection. Will
|
||||
save off the capabilities and messageid."""
|
||||
code, string = self.get200result()
|
||||
assert code == 220
|
||||
m = re.search('<(.*)> (<.*>)$', string)
|
||||
assert m is not None
|
||||
capstr, msgid = m.groups()
|
||||
self.capabilities = capstr.split('.')
|
||||
self.messageid = msgid
|
||||
|
||||
def getcapabilities(self):
|
||||
"""Returns a list of the capabilities advertised by the server."""
|
||||
return self.capabilities
|
||||
|
||||
def getmessageid(self):
|
||||
"""Returns the message id, including angle brackets."""
|
||||
return self.messageid
|
||||
|
||||
def getdbdescs(self):
|
||||
"""Gets a dict of available databases. The key is the db name
|
||||
and the value is the db description. This command may generate
|
||||
network traffic!"""
|
||||
if hasattr(self, 'dbdescs'):
|
||||
return self.dbdescs
|
||||
|
||||
self.sendcommand("SHOW DB")
|
||||
self.dbdescs = self.get100dict()
|
||||
return self.dbdescs
|
||||
|
||||
def getstratdescs(self):
|
||||
"""Gets a dict of available strategies. The key is the strat
|
||||
name and the value is the strat description. This call may
|
||||
generate network traffic!"""
|
||||
if hasattr(self, 'stratdescs'):
|
||||
return self.stratdescs
|
||||
|
||||
self.sendcommand("SHOW STRAT")
|
||||
self.stratdescs = self.get100dict()
|
||||
return self.stratdescs
|
||||
|
||||
def getdbobj(self, dbname):
|
||||
"""Gets a Database object corresponding to the database name passed
|
||||
in. This function explicitly will *not* generate network traffic.
|
||||
If you have not yet run getdbdescs(), it will fail."""
|
||||
if not hasattr(self, 'dbobjs'):
|
||||
self.dbobjs = {}
|
||||
|
||||
if self.dbobjs.has_key(dbname):
|
||||
return self.dbobjs[dbname]
|
||||
|
||||
# We use self.dbdescs explicitly since we don't want to
|
||||
# generate net traffic with this request!
|
||||
|
||||
if dbname != '*' and dbname != '!' and \
|
||||
not dbname in self.dbdescs.keys():
|
||||
raise Exception, "Invalid database name '%s'" % dbname
|
||||
|
||||
self.dbobjs[dbname] = Database(self, dbname)
|
||||
return self.dbobjs[dbname]
|
||||
|
||||
def sendcommand(self, command):
|
||||
"""Takes a command, without a newline character, and sends it to
|
||||
the server."""
|
||||
self.wfile.write(command + "\n")
|
||||
|
||||
def define(self, database, word):
|
||||
"""Returns a list of Definition objects for each matching
|
||||
definition. Parameters are the database name and the word
|
||||
to look up. This is one of the main functions you will use
|
||||
to interact with the server. Returns a list of Definition
|
||||
objects. If there are no matches, an empty list is returned.
|
||||
|
||||
Note: database may be '*' which means to search all databases,
|
||||
or '!' which means to return matches from the first database that
|
||||
has a match."""
|
||||
self.getdbdescs() # Prime the cache
|
||||
|
||||
if database != '*' and database != '!' and \
|
||||
not database in self.getdbdescs():
|
||||
raise Exception, "Invalid database '%s' specified" % database
|
||||
|
||||
self.sendcommand("DEFINE " + enquote(database) + " " + enquote(word))
|
||||
code = self.getresultcode()[0]
|
||||
|
||||
retval = []
|
||||
|
||||
if code == 552:
|
||||
# No definitions.
|
||||
return []
|
||||
if code != 150:
|
||||
raise Exception, "Unknown code %d" % code
|
||||
|
||||
while 1:
|
||||
code, text = self.getresultcode()
|
||||
if code != 151:
|
||||
break
|
||||
|
||||
m = re.search('^"(.+)" (\S+)', text)
|
||||
assert m is not None
|
||||
resultword, resultdb = m.groups()
|
||||
defstr = self.get100block()
|
||||
retval.append(Definition(self, self.getdbobj(resultdb),
|
||||
resultword, defstr))
|
||||
return retval
|
||||
|
||||
def match(self, database, strategy, word):
|
||||
"""Gets matches for a query. Arguments are database name,
|
||||
the strategy (see available ones in getstratdescs()), and the
|
||||
pattern/word to look for. Returns a list of Definition objects.
|
||||
If there is no match, an empty list is returned.
|
||||
|
||||
Note: database may be '*' which means to search all databases,
|
||||
or '!' which means to return matches from the first database that
|
||||
has a match."""
|
||||
self.getstratdescs() # Prime the cache
|
||||
self.getdbdescs() # Prime the cache
|
||||
if not strategy in self.getstratdescs().keys():
|
||||
raise Exception, "Invalid strategy '%s'" % strategy
|
||||
if database != '*' and database != '!' and \
|
||||
not database in self.getdbdescs().keys():
|
||||
raise Exception, "Invalid database name '%s'" % database
|
||||
|
||||
self.sendcommand("MATCH %s %s %s" % (enquote(database),
|
||||
enquote(strategy),
|
||||
enquote(word)))
|
||||
code = self.getresultcode()[0]
|
||||
if code == 552:
|
||||
# No Matches
|
||||
return []
|
||||
if code != 152:
|
||||
raise Exception, "Unexpected code %d" % code
|
||||
|
||||
retval = []
|
||||
|
||||
for matchline in self.get100block().split("\n"):
|
||||
matchdict, matchword = matchline.split(" ", 1)
|
||||
retval.append(Definition(self, self.getdbobj(matchdict),
|
||||
dequote(matchword)))
|
||||
if self.getresultcode()[0] != 250:
|
||||
raise Exception, "Unexpected end-of-list code %d" % code
|
||||
return retval
|
||||
|
||||
class Database:
|
||||
"""An object corresponding to a particular database in a server."""
|
||||
def __init__(self, dictconn, dbname):
|
||||
"""Initialize the object -- requires a Connection object and
|
||||
a database name."""
|
||||
self.conn = dictconn
|
||||
self.name = dbname
|
||||
|
||||
def getname(self):
|
||||
"""Returns the short name for this database."""
|
||||
return self.name
|
||||
|
||||
def getdescription(self):
|
||||
if hasattr(self, 'description'):
|
||||
return self.description
|
||||
if self.getname() == '*':
|
||||
self.description = 'All Databases'
|
||||
elif self.getname() == '!':
|
||||
self.description = 'First matching database'
|
||||
else:
|
||||
self.description = self.conn.getdbdescs()[self.getname()]
|
||||
return self.description
|
||||
|
||||
def getinfo(self):
|
||||
"""Returns a string of info describing this database."""
|
||||
if hasattr(self, 'info'):
|
||||
return self.info
|
||||
|
||||
if self.getname() == '*':
|
||||
self.info = "This special database will search all databases on the system."
|
||||
elif self.getname() == '!':
|
||||
self.info = "This special database will return matches from the first matching database."
|
||||
else:
|
||||
self.conn.sendcommand("SHOW INFO " + self.name)
|
||||
self.info = "\n".join(self.conn.get100result()[1])
|
||||
return self.info
|
||||
|
||||
def define(self, word):
|
||||
"""Get a definition from within this database.
|
||||
The argument, word, is the word to look up. The return value is the
|
||||
same as from Connection.define()."""
|
||||
return self.conn.define(self.getname(), word)
|
||||
|
||||
def match(self, strategy, word):
|
||||
"""Get a match from within this database.
|
||||
The argument, word, is the word to look up. The return value is
|
||||
the same as from Connection.define()."""
|
||||
return self.conn.match(self.getname(), strategy, word)
|
||||
|
||||
class Definition:
|
||||
"""An object corresponding to a single definition."""
|
||||
def __init__(self, dictconn, db, word, defstr = None):
|
||||
"""Instantiate the object. Requires: a Connection object,
|
||||
a Database object (NOT corresponding to '*' or '!' databases),
|
||||
a word. Optional: a definition string. If not supplied,
|
||||
it will be fetched if/when it is requested."""
|
||||
self.conn = dictconn
|
||||
self.db = db
|
||||
self.word = word
|
||||
self.defstr = defstr
|
||||
|
||||
def getdb(self):
|
||||
"""Get the Database object corresponding to this definition."""
|
||||
return self.db
|
||||
|
||||
def getdefstr(self):
|
||||
"""Get the definition string (the actual content) of this
|
||||
definition."""
|
||||
if not self.defstr:
|
||||
self.defstr = self.conn.define(self.getdb().getname(), self.word)[0].getdefstr()
|
||||
return self.defstr
|
||||
|
||||
def getword(self):
|
||||
"""Get the word this object describes."""
|
||||
return self.word
|
@ -1,124 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2002-2004, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
import socket
|
||||
|
||||
import dictclient
|
||||
|
||||
import supybot.conf as conf
|
||||
import supybot.utils as utils
|
||||
from supybot.commands import *
|
||||
import supybot.ircutils as ircutils
|
||||
import supybot.callbacks as callbacks
|
||||
|
||||
class Dict(callbacks.Plugin):
|
||||
threaded = True
|
||||
def dictionaries(self, irc, msg, args):
|
||||
"""takes no arguments
|
||||
|
||||
Returns the dictionaries valid for the dict command.
|
||||
"""
|
||||
try:
|
||||
server = conf.supybot.plugins.Dict.server()
|
||||
conn = dictclient.Connection(server)
|
||||
dbs = list(conn.getdbdescs().keys())
|
||||
dbs.sort()
|
||||
irc.reply(format('%L', dbs))
|
||||
except socket.error, e:
|
||||
irc.error(utils.web.strError(e))
|
||||
dictionaries = wrap(dictionaries)
|
||||
|
||||
def random(self, irc, msg, args):
|
||||
"""takes no arguments
|
||||
|
||||
Returns a random valid dictionary.
|
||||
"""
|
||||
try:
|
||||
server = conf.supybot.plugins.Dict.server()
|
||||
conn = dictclient.Connection(server)
|
||||
dbs = conn.getdbdescs().keys()
|
||||
irc.reply(utils.iter.choice(dbs))
|
||||
except socket.error, e:
|
||||
irc.error(utils.web.strError(e))
|
||||
random = wrap(random)
|
||||
|
||||
def dict(self, irc, msg, args, words):
|
||||
"""[<dictionary>] <word>
|
||||
|
||||
Looks up the definition of <word> on dict.org's dictd server.
|
||||
"""
|
||||
try:
|
||||
server = conf.supybot.plugins.Dict.server()
|
||||
conn = dictclient.Connection(server)
|
||||
except socket.error, e:
|
||||
irc.error(utils.web.strError(e), Raise=True)
|
||||
dbs = set(conn.getdbdescs())
|
||||
if words[0] in dbs:
|
||||
dictionary = words.pop(0)
|
||||
else:
|
||||
default = self.registryValue('default', msg.args[0])
|
||||
if default in dbs:
|
||||
dictionary = default
|
||||
else:
|
||||
if default:
|
||||
self.log.info('Default dict for %s is not a supported '
|
||||
'dictionary: %s.', msg.args[0], default)
|
||||
dictionary = '*'
|
||||
if not words:
|
||||
irc.error('You must give a word to define.', Raise=True)
|
||||
word = ' '.join(words)
|
||||
definitions = conn.define(dictionary, word)
|
||||
dbs = set()
|
||||
if not definitions:
|
||||
if dictionary == '*':
|
||||
irc.reply(format('No definition for %q could be found.', word))
|
||||
else:
|
||||
irc.reply(format('No definition for %q could be found in %s',
|
||||
word, ircutils.bold(dictionary)))
|
||||
return
|
||||
L = []
|
||||
for d in definitions:
|
||||
dbs.add(ircutils.bold(d.getdb().getname()))
|
||||
(db, s) = (d.getdb().getname(), d.getdefstr())
|
||||
db = ircutils.bold(db)
|
||||
s = utils.str.normalizeWhitespace(s).rstrip(';.,')
|
||||
L.append('%s: %s' % (db, s))
|
||||
utils.sortBy(len, L)
|
||||
if dictionary == '*' and len(dbs) > 1:
|
||||
s = format('%L responded: %s', list(dbs), '; '.join(L))
|
||||
else:
|
||||
s = '; '.join(L)
|
||||
irc.reply(s)
|
||||
dict = wrap(dict, [many('something')])
|
||||
|
||||
|
||||
Class = Dict
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1,47 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2002-2004, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
from supybot.test import *
|
||||
|
||||
class DictTestCase(PluginTestCase):
|
||||
plugins = ('Dict',)
|
||||
if network:
|
||||
def testDict(self):
|
||||
self.assertNotError('dict slash')
|
||||
self.assertNotRegexp('dict web1913 slash', 'foldoc')
|
||||
self.assertError('dict ""')
|
||||
|
||||
def testDictionaries(self):
|
||||
self.assertNotError('dictionaries')
|
||||
|
||||
def testRandomDictionary(self):
|
||||
self.assertNotError('random')
|
||||
self.assertNotError('dict [random] moo')
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1 +0,0 @@
|
||||
Insert a description of your plugin here, with any notes, etc. about using it.
|
@ -1,64 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2002-2005, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
"""
|
||||
Handles 'factoids,' little tidbits of information held in a database and
|
||||
available on demand via several commands.
|
||||
"""
|
||||
|
||||
import supybot
|
||||
import supybot.world as world
|
||||
|
||||
# Use this for the version of this plugin. You may wish to put a CVS keyword
|
||||
# in here if you're keeping the plugin in CVS or some similar system.
|
||||
__version__ = "0.1"
|
||||
|
||||
__author__ = supybot.authors.jemfinch
|
||||
|
||||
# This is a dictionary mapping supybot.Author instances to lists of
|
||||
# contributions.
|
||||
__contributors__ = {}
|
||||
|
||||
# This is a url where the most recent plugin package can be downloaded.
|
||||
__url__ = '' # 'http://supybot.com/Members/yourname/Factoids/download'
|
||||
|
||||
import config
|
||||
import plugin
|
||||
reload(plugin) # In case we're being reloaded.
|
||||
# Add more reloads here if you add third-party modules and want them to be
|
||||
# reloaded when this plugin is reloaded. Don't forget to import them as well!
|
||||
|
||||
if world.testing:
|
||||
import test
|
||||
|
||||
Class = plugin.Class
|
||||
configure = config.configure
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1,61 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2002-2005, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
import supybot.conf as conf
|
||||
import supybot.registry as registry
|
||||
|
||||
def configure(advanced):
|
||||
# This will be called by supybot to configure this module. advanced is
|
||||
# a bool that specifies whether the user identified himself as an advanced
|
||||
# user or not. You should effect your configuration by manipulating the
|
||||
# registry as appropriate.
|
||||
from supybot.questions import expect, anything, something, yn
|
||||
conf.registerPlugin('Factoids', True)
|
||||
|
||||
|
||||
Factoids = conf.registerPlugin('Factoids')
|
||||
conf.registerChannelValue(Factoids, 'learnSeparator',
|
||||
registry.String('as', """Determines what separator must be used in the
|
||||
learn command. Defaults to 'as' -- learn <key> as <value>. Users might
|
||||
feel more comfortable with 'is' or something else, so it's
|
||||
configurable."""))
|
||||
conf.registerChannelValue(Factoids, 'showFactoidIfOnlyOneMatch',
|
||||
registry.Boolean(True, """Determines whether the bot will reply with the
|
||||
single matching factoid if only one factoid matches when using the search
|
||||
command."""))
|
||||
conf.registerChannelValue(Factoids, 'replyWhenInvalidCommand',
|
||||
registry.Boolean(True, """Determines whether the bot will reply to invalid
|
||||
commands by searching for a factoid; basically making the whatis
|
||||
unnecessary when you want all factoids for a given key."""))
|
||||
conf.registerChannelValue(Factoids, 'factoidPrefix',
|
||||
registry.StringWithSpaceOnRight('could be ', """Determines the string that
|
||||
factoids will be introduced by."""))
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1,408 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2002-2005, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
import os
|
||||
import time
|
||||
import string
|
||||
|
||||
import supybot.conf as conf
|
||||
import supybot.ircdb as ircdb
|
||||
import supybot.utils as utils
|
||||
from supybot.commands import *
|
||||
import supybot.plugins as plugins
|
||||
import supybot.ircutils as ircutils
|
||||
import supybot.callbacks as callbacks
|
||||
|
||||
try:
|
||||
import sqlite
|
||||
except ImportError:
|
||||
raise callbacks.Error, 'You need to have PySQLite installed to use this ' \
|
||||
'plugin. Download it at <http://pysqlite.sf.net/>'
|
||||
|
||||
def getFactoid(irc, msg, args, state):
|
||||
assert not state.channel
|
||||
callConverter('channel', irc, msg, args, state)
|
||||
separator = state.cb.registryValue('learnSeparator', state.channel)
|
||||
try:
|
||||
i = args.index(separator)
|
||||
except ValueError:
|
||||
raise callbacks.ArgumentError
|
||||
args.pop(i)
|
||||
key = []
|
||||
value = []
|
||||
for (j, s) in enumerate(args[:]):
|
||||
if j < i:
|
||||
key.append(args.pop(0))
|
||||
else:
|
||||
value.append(args.pop(0))
|
||||
state.args.append(' '.join(key))
|
||||
state.args.append(' '.join(value))
|
||||
|
||||
def getFactoidId(irc, msg, args, state):
|
||||
Type = 'key id'
|
||||
p = lambda i: i > 0
|
||||
callConverter('int', irc, msg, args, state, Type, p)
|
||||
|
||||
addConverter('factoid', getFactoid)
|
||||
addConverter('factoidId', getFactoidId)
|
||||
|
||||
class Factoids(callbacks.Plugin, plugins.ChannelDBHandler):
|
||||
def makeDb(self, filename):
|
||||
if os.path.exists(filename):
|
||||
return sqlite.connect(filename)
|
||||
db = sqlite.connect(filename)
|
||||
cursor = db.cursor()
|
||||
cursor.execute("""CREATE TABLE keys (
|
||||
id INTEGER PRIMARY KEY,
|
||||
key TEXT UNIQUE ON CONFLICT IGNORE,
|
||||
locked BOOLEAN
|
||||
)""")
|
||||
cursor.execute("""CREATE TABLE factoids (
|
||||
id INTEGER PRIMARY KEY,
|
||||
key_id INTEGER,
|
||||
added_by TEXT,
|
||||
added_at TIMESTAMP,
|
||||
fact TEXT
|
||||
)""")
|
||||
cursor.execute("""CREATE TRIGGER remove_factoids
|
||||
BEFORE DELETE ON keys
|
||||
BEGIN
|
||||
DELETE FROM factoids WHERE key_id = old.id;
|
||||
END
|
||||
""")
|
||||
db.commit()
|
||||
return db
|
||||
|
||||
def learn(self, irc, msg, args, channel, key, factoid):
|
||||
"""[<channel>] <key> as <value>
|
||||
|
||||
Associates <key> with <value>. <channel> is only necessary if the
|
||||
message isn't sent on the channel itself. The word 'as' is necessary
|
||||
to separate the key from the value. It can be changed to another
|
||||
word via the learnSeparator registry value.
|
||||
"""
|
||||
db = self.getDb(channel)
|
||||
cursor = db.cursor()
|
||||
cursor.execute("SELECT id, locked FROM keys WHERE key LIKE %s", key)
|
||||
if cursor.rowcount == 0:
|
||||
cursor.execute("""INSERT INTO keys VALUES (NULL, %s, 0)""", key)
|
||||
db.commit()
|
||||
cursor.execute("SELECT id, locked FROM keys WHERE key LIKE %s",key)
|
||||
(id, locked) = map(int, cursor.fetchone())
|
||||
capability = ircdb.makeChannelCapability(channel, 'factoids')
|
||||
if not locked:
|
||||
if ircdb.users.hasUser(msg.prefix):
|
||||
name = ircdb.users.getUser(msg.prefix).name
|
||||
else:
|
||||
name = msg.nick
|
||||
cursor.execute("""INSERT INTO factoids VALUES
|
||||
(NULL, %s, %s, %s, %s)""",
|
||||
id, name, int(time.time()), factoid)
|
||||
db.commit()
|
||||
irc.replySuccess()
|
||||
else:
|
||||
irc.error('That factoid is locked.')
|
||||
learn = wrap(learn, ['factoid'])
|
||||
|
||||
def _lookupFactoid(self, channel, key):
|
||||
db = self.getDb(channel)
|
||||
cursor = db.cursor()
|
||||
cursor.execute("""SELECT factoids.fact FROM factoids, keys
|
||||
WHERE keys.key LIKE %s AND factoids.key_id=keys.id
|
||||
ORDER BY factoids.id
|
||||
LIMIT 20""", key)
|
||||
return [t[0] for t in cursor.fetchall()]
|
||||
|
||||
def _replyFactoids(self, irc, channel, key, factoids,
|
||||
number=0, error=True):
|
||||
if factoids:
|
||||
if number:
|
||||
try:
|
||||
irc.reply(factoids[number-1])
|
||||
except IndexError:
|
||||
irc.error('That\'s not a valid number for that key.')
|
||||
return
|
||||
else:
|
||||
intro = self.registryValue('factoidPrefix', channel)
|
||||
prefix = format('%q %s', key, intro)
|
||||
if len(factoids) == 1:
|
||||
irc.reply(prefix + factoids[0])
|
||||
else:
|
||||
factoidsS = []
|
||||
counter = 1
|
||||
for factoid in factoids:
|
||||
factoidsS.append(format('(#%i) %s', counter, factoid))
|
||||
counter += 1
|
||||
irc.replies(factoidsS, prefixer=prefix,
|
||||
joiner=', or ', onlyPrefixFirst=True)
|
||||
elif error:
|
||||
irc.error('No factoid matches that key.')
|
||||
|
||||
def invalidCommand(self, irc, msg, tokens):
|
||||
if irc.isChannel(msg.args[0]):
|
||||
channel = msg.args[0]
|
||||
if self.registryValue('replyWhenInvalidCommand', channel):
|
||||
key = ' '.join(tokens)
|
||||
factoids = self._lookupFactoid(channel, key)
|
||||
self._replyFactoids(irc, channel, key, factoids, error=False)
|
||||
|
||||
def whatis(self, irc, msg, args, channel, words):
|
||||
"""[<channel>] <key> [<number>]
|
||||
|
||||
Looks up the value of <key> in the factoid database. If given a
|
||||
number, will return only that exact factoid. <channel> is only
|
||||
necessary if the message isn't sent in the channel itself.
|
||||
"""
|
||||
number = None
|
||||
if len(words) > 1:
|
||||
if words[-1].isdigit():
|
||||
number = int(words.pop())
|
||||
if number <= 0:
|
||||
irc.errorInvalid('key id')
|
||||
key = ' '.join(words)
|
||||
factoids = self._lookupFactoid(channel, key)
|
||||
self._replyFactoids(irc, channel, key, factoids, number)
|
||||
whatis = wrap(whatis, ['channel', many('something')])
|
||||
|
||||
def lock(self, irc, msg, args, channel, key):
|
||||
"""[<channel>] <key>
|
||||
|
||||
Locks the factoid(s) associated with <key> so that they cannot be
|
||||
removed or added to. <channel> is only necessary if the message isn't
|
||||
sent in the channel itself.
|
||||
"""
|
||||
db = self.getDb(channel)
|
||||
cursor = db.cursor()
|
||||
cursor.execute("UPDATE keys SET locked=1 WHERE key LIKE %s", key)
|
||||
db.commit()
|
||||
irc.replySuccess()
|
||||
lock = wrap(lock, ['channel', 'text'])
|
||||
|
||||
def unlock(self, irc, msg, args, channel, key):
|
||||
"""[<channel>] <key>
|
||||
|
||||
Unlocks the factoid(s) associated with <key> so that they can be
|
||||
removed or added to. <channel> is only necessary if the message isn't
|
||||
sent in the channel itself.
|
||||
"""
|
||||
db = self.getDb(channel)
|
||||
cursor = db.cursor()
|
||||
cursor.execute("UPDATE keys SET locked=0 WHERE key LIKE %s", key)
|
||||
db.commit()
|
||||
irc.replySuccess()
|
||||
unlock = wrap(unlock, ['channel', 'text'])
|
||||
|
||||
def forget(self, irc, msg, args, channel, words):
|
||||
"""[<channel>] <key> [<number>|*]
|
||||
|
||||
Removes the factoid <key> from the factoids database. If there are
|
||||
more than one factoid with such a key, a number is necessary to
|
||||
determine which one should be removed. A * can be used to remove all
|
||||
factoids associated with a key. <channel> is only necessary if
|
||||
the message isn't sent in the channel itself.
|
||||
"""
|
||||
number = None
|
||||
if len(words) > 1:
|
||||
if words[-1].isdigit():
|
||||
number = int(words.pop())
|
||||
if number <= 0:
|
||||
irc.errorInvalid('key id')
|
||||
elif words[-1] == '*':
|
||||
words.pop()
|
||||
number = True
|
||||
key = ' '.join(words)
|
||||
db = self.getDb(channel)
|
||||
cursor = db.cursor()
|
||||
cursor.execute("""SELECT keys.id, factoids.id
|
||||
FROM keys, factoids
|
||||
WHERE key LIKE %s AND
|
||||
factoids.key_id=keys.id""", key)
|
||||
if cursor.rowcount == 0:
|
||||
irc.error('There is no such factoid.')
|
||||
elif cursor.rowcount == 1 or number is True:
|
||||
(id, _) = cursor.fetchone()
|
||||
cursor.execute("""DELETE FROM factoids WHERE key_id=%s""", id)
|
||||
cursor.execute("""DELETE FROM keys WHERE key LIKE %s""", key)
|
||||
db.commit()
|
||||
irc.replySuccess()
|
||||
else:
|
||||
if number is not None:
|
||||
results = cursor.fetchall()
|
||||
try:
|
||||
(_, id) = results[number-1]
|
||||
except IndexError:
|
||||
irc.error('Invalid factoid number.')
|
||||
return
|
||||
cursor.execute("DELETE FROM factoids WHERE id=%s", id)
|
||||
db.commit()
|
||||
irc.replySuccess()
|
||||
else:
|
||||
irc.error('%s factoids have that key. '
|
||||
'Please specify which one to remove, '
|
||||
'or use * to designate all of them.' %
|
||||
cursor.rowcount)
|
||||
forget = wrap(forget, ['channel', many('something')])
|
||||
|
||||
def random(self, irc, msg, args, channel):
|
||||
"""[<channel>]
|
||||
|
||||
Returns a random factoid from the database for <channel>. <channel>
|
||||
is only necessary if the message isn't sent in the channel itself.
|
||||
"""
|
||||
db = self.getDb(channel)
|
||||
cursor = db.cursor()
|
||||
cursor.execute("""SELECT fact, key_id FROM factoids
|
||||
ORDER BY random()
|
||||
LIMIT 3""")
|
||||
if cursor.rowcount != 0:
|
||||
L = []
|
||||
for (factoid, id) in cursor.fetchall():
|
||||
cursor.execute("""SELECT key FROM keys WHERE id=%s""", id)
|
||||
(key,) = cursor.fetchone()
|
||||
L.append('"%s": %s' % (ircutils.bold(key), factoid))
|
||||
irc.reply('; '.join(L))
|
||||
else:
|
||||
irc.error('I couldn\'t find a factoid.')
|
||||
random = wrap(random, ['channel'])
|
||||
|
||||
def info(self, irc, msg, args, channel, key):
|
||||
"""[<channel>] <key>
|
||||
|
||||
Gives information about the factoid(s) associated with <key>.
|
||||
<channel> is only necessary if the message isn't sent in the channel
|
||||
itself.
|
||||
"""
|
||||
db = self.getDb(channel)
|
||||
cursor = db.cursor()
|
||||
cursor.execute("SELECT id, locked FROM keys WHERE key LIKE %s", key)
|
||||
if cursor.rowcount == 0:
|
||||
irc.error('No factoid matches that key.')
|
||||
return
|
||||
(id, locked) = map(int, cursor.fetchone())
|
||||
cursor.execute("""SELECT added_by, added_at FROM factoids
|
||||
WHERE key_id=%s
|
||||
ORDER BY id""", id)
|
||||
factoids = cursor.fetchall()
|
||||
L = []
|
||||
counter = 0
|
||||
for (added_by, added_at) in factoids:
|
||||
counter += 1
|
||||
added_at = time.strftime(conf.supybot.reply.format.time(),
|
||||
time.localtime(int(added_at)))
|
||||
L.append(format('#%i was added by %s at %s',
|
||||
counter, added_by, added_at))
|
||||
factoids = '; '.join(L)
|
||||
s = format('Key %q is %s and has %n associated with it: %s',
|
||||
key, locked and 'locked' or 'not locked',
|
||||
(counter, 'factoid'), factoids)
|
||||
irc.reply(s)
|
||||
info = wrap(info, ['channel', 'text'])
|
||||
|
||||
def change(self, irc, msg, args, channel, key, number, replacer):
|
||||
"""[<channel>] <key> <number> <regexp>
|
||||
|
||||
Changes the factoid #<number> associated with <key> according to
|
||||
<regexp>.
|
||||
"""
|
||||
db = self.getDb(channel)
|
||||
cursor = db.cursor()
|
||||
cursor.execute("""SELECT factoids.id, factoids.fact
|
||||
FROM keys, factoids
|
||||
WHERE keys.key LIKE %s AND
|
||||
keys.id=factoids.key_id""", key)
|
||||
if cursor.rowcount == 0:
|
||||
irc.error(format('I couldn\'t find any key %q', key))
|
||||
return
|
||||
elif cursor.rowcount < number:
|
||||
irc.errorInvalid('key id')
|
||||
(id, fact) = cursor.fetchall()[number-1]
|
||||
newfact = replacer(fact)
|
||||
cursor.execute("UPDATE factoids SET fact=%s WHERE id=%s", newfact, id)
|
||||
db.commit()
|
||||
irc.replySuccess()
|
||||
change = wrap(change, ['channel', 'something',
|
||||
'factoidId', 'regexpReplacer'])
|
||||
|
||||
_sqlTrans = string.maketrans('*?', '%_')
|
||||
def search(self, irc, msg, args, channel, optlist, globs):
|
||||
"""[<channel>] [--values] [--{regexp} <value>] [<glob> ...]
|
||||
|
||||
Searches the keyspace for keys matching <glob>. If --regexp is given,
|
||||
it associated value is taken as a regexp and matched against the keys.
|
||||
If --values is given, search the value space instead of the keyspace.
|
||||
"""
|
||||
if not optlist and not globs:
|
||||
raise callbacks.ArgumentError
|
||||
tables = ['keys']
|
||||
formats = []
|
||||
criteria = []
|
||||
target = 'keys.key'
|
||||
predicateName = 'p'
|
||||
db = self.getDb(channel)
|
||||
for (option, arg) in optlist:
|
||||
if option == 'values':
|
||||
target = 'factoids.fact'
|
||||
if 'factoids' not in tables:
|
||||
tables.append('factoids')
|
||||
criteria.append('factoids.key_id=keys.id')
|
||||
elif option == 'regexp':
|
||||
criteria.append('%s(TARGET)' % predicateName)
|
||||
def p(s, r=arg):
|
||||
return int(bool(r.search(s)))
|
||||
db.create_function(predicateName, 1, p)
|
||||
predicateName += 'p'
|
||||
for glob in globs:
|
||||
criteria.append('TARGET LIKE %s')
|
||||
formats.append(glob.translate(self._sqlTrans))
|
||||
cursor = db.cursor()
|
||||
sql = """SELECT keys.key FROM %s WHERE %s""" % \
|
||||
(', '.join(tables), ' AND '.join(criteria))
|
||||
sql = sql.replace('TARGET', target)
|
||||
cursor.execute(sql, formats)
|
||||
if cursor.rowcount == 0:
|
||||
irc.reply('No keys matched that query.')
|
||||
elif cursor.rowcount == 1 and \
|
||||
self.registryValue('showFactoidIfOnlyOneMatch', channel):
|
||||
self.whatis(irc, msg, [cursor.fetchone()[0]])
|
||||
elif cursor.rowcount > 100:
|
||||
irc.reply('More than 100 keys matched that query; '
|
||||
'please narrow your query.')
|
||||
else:
|
||||
keys = [repr(t[0]) for t in cursor.fetchall()]
|
||||
s = format('%L', keys)
|
||||
irc.reply(s)
|
||||
search = wrap(search, ['channel',
|
||||
getopts({'values': '', 'regexp': 'regexpMatcher'}),
|
||||
any('glob')])
|
||||
|
||||
|
||||
Class = Factoids
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1,163 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2002-2005, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
from supybot.test import *
|
||||
|
||||
try:
|
||||
import sqlite
|
||||
except ImportError:
|
||||
sqlite = None
|
||||
|
||||
if sqlite:
|
||||
class FactoidsTestCase(ChannelPluginTestCase):
|
||||
plugins = ('Factoids',)
|
||||
def testRandomfactoid(self):
|
||||
self.assertError('random')
|
||||
self.assertNotError('learn jemfinch as my primary author')
|
||||
self.assertRegexp('random', 'primary author')
|
||||
|
||||
def testLearn(self):
|
||||
self.assertNotError('learn jemfinch as my primary author')
|
||||
self.assertNotError('info jemfinch')
|
||||
self.assertRegexp('whatis jemfinch', 'my primary author')
|
||||
self.assertRegexp('whatis JEMFINCH', 'my primary author')
|
||||
self.assertRegexp('whatis JEMFINCH 1', 'my primary author')
|
||||
self.assertNotError('learn jemfinch as a bad assembly programmer')
|
||||
self.assertRegexp('whatis jemfinch 2', 'bad assembly')
|
||||
self.assertNotRegexp('whatis jemfinch 2', 'primary author')
|
||||
self.assertRegexp('whatis jemfinch', r'.*primary author.*assembly')
|
||||
self.assertError('forget jemfinch')
|
||||
self.assertError('forget jemfinch 3')
|
||||
self.assertError('forget jemfinch 0')
|
||||
self.assertNotError('forget jemfinch 2')
|
||||
self.assertNotError('forget jemfinch 1')
|
||||
self.assertError('whatis jemfinch')
|
||||
self.assertError('info jemfinch')
|
||||
|
||||
self.assertNotError('learn foo bar as baz')
|
||||
self.assertNotError('info foo bar')
|
||||
self.assertRegexp('whatis foo bar', 'baz')
|
||||
self.assertNotError('learn foo bar as quux')
|
||||
self.assertRegexp('whatis foo bar', '.*baz.*quux')
|
||||
self.assertError('forget foo bar')
|
||||
self.assertNotError('forget foo bar 2')
|
||||
self.assertNotError('forget foo bar 1')
|
||||
self.assertError('whatis foo bar')
|
||||
self.assertError('info foo bar')
|
||||
|
||||
self.assertError('learn foo bar baz') # No 'as'
|
||||
self.assertError('learn foo bar') # No 'as'
|
||||
|
||||
def testChangeFactoid(self):
|
||||
self.assertNotError('learn foo as bar')
|
||||
self.assertNotError('change foo 1 s/bar/baz/')
|
||||
self.assertRegexp('whatis foo', 'baz')
|
||||
self.assertError('change foo 2 s/bar/baz/')
|
||||
self.assertError('change foo 0 s/bar/baz/')
|
||||
|
||||
def testSearchFactoids(self):
|
||||
self.assertNotError('learn jemfinch as my primary author')
|
||||
self.assertNotError('learn strike as a cool guy working on me')
|
||||
self.assertNotError('learn inkedmn as another of my developers')
|
||||
self.assertNotError('learn jamessan as a developer of much python')
|
||||
self.assertNotError('learn bwp as author of my weather command')
|
||||
self.assertRegexp('factoids search --regexp /.w./', 'bwp')
|
||||
self.assertRegexp('factoids search --regexp /^.+i/',
|
||||
'jemfinch.*strike')
|
||||
self.assertNotRegexp('factoids search --regexp /^.+i/', 'inkedmn')
|
||||
self.assertRegexp('factoids search --regexp m/j/ --regexp m/ss/',
|
||||
'jamessan')
|
||||
self.assertRegexp('factoids search --regexp m/^j/ *ss*',
|
||||
'jamessan')
|
||||
self.assertRegexp('factoids search --regexp /^j/',
|
||||
'jemfinch.*jamessan')
|
||||
self.assertRegexp('factoids search j*', 'jemfinch.*jamessan')
|
||||
self.assertRegexp('factoids search *ke*',
|
||||
'inkedmn.*strike|strike.*inkedmn')
|
||||
self.assertRegexp('factoids search ke',
|
||||
'inkedmn.*strike|strike.*inkedmn')
|
||||
self.assertRegexp('factoids search jemfinch',
|
||||
'my primary author')
|
||||
self.assertRegexp('factoids search --values primary author',
|
||||
'my primary author')
|
||||
|
||||
def testWhatisOnNumbers(self):
|
||||
self.assertNotError('learn 911 as emergency number')
|
||||
self.assertRegexp('whatis 911', 'emergency number')
|
||||
|
||||
def testNotZeroIndexed(self):
|
||||
self.assertNotError('learn foo as bar')
|
||||
self.assertNotRegexp('info foo', '#0')
|
||||
self.assertNotRegexp('whatis foo', '#0')
|
||||
self.assertNotError('learn foo as baz')
|
||||
self.assertNotRegexp('info foo', '#0')
|
||||
self.assertNotRegexp('whatis foo', '#0')
|
||||
|
||||
def testInfoReturnsRightNumber(self):
|
||||
self.assertNotError('learn foo as bar')
|
||||
self.assertNotRegexp('info foo', '2 factoids')
|
||||
|
||||
def testLearnSeparator(self):
|
||||
self.assertError('learn foo is bar')
|
||||
self.assertNotError('learn foo as bar')
|
||||
self.assertRegexp('whatis foo', 'bar')
|
||||
orig = conf.supybot.plugins.Factoids.learnSeparator()
|
||||
try:
|
||||
conf.supybot.plugins.Factoids.learnSeparator.setValue('is')
|
||||
self.assertError('learn bar as baz')
|
||||
self.assertNotError('learn bar is baz')
|
||||
self.assertRegexp('whatis bar', 'baz')
|
||||
finally:
|
||||
conf.supybot.plugins.Factoids.learnSeparator.setValue(orig)
|
||||
|
||||
def testShowFactoidIfOnlyOneMatch(self):
|
||||
m1 = self.assertNotError('factoids search m/foo|bar/')
|
||||
orig = conf.supybot.plugins.Factoids.showFactoidIfOnlyOneMatch()
|
||||
try:
|
||||
conf.supybot.plugins.Factoids. \
|
||||
showFactoidIfOnlyOneMatch.setValue(False)
|
||||
m2 = self.assertNotError('factoids search m/foo/')
|
||||
self.failUnless(m1.args[1].startswith(m2.args[1]))
|
||||
finally:
|
||||
conf.supybot.plugins.Factoids. \
|
||||
showFactoidIfOnlyOneMatch.setValue(orig)
|
||||
|
||||
def testInvalidCommand(self):
|
||||
orig = conf.supybot.plugins.Factoids.replyWhenInvalidCommand()
|
||||
try:
|
||||
conf.supybot.plugins.Factoids.\
|
||||
replyWhenInvalidCommand.setValue(True)
|
||||
self.assertNotError('learn foo as bar')
|
||||
self.assertRegexp('foo', 'bar')
|
||||
finally:
|
||||
conf.supybot.plugins.Factoids.\
|
||||
replyWhenInvalidCommand.setValue(orig)
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1 +0,0 @@
|
||||
Insert a description of your plugin here, with any notes, etc. about using it.
|
@ -1,59 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2004, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
"""
|
||||
Provides numerous filters, and a command (outfilter) to set them as filters on
|
||||
the output of the bot.
|
||||
"""
|
||||
|
||||
import supybot
|
||||
import supybot.world as world
|
||||
|
||||
# Use this for the version of this plugin. You may wish to put a CVS keyword
|
||||
# in here if you\'re keeping the plugin in CVS or some similar system.
|
||||
__version__ = "%%VERSION%%"
|
||||
|
||||
__author__ = supybot.authors.jemfinch
|
||||
|
||||
# This is a dictionary mapping supybot.Author instances to lists of
|
||||
# contributions.
|
||||
__contributors__ = {}
|
||||
|
||||
import config
|
||||
import plugin
|
||||
reload(plugin) # In case we're being reloaded.
|
||||
|
||||
if world.testing:
|
||||
import test
|
||||
|
||||
Class = plugin.Class
|
||||
configure = config.configure
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1,57 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2004, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
import supybot.conf as conf
|
||||
import supybot.registry as registry
|
||||
|
||||
Filter = conf.registerPlugin('Filter')
|
||||
conf.registerGroup(Filter, 'spellit')
|
||||
conf.registerGlobalValue(Filter.spellit,
|
||||
'replaceLetters', registry.Boolean(True, """Determines whether or not to
|
||||
replace letters in the output of spellit."""))
|
||||
conf.registerGlobalValue(Filter.spellit,
|
||||
'replacePunctuation', registry.Boolean(True, """Determines whether or not
|
||||
to replace punctuation in the output of spellit."""))
|
||||
conf.registerGlobalValue(Filter.spellit,
|
||||
'replaceNumbers', registry.Boolean(True, """Determines whether or not to
|
||||
replace numbers in the output of spellit."""))
|
||||
conf.registerGroup(Filter, 'shrink')
|
||||
conf.registerChannelValue(Filter.shrink, 'minimum',
|
||||
registry.PositiveInteger(4, """Determines the minimum number of a letters
|
||||
in a word before it will be shrunken by the shrink command/filter."""))
|
||||
|
||||
def configure(advanced):
|
||||
# This will be called by supybot to configure this module. advanced is
|
||||
# a bool that specifies whether the user identified himself as an advanced
|
||||
# user or not. You should effect your configuration by manipulating the
|
||||
# registry as appropriate.
|
||||
from supybot.questions import expect, anything, something, yn
|
||||
conf.registerPlugin('Filter', True)
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1,616 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2002-2005, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
import re
|
||||
import string
|
||||
import random
|
||||
from cStringIO import StringIO
|
||||
|
||||
import supybot.conf as conf
|
||||
import supybot.utils as utils
|
||||
from supybot.commands import *
|
||||
import supybot.ircmsgs as ircmsgs
|
||||
import supybot.ircutils as ircutils
|
||||
import supybot.callbacks as callbacks
|
||||
|
||||
class MyFilterProxy(object):
|
||||
def reply(self, s):
|
||||
self.s = s
|
||||
|
||||
class Filter(callbacks.Plugin):
|
||||
"""This plugin offers several commands which transform text in some way.
|
||||
It also provides the capability of using such commands to 'filter' the
|
||||
output of the bot -- for instance, you could make everything the bot says
|
||||
be in leetspeak, or Morse code, or any number of other kinds of filters.
|
||||
Not very useful, but definitely quite fun :)"""
|
||||
def __init__(self, irc):
|
||||
self.__parent = super(Filter, self)
|
||||
self.__parent.__init__(irc)
|
||||
self.outFilters = ircutils.IrcDict()
|
||||
|
||||
def outFilter(self, irc, msg):
|
||||
if msg.command == 'PRIVMSG':
|
||||
if msg.args[0] in self.outFilters:
|
||||
if ircmsgs.isAction(msg):
|
||||
s = ircmsgs.unAction(msg)
|
||||
else:
|
||||
s = msg.args[1]
|
||||
methods = self.outFilters[msg.args[0]]
|
||||
for filtercommand in methods:
|
||||
myIrc = MyFilterProxy()
|
||||
filtercommand(myIrc, msg, [s])
|
||||
s = myIrc.s
|
||||
if ircmsgs.isAction(msg):
|
||||
msg = ircmsgs.action(msg.args[0], s, msg=msg)
|
||||
else:
|
||||
msg = ircmsgs.IrcMsg(msg=msg, args=(msg.args[0], s))
|
||||
return msg
|
||||
|
||||
_filterCommands = ['jeffk', 'leet', 'rot13', 'hexlify', 'binary', 'lithp',
|
||||
'scramble', 'morse', 'reverse', 'colorize', 'squish',
|
||||
'supa1337', 'colorstrip', 'aol', 'rainbow', 'spellit',
|
||||
'hebrew', 'undup', 'gnu', 'shrink']
|
||||
def outfilter(self, irc, msg, args, channel, command):
|
||||
"""[<channel>] [<command>]
|
||||
|
||||
Sets the outFilter of this plugin to be <command>. If no command is
|
||||
given, unsets the outFilter. <channel> is only necessary if the
|
||||
message isn't sent in the channel itself.
|
||||
"""
|
||||
if command:
|
||||
if not self.isDisabled(command) and \
|
||||
command in self._filterCommands:
|
||||
method = getattr(self, command)
|
||||
self.outFilters.setdefault(channel, []).append(method)
|
||||
irc.replySuccess()
|
||||
else:
|
||||
irc.error('That\'s not a valid filter command.')
|
||||
else:
|
||||
self.outFilters[channel] = []
|
||||
irc.replySuccess()
|
||||
outfilter = wrap(outfilter,
|
||||
[('checkChannelCapability', 'op'),
|
||||
additional('commandName')])
|
||||
|
||||
def hebrew(self, irc, msg, args, text):
|
||||
"""<text>
|
||||
|
||||
Removes all the vowels from <text>. (If you're curious why this is
|
||||
named 'hebrew' it's because I (jemfinch) thought of it in Hebrew class,
|
||||
and printed Hebrew often elides the vowels.)
|
||||
"""
|
||||
text = filter(lambda c: c not in 'aeiou', text)
|
||||
irc.reply(text)
|
||||
hebrew = wrap(hebrew, ['text'])
|
||||
|
||||
def squish(self, irc, msg, args, text):
|
||||
"""<text>
|
||||
|
||||
Removes all the spaces from <text>.
|
||||
"""
|
||||
text = ''.join(text.split())
|
||||
irc.reply(text)
|
||||
squish = wrap(squish, ['text'])
|
||||
|
||||
def undup(self, irc, msg, args, text):
|
||||
"""<text>
|
||||
|
||||
Returns <text>, with all consecutive duplicated letters removed.
|
||||
"""
|
||||
L = [text[0]]
|
||||
for c in text:
|
||||
if c != L[-1]:
|
||||
L.append(c)
|
||||
irc.reply(''.join(L))
|
||||
undup = wrap(undup, ['text'])
|
||||
|
||||
def binary(self, irc, msg, args, text):
|
||||
"""<text>
|
||||
|
||||
Returns the binary representation of <text>.
|
||||
"""
|
||||
L = []
|
||||
for c in text:
|
||||
LL = []
|
||||
i = ord(c)
|
||||
counter = 8
|
||||
while i:
|
||||
counter -= 1
|
||||
if i & 1:
|
||||
LL.append('1')
|
||||
else:
|
||||
LL.append('0')
|
||||
i >>= 1
|
||||
while counter:
|
||||
LL.append('0')
|
||||
counter -= 1
|
||||
LL.reverse()
|
||||
L.extend(LL)
|
||||
irc.reply(''.join(L))
|
||||
binary = wrap(binary, ['text'])
|
||||
|
||||
def hexlify(self, irc, msg, args, text):
|
||||
"""<text>
|
||||
|
||||
Returns a hexstring from the given string; a hexstring is a string
|
||||
composed of the hexadecimal value of each character in the string
|
||||
"""
|
||||
irc.reply(text.encode('hex_codec'))
|
||||
hexlify = wrap(hexlify, ['text'])
|
||||
|
||||
def unhexlify(self, irc, msg, args, text):
|
||||
"""<hexstring>
|
||||
|
||||
Returns the string corresponding to <hexstring>. Obviously,
|
||||
<hexstring> must be a string of hexadecimal digits.
|
||||
"""
|
||||
try:
|
||||
irc.reply(text.decode('hex_codec'))
|
||||
except TypeError:
|
||||
irc.error('Invalid input.')
|
||||
unhexlify = wrap(unhexlify, ['text'])
|
||||
|
||||
def rot13(self, irc, msg, args, text):
|
||||
"""<text>
|
||||
|
||||
Rotates <text> 13 characters to the right in the alphabet. Rot13 is
|
||||
commonly used for text that simply needs to be hidden from inadvertent
|
||||
reading by roaming eyes, since it's easily reversible.
|
||||
"""
|
||||
irc.reply(text.encode('rot13'))
|
||||
rot13 = wrap(rot13, ['text'])
|
||||
|
||||
def lithp(self, irc, msg, args, text):
|
||||
"""<text>
|
||||
|
||||
Returns the lisping version of <text>
|
||||
"""
|
||||
text = text.replace('sh', 'th')
|
||||
text = text.replace('SH', 'TH')
|
||||
text = text.replace('Sh', 'Th')
|
||||
text = text.replace('ss', 'th')
|
||||
text = text.replace('SS', 'TH')
|
||||
text = text.replace('s', 'th')
|
||||
text = text.replace('z', 'th')
|
||||
text = text.replace('S', 'Th')
|
||||
text = text.replace('Z', 'Th')
|
||||
text = text.replace('x', 'kth')
|
||||
text = text.replace('X', 'KTH')
|
||||
text = text.replace('cce', 'kth')
|
||||
text = text.replace('CCE', 'KTH')
|
||||
text = text.replace('tion', 'thion')
|
||||
text = text.replace('TION', 'THION')
|
||||
irc.reply(text)
|
||||
lithp = wrap(lithp, ['text'])
|
||||
|
||||
_leettrans = string.maketrans('oOaAeElBTiIts', '004433187!1+5')
|
||||
_leetres = [(re.compile(r'\b(?:(?:[yY][o0O][oO0uU])|u)\b'), 'j00'),
|
||||
(re.compile(r'fear'), 'ph33r'),
|
||||
(re.compile(r'[aA][tT][eE]'), '8'),
|
||||
(re.compile(r'[aA][tT]'), '@'),
|
||||
(re.compile(r'[sS]\b'), 'z'),
|
||||
(re.compile(r'x'), '><'),]
|
||||
def leet(self, irc, msg, args, text):
|
||||
"""<text>
|
||||
|
||||
Returns the l33tspeak version of <text>
|
||||
"""
|
||||
for (r, sub) in self._leetres:
|
||||
text = re.sub(r, sub, text)
|
||||
text = text.translate(self._leettrans)
|
||||
irc.reply(text)
|
||||
leet = wrap(leet, ['text'])
|
||||
|
||||
_supaleetreplacers = [('xX', '><'), ('kK', '|<'), ('rR', '|2'),
|
||||
('hH', '|-|'), ('L', '|_'), ('uU', '|_|'),
|
||||
('O', '()'), ('nN', '|\\|'), ('mM', '/\\/\\'),
|
||||
('G', '6'), ('Ss', '$'), ('i', ';'), ('aA', '/-\\'),
|
||||
('eE', '3'), ('t', '+'), ('T', '7'), ('l', '1'),
|
||||
('D', '|)'), ('B', '|3'), ('I', ']['), ('Vv', '\\/'),
|
||||
('wW', '\\/\\/'), ('d', 'c|'), ('b', '|>'),
|
||||
('c', '<'), ('h', '|n'),]
|
||||
def supa1337(self, irc, msg, args, text):
|
||||
"""<text>
|
||||
|
||||
Replies with an especially k-rad translation of <text>.
|
||||
"""
|
||||
for (r, sub) in self._leetres:
|
||||
text = re.sub(r, sub, text)
|
||||
for (letters, replacement) in self._supaleetreplacers:
|
||||
for letter in letters:
|
||||
text = text.replace(letter, replacement)
|
||||
irc.reply(text)
|
||||
supa1337 = wrap(supa1337, ['text'])
|
||||
|
||||
_scrambleRe = re.compile(r'(?:\b|(?![a-zA-Z]))([a-zA-Z])([a-zA-Z]*)'
|
||||
r'([a-zA-Z])(?:\b|(?![a-zA-Z]))')
|
||||
def scramble(self, irc, msg, args, text):
|
||||
"""<text>
|
||||
|
||||
Replies with a string where each word is scrambled; i.e., each internal
|
||||
letter (that is, all letters but the first and last) are shuffled.
|
||||
"""
|
||||
def _subber(m):
|
||||
L = list(m.group(2))
|
||||
random.shuffle(L)
|
||||
return '%s%s%s' % (m.group(1), ''.join(L), m.group(3))
|
||||
s = self._scrambleRe.sub(_subber, text)
|
||||
irc.reply(s)
|
||||
scramble = wrap(scramble, ['text'])
|
||||
|
||||
_code = {
|
||||
"A" : ".-",
|
||||
"B" : "-...",
|
||||
"C" : "-.-.",
|
||||
"D" : "-..",
|
||||
"E" : ".",
|
||||
"F" : "..-.",
|
||||
"G" : "--.",
|
||||
"H" : "....",
|
||||
"I" : "..",
|
||||
"J" : ".---",
|
||||
"K" : "-.-",
|
||||
"L" : ".-..",
|
||||
"M" : "--",
|
||||
"N" : "-.",
|
||||
"O" : "---",
|
||||
"P" : ".--.",
|
||||
"Q" : "--.-",
|
||||
"R" : ".-.",
|
||||
"S" : "...",
|
||||
"T" : "-",
|
||||
"U" : "..-",
|
||||
"V" : "...-",
|
||||
"W" : ".--",
|
||||
"X" : "-..-",
|
||||
"Y" : "-.--",
|
||||
"Z" : "--..",
|
||||
"0" : "-----",
|
||||
"1" : ".----",
|
||||
"2" : "..---",
|
||||
"3" : "...--",
|
||||
"4" : "....-",
|
||||
"5" : ".....",
|
||||
"6" : "-....",
|
||||
"7" : "--...",
|
||||
"8" : "---..",
|
||||
"9" : "----.",
|
||||
"." : ".-.-.-",
|
||||
"," : "--..--",
|
||||
":" : "---...",
|
||||
"?" : "..--..",
|
||||
"'" : ".----.",
|
||||
"-" : "-....-",
|
||||
"/" : "-..-.",
|
||||
'"' : ".-..-.",
|
||||
"@" : ".--.-.",
|
||||
"=" : "-...-"
|
||||
}
|
||||
_revcode = dict([(y, x) for (x, y) in _code.items()])
|
||||
_unmorsere = re.compile('([.-]+)')
|
||||
def unmorse(self, irc, msg, args, text):
|
||||
"""<Morse code text>
|
||||
|
||||
Does the reverse of the morse command.
|
||||
"""
|
||||
text = text.replace('_', '-')
|
||||
def morseToLetter(m):
|
||||
s = m.group(1)
|
||||
return self._revcode.get(s, s)
|
||||
text = self._unmorsere.sub(morseToLetter, text)
|
||||
text = text.replace(' ', '\x00')
|
||||
text = text.replace(' ', '')
|
||||
text = text.replace('\x00', ' ')
|
||||
irc.reply(text)
|
||||
unmorse = wrap(unmorse, ['text'])
|
||||
|
||||
def morse(self, irc, msg, args, text):
|
||||
"""<text>
|
||||
|
||||
Gives the Morse code equivalent of a given string.
|
||||
"""
|
||||
L = []
|
||||
for c in text.upper():
|
||||
if c in self._code:
|
||||
L.append(self._code[c])
|
||||
else:
|
||||
L.append(c)
|
||||
irc.reply(' '.join(L))
|
||||
morse = wrap(morse, ['text'])
|
||||
|
||||
def reverse(self, irc, msg, args, text):
|
||||
"""<text>
|
||||
|
||||
Reverses <text>.
|
||||
"""
|
||||
irc.reply(text[::-1])
|
||||
reverse = wrap(reverse, ['text'])
|
||||
|
||||
def _color(self, c, fg=None):
|
||||
if c == ' ':
|
||||
return c
|
||||
if fg is None:
|
||||
fg = str(random.randint(2, 15)).zfill(2)
|
||||
return '\x03%s%s' % (fg, c)
|
||||
|
||||
def colorize(self, irc, msg, args, text):
|
||||
"""<text>
|
||||
|
||||
Returns <text> with each character randomly colorized.
|
||||
"""
|
||||
L = [self._color(c) for c in text]
|
||||
irc.reply('%s%s' % (''.join(L), '\x03'))
|
||||
colorize = wrap(colorize, ['text'])
|
||||
|
||||
def rainbow(self, irc, msg, args, text):
|
||||
"""<text>
|
||||
|
||||
Returns <text> colorized like a rainbow.
|
||||
"""
|
||||
colors = utils.iter.cycle([4, 7, 8, 3, 2, 12, 6])
|
||||
L = [self._color(c, fg=colors.next()) for c in text]
|
||||
irc.reply(''.join(L) + '\x03')
|
||||
rainbow = wrap(rainbow, ['text'])
|
||||
|
||||
def stripcolor(self, irc, msg, args, text):
|
||||
"""<text>
|
||||
|
||||
Returns <text> stripped of all color codes.
|
||||
"""
|
||||
irc.reply(ircutils.stripColor(text))
|
||||
stripcolor = wrap(stripcolor, ['text'])
|
||||
|
||||
def aol(self, irc, msg, args, text):
|
||||
"""<text>
|
||||
|
||||
Returns <text> as if an AOLuser had said it.
|
||||
"""
|
||||
text = text.replace(' you ', ' u ')
|
||||
text = text.replace(' are ', ' r ')
|
||||
text = text.replace(' love ', ' <3 ')
|
||||
text = text.replace(' luv ', ' <3 ')
|
||||
text = text.replace(' too ', ' 2 ')
|
||||
text = text.replace(' to ', ' 2 ')
|
||||
text = text.replace(' two ', ' 2 ')
|
||||
text = text.replace('fore', '4')
|
||||
text = text.replace(' for ', ' 4 ')
|
||||
text = text.replace('be', 'b')
|
||||
text = text.replace('four', ' 4 ')
|
||||
text = text.replace(' their ', ' there ')
|
||||
text = text.replace(', ', ' ')
|
||||
text = text.replace(',', ' ')
|
||||
text = text.replace("'", '')
|
||||
text = text.replace('one', '1')
|
||||
smiley = utils.iter.choice(['<3', ':)', ':-)', ':D', ':-D'])
|
||||
text += smiley*3
|
||||
irc.reply(text)
|
||||
aol = wrap(aol, ['text'])
|
||||
|
||||
def jeffk(self, irc, msg, args, text):
|
||||
"""<text>
|
||||
|
||||
Returns <text> as if JeffK had said it himself.
|
||||
"""
|
||||
def randomlyPick(L):
|
||||
return utils.iter.choice(L)
|
||||
def quoteOrNothing(m):
|
||||
return randomlyPick(['"', '']).join(m.groups())
|
||||
def randomlyReplace(s, probability=0.5):
|
||||
def f(m):
|
||||
if random.random() < probability:
|
||||
return m.expand(s)
|
||||
else:
|
||||
return m.group(0)
|
||||
return f
|
||||
def randomExclaims(m):
|
||||
if random.random() < 0.85:
|
||||
return ('!' * random.randrange(1, 5)) + m.group(1)
|
||||
else:
|
||||
return '.' + m.group(1)
|
||||
def randomlyShuffle(m):
|
||||
L = list(m.groups())
|
||||
random.shuffle(L)
|
||||
return ''.join(L)
|
||||
def lessRandomlyShuffle(m):
|
||||
L = list(m.groups())
|
||||
if random.random() < .4:
|
||||
random.shuffle(L)
|
||||
return ''.join(L)
|
||||
def randomlyLaugh(text, probability=.3):
|
||||
if random.random() < probability:
|
||||
if random.random() < .5:
|
||||
insult = utils.iter.choice([' fagot1', ' fagorts',
|
||||
' jerks', 'fagot' ' jerk',
|
||||
'dumbshoes', ' dumbshoe'])
|
||||
else:
|
||||
insult = ''
|
||||
laugh1 = utils.iter.choice(['ha', 'hah', 'lol', 'l0l', 'ahh'])
|
||||
laugh2 = utils.iter.choice(['ha', 'hah', 'lol', 'l0l', 'ahh'])
|
||||
laugh1 = laugh1 * random.randrange(1, 5)
|
||||
laugh2 = laugh2 * random.randrange(1, 5)
|
||||
exclaim = utils.iter.choice(['!', '~', '!~', '~!!~~',
|
||||
'!!~', '~~~!'])
|
||||
exclaim += utils.iter.choice(['!', '~', '!~', '~!!~~',
|
||||
'!!~', '~~~!'])
|
||||
if random.random() < 0.5:
|
||||
exclaim += utils.iter.choice(['!', '~', '!~', '~!!~~',
|
||||
'!!~', '~~~!'])
|
||||
laugh = ''.join([' ', laugh1, laugh2, insult, exclaim])
|
||||
text += laugh
|
||||
return text
|
||||
if random.random() < .03:
|
||||
irc.reply(randomlyLaugh('NO YUO', probability=1))
|
||||
return
|
||||
alwaysInsertions = {
|
||||
r'er\b': 'ar',
|
||||
r'\bthe\b': 'teh',
|
||||
r'\byou\b': 'yuo',
|
||||
r'\bis\b': 'si',
|
||||
r'\blike\b': 'liek',
|
||||
r'[^e]ing\b': 'eing',
|
||||
}
|
||||
for (r, s) in alwaysInsertions.iteritems():
|
||||
text = re.sub(r, s, text)
|
||||
randomInsertions = {
|
||||
r'i': 'ui',
|
||||
r'le\b': 'al',
|
||||
r'i': 'io',
|
||||
r'l': 'll',
|
||||
r'to': 'too',
|
||||
r'that': 'taht',
|
||||
r'[^s]c([ei])': r'sci\1',
|
||||
r'ed\b': r'e',
|
||||
r'\band\b': 'adn',
|
||||
r'\bhere\b': 'hear',
|
||||
r'\bthey\'re': 'their',
|
||||
r'\bthere\b': 'they\'re',
|
||||
r'\btheir\b': 'there',
|
||||
r'[^e]y': 'ey',
|
||||
}
|
||||
for (r, s) in randomInsertions.iteritems():
|
||||
text = re.sub(r, randomlyReplace(s), text)
|
||||
text = re.sub(r'(\w)\'(\w)', quoteOrNothing, text)
|
||||
text = re.sub(r'\.(\s+|$)', randomExclaims, text)
|
||||
text = re.sub(r'([aeiou])([aeiou])', randomlyShuffle, text)
|
||||
text = re.sub(r'([bcdfghkjlmnpqrstvwxyz])([bcdfghkjlmnpqrstvwxyz])',
|
||||
lessRandomlyShuffle, text)
|
||||
text = randomlyLaugh(text)
|
||||
if random.random() < .4:
|
||||
text = text.upper()
|
||||
irc.reply(text)
|
||||
jeffk = wrap(jeffk, ['text'])
|
||||
|
||||
# Keeping these separate so people can just replace the alphabets for
|
||||
# whatever their language of choice
|
||||
_spellLetters = {
|
||||
'a': 'ay', 'b': 'bee', 'c': 'see', 'd': 'dee', 'e': 'ee', 'f': 'eff',
|
||||
'g': 'gee', 'h': 'aych', 'i': 'eye', 'j': 'jay', 'k': 'kay', 'l':
|
||||
'ell', 'm': 'em', 'n': 'en', 'o': 'oh', 'p': 'pee', 'q': 'cue', 'r':
|
||||
'arr', 's': 'ess', 't': 'tee', 'u': 'you', 'v': 'vee', 'w':
|
||||
'double-you', 'x': 'ecks', 'y': 'why', 'z': 'zee'
|
||||
}
|
||||
for (k, v) in _spellLetters.items():
|
||||
_spellLetters[k.upper()] = v
|
||||
_spellPunctuation = {
|
||||
'!': 'exclamation point',
|
||||
'"': 'quote',
|
||||
'#': 'pound',
|
||||
'$': 'dollar sign',
|
||||
'%': 'percent',
|
||||
'&': 'ampersand',
|
||||
'\'': 'single quote',
|
||||
'(': 'left paren',
|
||||
')': 'right paren',
|
||||
'*': 'asterisk',
|
||||
'+': 'plus',
|
||||
',': 'comma',
|
||||
'-': 'minus',
|
||||
'.': 'period',
|
||||
'/': 'slash',
|
||||
':': 'colon',
|
||||
';': 'semicolon',
|
||||
'<': 'less than',
|
||||
'=': 'equals',
|
||||
'>': 'greater than',
|
||||
'?': 'question mark',
|
||||
'@': 'at',
|
||||
'[': 'left bracket',
|
||||
'\\': 'backslash',
|
||||
']': 'right bracket',
|
||||
'^': 'caret',
|
||||
'_': 'underscore',
|
||||
'`': 'backtick',
|
||||
'{': 'left brace',
|
||||
'|': 'pipe',
|
||||
'}': 'right brace',
|
||||
'~': 'tilde'
|
||||
}
|
||||
_spellNumbers = {
|
||||
'0': 'zero', '1': 'one', '2': 'two', '3': 'three', '4': 'four',
|
||||
'5': 'five', '6': 'six', '7': 'seven', '8': 'eight', '9': 'nine'
|
||||
}
|
||||
def spellit(self, irc, msg, args, text):
|
||||
"""<text>
|
||||
|
||||
Returns <text>, phonetically spelled out.
|
||||
"""
|
||||
d = {}
|
||||
if self.registryValue('spellit.replaceLetters'):
|
||||
d.update(self._spellLetters)
|
||||
if self.registryValue('spellit.replaceNumbers'):
|
||||
d.update(self._spellNumbers)
|
||||
if self.registryValue('spellit.replacePunctuation'):
|
||||
d.update(self._spellPunctuation)
|
||||
# A bug in unicode on OSX prevents me from testing this.
|
||||
## dd = {}
|
||||
## for (c, v) in d.iteritems():
|
||||
## dd[ord(c)] = unicode(v + ' ')
|
||||
## irc.reply(unicode(text).translate(dd))
|
||||
out = StringIO()
|
||||
write = out.write
|
||||
for c in text:
|
||||
try:
|
||||
c = d[c]
|
||||
write(' ')
|
||||
except KeyError:
|
||||
pass
|
||||
write(c)
|
||||
irc.reply(out.getvalue())
|
||||
spellit = wrap(spellit, ['text'])
|
||||
|
||||
def gnu(self, irc, msg, args, text):
|
||||
"""<text>
|
||||
|
||||
Returns <text> as GNU/RMS would say it.
|
||||
"""
|
||||
irc.reply(' '.join(['GNU/' + s for s in text.split()]))
|
||||
gnu = wrap(gnu, ['text'])
|
||||
|
||||
def shrink(self, irc, msg, args, text):
|
||||
"""<text>
|
||||
|
||||
Returns <text> with each word longer than
|
||||
supybot.plugins.Filter.shrink.minimum being shrunken (i.e., like
|
||||
"internationalization" becomes "i18n").
|
||||
"""
|
||||
L = []
|
||||
minimum = self.registryValue('shrink.minimum', msg.args[0])
|
||||
r = re.compile(r'[A-Za-z]{%s,}' % minimum)
|
||||
def shrink(m):
|
||||
s = m.group(0)
|
||||
return ''.join((s[0], str(len(s)-2), s[-1]))
|
||||
text = r.sub(shrink, text)
|
||||
irc.reply(text)
|
||||
shrink = wrap(shrink, ['text'])
|
||||
|
||||
|
||||
Class = Filter
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1,169 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2002-2005, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
from supybot.test import *
|
||||
|
||||
import re
|
||||
|
||||
import supybot.utils as utils
|
||||
import supybot.callbacks as callbacks
|
||||
|
||||
class FilterTest(ChannelPluginTestCase):
|
||||
plugins = ('Filter', 'Utilities')
|
||||
def testNoErrors(self):
|
||||
self.assertNotError('leet foobar')
|
||||
self.assertNotError('supa1337 foobar')
|
||||
self.assertNotError('lithp meghan sweeney')
|
||||
self.assertNotError('aol I\'m too legit to quit.')
|
||||
|
||||
def testDisabledCommandsCannotFilter(self):
|
||||
self.assertNotError('outfilter rot13')
|
||||
self.assertResponse('echo foo', 'sbb')
|
||||
self.assertNotError('outfilter')
|
||||
try:
|
||||
self.assertNotError('disable rot13')
|
||||
self.assertError('outfilter rot13')
|
||||
self.assertNotError('enable rot13')
|
||||
self.assertNotError('outfilter rot13')
|
||||
finally:
|
||||
try:
|
||||
callbacks.Plugin._disabled.remove('rot13')
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
def testHebrew(self):
|
||||
self.assertResponse('hebrew The quick brown fox '
|
||||
'jumps over the lazy dog.',
|
||||
'Th qck brwn fx jmps vr th lzy dg.')
|
||||
def testJeffk(self):
|
||||
for i in range(100):
|
||||
self.assertNotError('jeffk the quick brown fox is ghetto')
|
||||
|
||||
def testSquish(self):
|
||||
self.assertResponse('squish foo bar baz', 'foobarbaz')
|
||||
self.assertResponse('squish "foo bar baz"', 'foobarbaz')
|
||||
|
||||
def testUndup(self):
|
||||
self.assertResponse('undup foo bar baz quux', 'fo bar baz qux')
|
||||
self.assertResponse('undup aaaaaaaaaa', 'a')
|
||||
|
||||
def testLithp(self):
|
||||
self.assertResponse('lithp jamessan', 'jamethan')
|
||||
self.assertResponse('lithp Shame', 'Thame')
|
||||
|
||||
def testMorse(self):
|
||||
self.assertResponse('unmorse [morse jemfinch]', 'JEMFINCH')
|
||||
|
||||
def testReverse(self):
|
||||
for s in map(str, range(1000, 1010)):
|
||||
self.assertResponse('reverse %s' % s, s[::-1])
|
||||
|
||||
def testBinary(self):
|
||||
self.assertResponse('binary A', '01000001')
|
||||
|
||||
def testRot13(self):
|
||||
for s in map(str, range(1000, 1010)):
|
||||
self.assertResponse('rot13 [rot13 %s]' % s, s)
|
||||
|
||||
def testRot13HandlesNonAsciiStuff(self):
|
||||
self.assertNotError('rot13 \xe4')
|
||||
|
||||
def testHexlifyUnhexlify(self):
|
||||
for s in map(str, range(1000, 1010)):
|
||||
self.assertResponse('unhexlify [hexlify %s]' % s, s)
|
||||
|
||||
def testScramble(self):
|
||||
s = 'the recalcitrant jamessan tests his scramble function'
|
||||
self.assertNotRegexp('scramble %s' % s, s)
|
||||
s = 'the recalc1trant jam3ssan tests his scramble fun><tion'
|
||||
self.assertNotRegexp('scramble %s' % s, s)
|
||||
|
||||
def testColorize(self):
|
||||
self.assertNotRegexp('colorize foobar', r'\s+')
|
||||
self.assertRegexp('colorize foobar', r'\x03')
|
||||
# Make sure we're closing colorize with an 'end color' marker
|
||||
self.assertRegexp('colorize foobar', r'\x03$')
|
||||
|
||||
_strings = ('Supybot pwns!', '123456', 'A string with \x02bold\x15')
|
||||
def testColorstrip(self):
|
||||
for s in self._strings:
|
||||
self.assertResponse('stripcolor [colorize %s]' % s, s)
|
||||
|
||||
def testSpellit(self):
|
||||
self.assertRegexp('spellit abc123!.%', 'ay bee see one two three '
|
||||
'exclamation point period percent')
|
||||
self.assertNotError('config plugins.Filter.spellit.replaceLetters off')
|
||||
self.assertRegexp('spellit asasdfasdf12345@#$!%^',
|
||||
'asasdfasdf one two three four five at pound '
|
||||
'dollar sign exclamation point percent caret')
|
||||
self.assertNotError('config plugins.Filter.spellit.replaceNumbers off')
|
||||
self.assertRegexp('spellit asasdfasdf12345@#$!%^',
|
||||
'asasdfasdf12345 at pound dollar sign exclamation '
|
||||
'point percent caret')
|
||||
self.assertNotError('config '
|
||||
'plugins.Filter.spellit.replacePunctuation off')
|
||||
self.assertResponse('spellit asasdfasdf12345@#$!%^',
|
||||
'asasdfasdf12345@#$!%^')
|
||||
|
||||
def testOutfilter(self):
|
||||
s = self.nick.encode('rot13')
|
||||
self.assertNotError('outfilter rot13')
|
||||
self.assertResponse('rot13 foobar', '%s: foobar' % s)
|
||||
self.assertNotError('outfilter rot13')
|
||||
self.assertResponse('rot13 foobar', 'sbbone')
|
||||
self.assertNotError('outfilter')
|
||||
self.assertResponse('rot13 foobar', 'sbbone')
|
||||
self.assertNotError('outfilter ROT13')
|
||||
self.assertResponse('rot13 foobar', '%s: foobar' % s)
|
||||
self.assertNotError('outfilter')
|
||||
self.assertResponse('rot13 foobar', 'sbbone')
|
||||
|
||||
def testOutfilterAction(self):
|
||||
s = self.nick.encode('rot13')
|
||||
self.assertNotError('outfilter rot13')
|
||||
self.assertResponse('rot13 foobar', '%s: foobar' % s)
|
||||
m = self.getMsg('action foobar')
|
||||
self.failUnless(ircmsgs.isAction(m))
|
||||
s = ircmsgs.unAction(m)
|
||||
self.assertEqual(s, 'sbbone')
|
||||
|
||||
def testGnu(self):
|
||||
self.assertResponse('gnu foo bar baz', 'GNU/foo GNU/bar GNU/baz')
|
||||
self.assertNotError('outfilter gnu')
|
||||
self.assertResponse('echo foo bar baz', 'GNU/foo GNU/bar GNU/baz')
|
||||
self.assertNotError('outfilter')
|
||||
|
||||
def testShrink(self):
|
||||
self.assertResponse('shrink I love you', 'I l2e you')
|
||||
self.assertResponse('shrink internationalization', 'i18n')
|
||||
self.assertResponse('shrink "I love you"', 'I l2e you')
|
||||
self.assertResponse('shrink internationalization, localization',
|
||||
'i18n, l10n')
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
@ -1 +0,0 @@
|
||||
Insert a description of your plugin here, with any notes, etc. about using it.
|
@ -1,58 +0,0 @@
|
||||
###
|
||||
# Copyright (c) 2004, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
"""
|
||||
Provides simple commands for formatting text on IRC.
|
||||
"""
|
||||
|
||||
import supybot
|
||||
import supybot.world as world
|
||||
|
||||
# Use this for the version of this plugin. You may wish to put a CVS keyword
|
||||
# in here if you\'re keeping the plugin in CVS or some similar system.
|
||||
__version__ = "%%VERSION%%"
|
||||
|
||||
__author__ = supybot.authors.jemfinch
|
||||
|
||||
# This is a dictionary mapping supybot.Author instances to lists of
|
||||
# contributions.
|
||||
__contributors__ = {}
|
||||
|
||||
import config
|
||||
import plugin
|
||||
reload(plugin) # In case we're being reloaded.
|
||||
|
||||
if world.testing:
|
||||
import test
|
||||
|
||||
Class = plugin.Class
|
||||
configure = config.configure
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user