nowa uproszczona wersja
This commit is contained in:
parent
bb482b414b
commit
da3cdfaee0
30
cytat#.py
30
cytat#.py
|
@ -1,30 +0,0 @@
|
|||
# coding=utf-8
|
||||
# https://pypi.org/project/wikiquote/
|
||||
# https://pypi.org/project/sopel/
|
||||
# Author xmszkn(at)disroot.org
|
||||
# GPLv3 license
|
||||
|
||||
from sopel import plugin, tools # sopel modules
|
||||
import wikiquote # from wikiquote
|
||||
import random
|
||||
|
||||
@plugin.command('cytat')
|
||||
@plugin.action_command('cytat')
|
||||
@plugin.example('.cytat', r'¯\_(ツ)_/¯')
|
||||
|
||||
def cytat(bot, trigger):
|
||||
query = trigger.group(2)
|
||||
if not query:
|
||||
bot.reply('Podaj zapytanie (autor, pojęcie)')
|
||||
return
|
||||
autor_znal = wikiquote.search(query, lang='pl')
|
||||
if len(autor_znal) == 0:
|
||||
bot.say('Nie ma cytatu odpowiadającego twojemu zapytaniu.')
|
||||
return
|
||||
autor_def = (autor_znal[0])
|
||||
cytat = wikiquote.quotes((autor_def), lang='pl')
|
||||
if len(cytat) == 0:
|
||||
bot.say('Nie ma cytatu odpowiadającego twojemu zapytaniu.')
|
||||
return
|
||||
answer = random.choice(wikiquote.quotes((autor_def), lang='pl'))
|
||||
bot.say(answer)
|
36
cytat.py
36
cytat.py
|
@ -4,37 +4,27 @@
|
|||
# Author xmszkn(at)disroot.org
|
||||
# GPLv3 license
|
||||
|
||||
from sopel import plugin, tools
|
||||
import wikiquote
|
||||
from sopel import plugin, tools # sopel modules
|
||||
import wikiquote # from wikiquote
|
||||
import random
|
||||
|
||||
|
||||
@plugin.command('cytat')
|
||||
@plugin.action_command('cytat')
|
||||
@plugin.example('.cytat', r'¯\_(ツ)_/¯')
|
||||
|
||||
def cytat(bot, trigger):
|
||||
query = trigger.group(2)
|
||||
if not query:
|
||||
bot.reply('Podaj zapytanie (autor, pojęcie)')
|
||||
return
|
||||
autor_znal = wikiquote.search(query, lang='pl')
|
||||
|
||||
if len(autor_znal) == 0:
|
||||
autor_znal = wikiquote.search(query, lang='pl') # autorzy jako lista
|
||||
if len(autor_znal) == 0: # brak autora
|
||||
bot.say('Nie ma cytatu odpowiadającego twojemu zapytaniu.')
|
||||
|
||||
elif len(autor_znal) != 0:
|
||||
|
||||
autor_def = (autor_znal[0])
|
||||
|
||||
cytat = wikiquote.quotes((autor_def), lang='pl')
|
||||
|
||||
if len(cytat) == 0:
|
||||
|
||||
bot.say('Nie ma cytatu odpowiadającego twojemu zapytaniu.')
|
||||
|
||||
elif len(cytat) != 0:
|
||||
|
||||
answer = random.choice(wikiquote.quotes((autor_def), lang='pl'))
|
||||
bot.say(answer)
|
||||
|
||||
|
||||
return
|
||||
autor_def = (autor_znal[0]) # autor pierwsza pozycja z listy
|
||||
cytat = wikiquote.quotes((autor_def), lang='pl') # szukanie cytatu jesli brak to
|
||||
if len(cytat) == 0:
|
||||
bot.say('Nie ma cytatu odpowiadającego twojemu zapytaniu.')
|
||||
return
|
||||
answer = random.choice(wikiquote.quotes((autor_def), lang='pl')) # wlasciwy cytat
|
||||
bot.say(answer) # odpowiedz bota
|
Loading…
Reference in New Issue