Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #100750
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | <arresteddevlopment@tuta.io> |
| Newsgroups | comp.lang.python |
| Subject | Re: How to use a variable to act as @rule in a Sopel IRC bot module? |
| Date | Tue, 22 Dec 2015 21:19:32 +0000 (UTC) |
| Lines | 33 |
| Message-ID | <mailman.71.1450819185.2237.python-list@python.org> (permalink) |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| X-Trace | news.uni-berlin.de RPFQGknrF/zNSRHd331uDwBsYgCqduUfYdjokJjjTrAg== |
| Return-Path | <arresteddevlopment@tuta.io> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.020 |
| X-Spam-Evidence | '*H*': 0.96; '*S*': 0.00; 'subject:How': 0.09; 'subject:module': 0.09; 'def': 0.13; 'subject: \n ': 0.15; 'formatting,': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:variable': 0.16; 'to:name:python list': 0.16; 'commands,': 0.22; "skip:' 40": 0.22; 'import': 0.24; 'appreciated.': 0.27; 'random': 0.29; 'asked': 0.29; 'rule': 0.33; 'skip:b 60': 0.33; 'subject:use': 0.35; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'to:addr:python.org': 0.40; 'received:de': 0.40; 'from:no real name:2**0': 0.60; 'skip:\xc2 10': 0.67; 'terrible': 0.84 |
| X-Content-Filtered-By | Mailman/MimeDel 2.1.20+ |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:100750 |
Show key headers only | View raw
Apologies for the terrible formatting, let me try that again:
A:
from sopel.module import commands, rule
import random
q_and_as = [('Why?', 'because'), ('Can I kick it?', 'nope')]
@commands("quizme")
def ask_q(bot, trigger):
q = random.choice(q_and_as)
bot.say(q[0])
@rule(q[1])
def correct(bot, trigger):
bot.sat('Correctamundo!')
B:
...
@commands("quizme")
def ask_q(bot, trigger):
q = random.choice(q_and_as)
bot.say(q[0])
answer(bot, trigger, q[1])
def answer(bot, trigger, answer):
@rule(answer)
def correct(bot, trigger):
bot.say(' correctamundo!')
If the above comes out wonky again I also asked on StackOverflow
(http://stackoverflow.com/questions/34419265/how-to-set-and-later-change-a-rule-in-a-sopel-irc-bot-module-python).
Any help would be greatly appreciated.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: How to use a variable to act as @rule in a Sopel IRC bot module? <arresteddevlopment@tuta.io> - 2015-12-22 21:19 +0000
csiph-web