Compare commits
6 commits
contenttyp
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 884b2a5b55 | |||
| b2701839d6 | |||
| 75b9a01928 | |||
| b77ef20fed | |||
| d46341a92d | |||
| bbcd5b224d |
6 changed files with 88 additions and 1202 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -2,3 +2,4 @@
|
|||
*.log
|
||||
/*.db
|
||||
/*.conf
|
||||
/env
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ Clone this git repository, and in the directory:
|
|||
|
||||
Then you can run the bot like so:
|
||||
|
||||
env/bin/python lolbot.py <server[:port]> <channel> <nickname> <db>
|
||||
env/bin/python lolbot.py --help
|
||||
|
||||
Development
|
||||
-----------
|
||||
|
|
|
|||
22
lolbot.py
22
lolbot.py
|
|
@ -211,9 +211,17 @@ class LolBot(SingleServerIRCBot):
|
|||
|
||||
def quiz_get_next(self):
|
||||
self.quiz += 1
|
||||
self.tip = 0
|
||||
self.question = random.choice(self.qb)
|
||||
print(str(self.question.question))
|
||||
self.connection.notice(self.channel, "Question %s: %s" % (self.quiz, str(self.question.question)))
|
||||
print(self.question.question)
|
||||
self.connection.notice(self.channel, "Question %s: %s" % (self.quiz, self.question.question))
|
||||
|
||||
def quiz_tip(self):
|
||||
if len(self.question.tip) > self.tip:
|
||||
self.connection.notice(self.channel, "Tip: %s" % self.question.tip[self.tip])
|
||||
self.tip += 1
|
||||
else:
|
||||
self.connection.notice(self.channel, "No more tips.")
|
||||
|
||||
def quiz_award_points(self, nick):
|
||||
if nick not in self.quiz_scores.keys():
|
||||
|
|
@ -300,13 +308,17 @@ class LolBot(SingleServerIRCBot):
|
|||
if self.quiz:
|
||||
self.quiz_scoreboard()
|
||||
|
||||
elif cmd == 'tip' or cmd == 'hint':
|
||||
if self.quiz:
|
||||
self.quiz_tip()
|
||||
|
||||
elif cmd == 'ask':
|
||||
if self.quiz:
|
||||
c.notice(self.channel, "Quiz is running. Use halt or quit to stop.")
|
||||
c.notice(self.channel, str(self.question.question))
|
||||
c.notice(self.channel, self.question.question)
|
||||
elif isinstance(self.question, Question):
|
||||
c.notice(self.channel, "There is an unanswered question.")
|
||||
c.notice(self.channel, str(self.question.question))
|
||||
c.notice(self.channel, self.question.question)
|
||||
else:
|
||||
self.start_quiz(nick)
|
||||
|
||||
|
|
@ -396,7 +408,7 @@ class LolBot(SingleServerIRCBot):
|
|||
try:
|
||||
(options, args) = getopt.getopt(sys.argv[1:], 'hc:s:p:j:n:d:', ['help', 'config=', 'server=', 'port=', 'join=', 'nick=', 'database=', ])
|
||||
except getopt.GetoptError as err:
|
||||
print(str(err))
|
||||
print(err)
|
||||
LolBot.usage()
|
||||
sys.exit(2)
|
||||
|
||||
|
|
|
|||
|
|
@ -68,8 +68,11 @@ class Url(Model):
|
|||
if title is None:
|
||||
r = requests.get(url)
|
||||
if r.status_code == 200:
|
||||
dom = BeautifulSoup(r.content, 'html.parser')
|
||||
self.title = dom.title.string
|
||||
if 'text/html' in r.headers['content-type']:
|
||||
dom = BeautifulSoup(r.content, 'html.parser')
|
||||
self.title = dom.title.string
|
||||
else:
|
||||
self.title = r.headers['content-type']
|
||||
else:
|
||||
self.title = "Error: HTTP %s" % r.status_code
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,70 @@
|
|||
# DO NOT ADD COMMENTS BEYOND THIS LINE, since they might get lost.
|
||||
# you may add as much comments as you want into the part above
|
||||
|
||||
Category: Units
|
||||
Question: What does the SI unit weber (Wb) measure?
|
||||
Tip: m....... f...
|
||||
Answer: magnetic flux
|
||||
Author: DoctorLard
|
||||
|
||||
Category: Units
|
||||
Question: Four gills in a ....?
|
||||
Tip: It's an Imperial unit.
|
||||
Tip: You might ask for one at the pub.
|
||||
Tip: p...
|
||||
Answer: pint
|
||||
Author: DoctorLard
|
||||
|
||||
Category: Units
|
||||
Question: Ten chains in a ....?
|
||||
Tip: It's an Imperial unit of length.
|
||||
Tip: f......
|
||||
Answer: furlong
|
||||
Author: DoctorLard
|
||||
|
||||
Category: Units
|
||||
Question: Four .... in a chain?
|
||||
Tip: An obscure Imperial unit of length.
|
||||
Tip: Equal to 5½ yards.
|
||||
Tip: r..
|
||||
RegExp: (rod|pole|perch)
|
||||
Answer: Rod (or Pole, or Perch)
|
||||
Author: DoctorLard
|
||||
|
||||
Category: Units
|
||||
Question: Eight .... in a mile?
|
||||
Tip: An Imperial unit of length.
|
||||
Tip: Equal to 220 yards.
|
||||
Tip: f......
|
||||
Answer: Furlong
|
||||
Author: DoctorLard
|
||||
|
||||
Category: Units
|
||||
Question: A perch is unit of area equivalent to a square pole. A pole is another name for a rod, and there are ten chains to a furlong and four rods to a chain. A rood is a quarter acre, and there are 160 perches to an acre. If a property area is one rood and half a furlong on one side, how long is the other side, in rods?
|
||||
Tip: Less than you might think.
|
||||
Tip: Whatever. Google won't help you either.
|
||||
Level: hard
|
||||
Answer: 2
|
||||
Author: DoctorLard
|
||||
|
||||
Question: How many pennies in a half crown?
|
||||
Answer: 30
|
||||
Author: DoctorLard
|
||||
|
||||
Category: Units
|
||||
Question: What is the old English surveying unit of area, defined as one furlong by one rod?
|
||||
Tip: There are four of them to an acre.
|
||||
Tip: r...
|
||||
Answer: rood
|
||||
Author: DoctorLard
|
||||
|
||||
Category: Units
|
||||
Question: What is the SI prefix that denotes a multiplier of ten to the negative eighteenth power (10¯¹⁸)?
|
||||
Tip: It's used really really small quantities.
|
||||
Tip: a...
|
||||
Answer: atto
|
||||
Author: DoctorLard
|
||||
|
||||
Category: Temporal anomalies
|
||||
Question: How many times do the minute and hour hands on a clockface overlap in a 24 hour period?
|
||||
Answer: 22
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue