Beispiel #1
0
def wallparser(bot,
               update,
               tags,
               pages,
               chat_id,
               info=None):  #Wallpaper parser
    bot.sendChatAction(chat_id, "upload_photo")
    client = Pybooru('Yandere')
    try:
        randompage = randint(1, int(pages))
        posts = client.posts_list(tags=str(tags),
                                  limit=1,
                                  page=str(randompage))
        for post in posts:
            tmp_data = "Uploader: " + post['author'] + "\nID: " + str(
                post['id'])
            globalarray[chat_id] = dict(data=tmp_data)
        photo = post['file_url']
        reply_markup = ikeyboard
        if info != None:
            bot.sendPhoto(chat_id,
                          photo,
                          reply_markup=reply_markup,
                          caption=info + '\n' + tmp_data)
        else:
            bot.sendPhoto(chat_id,
                          photo,
                          reply_markup=reply_markup,
                          caption=tmp_data)
    except Exception as e:
        print(e)
        print("Retrying...")
        print(wallparser(bot, update, tags, pages, chat_id))
Beispiel #2
0
def noparser(
        bot,
        update,
        tags,
        pages,
        chat_id,
        info=None):  #Parser without retry loop (to prevent infinte exception)
    bot.sendChatAction(chat_id, "upload_photo")
    client = Pybooru('Yandere')
    randomint = randint(1000, 10000000)
    try:
        randompage = randint(1, int(pages))
        posts = client.posts_list(tags=str(tags),
                                  limit=1,
                                  page=str(randompage))
        for post in posts:
            urllib.request.urlretrieve(
                post['file_url'], "tmp/anime_bot_" + str(randomint) + ".jpg")
            tmp_data = "Uploader: " + post['author'] + "\nID: " + str(
                post['id'])
            globalarray[chat_id] = dict(data=tmp_data)
        photo = open('tmp/anime_bot_' + str(randomint) + ".jpg", 'rb')
        reply_markup = ikeyboard
        if info != None:
            bot.sendPhoto(chat_id,
                          photo,
                          reply_markup=reply_markup,
                          caption=info + '\n' + tmp_data)
            os.remove('tmp/anime_bot_' + str(randomint) + ".jpg")
        else:
            bot.sendPhoto(chat_id,
                          photo,
                          reply_markup=reply_markup,
                          caption=tmp_data)
            os.remove('tmp/anime_bot_' + str(randomint) + ".jpg")
    except Exception as e:
        print(e)
Beispiel #3
0
def inline(bot, update):  #Inline Handler & Parser
    query = update.inline_query.query
    if query is None:
        query = 'rating:s'
        client = Pybooru('Yandere')
        posts = client.posts_list(tags=query, limit=50)
        lposts = len(posts)
        inlinequery = list()
        reply_markup = InlineKeyboardMarkup(
            [InlineKeyboardButton("More", callback_data='More')])
        for post in posts:
            inlinequery.append(
                InlineQueryResultPhoto(
                    type='photo',
                    id=uuid4(),
                    photo_url=post['file_url'],
                    photo_width=post['preview_width'] * 6,
                    photo_height=post['preview_height'] * 6,
                    #reply_markup=reply_markup,
                    thumb_url=post['preview_url']), )
        bot.answerInlineQuery(update.inline_query.id,
                              results=inlinequery,
                              switch_pm_text="Help",
                              switch_pm_parameter="ihelp")
        inlinequery.clear()
    else:
        client = Pybooru('Yandere')
        posts = client.posts_list(tags=query, limit=50)
        lposts = len(posts)
        inlinequery = list()
        reply_markup = InlineKeyboardMarkup(
            [InlineKeyboardButton("More", callback_data='More')])
        for post in posts:
            inlinequery.append(
                InlineQueryResultPhoto(
                    type='photo',
                    id=uuid4(),
                    photo_url=post['file_url'],
                    photo_width=post['preview_width'] * 6,
                    photo_height=post['preview_height'] * 6,
                    #reply_markup=reply_markup,
                    thumb_url=post['preview_url']), )
        bot.answerInlineQuery(update.inline_query.id,
                              results=inlinequery,
                              switch_pm_text="Help",
                              switch_pm_parameter="ihelp")
        inlinequery.clear()
Beispiel #4
0
def idd(bot, update, tags=None, chat_id=None):
    randomint = randint(1000, 10000000)
    try:
        bot.sendChatAction(chat_id, "upload_document")
        tags = update.message.text.split(' ', 1)[1]
        chat_id = update.message.chat_id
        try:
            client = Pybooru('Yandere')
            posts = client.posts_list(tags="id:" + str(tags), limit=1)
            for post in posts:
                urllib.request.urlretrieve(
                    post['file_url'],
                    "tmp/anime_bot_" + str(randomint) + ".jpg")
                tmp_data = "Uploader: " + post['author'] + "\nID: " + str(
                    post['id'])
                globalarray[chat_id] = dict(data=tmp_data)
            photo = open('tmp/anime_bot_' + str(randomint) + ".jpg", 'rb')
            reply_markup = InlineKeyboardMarkup(
                [[InlineKeyboardButton("More", callback_data='More')]])
            bot.sendDocument(chat_id, photo, reply_markup=reply_markup)
            os.remove('tmp/anime_bot_' + str(randomint) + ".jpg")
        except Exception as e:
            print(e)
    except:
        bot.sendChatAction(chat_id, "upload_document")
        client = Pybooru('Yandere')
        try:
            posts = client.posts_list(tags="id:" + str(tags), limit=1)
            for post in posts:
                urllib.request.urlretrieve(
                    post['file_url'],
                    "tmp/anime_bot_" + str(randomint) + ".jpg")
                tmp_data = "Uploader: " + post['author'] + "\nID: " + str(
                    post['id'])
                globalarray[chat_id] = dict(data=tmp_data)
            photo = open('tmp/anime_bot_' + str(randomint) + ".jpg", 'rb')
            reply_markup = InlineKeyboardMarkup(
                [[InlineKeyboardButton("More", callback_data='More')]])
            bot.sendDocument(chat_id, photo, reply_markup=reply_markup)
            os.remove('tmp/anime_bot_' + str(randomint) + ".jpg")
        except Exception as e:
            print(e)
Beispiel #5
0
from pybooru import Pybooru

client = Pybooru('yandere')

wiki = client.wiki('nice', 'date', 2, 1)

for msg in wiki:
    print 'Mensaje: %s' % (msg['body']),
Beispiel #6
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from pybooru import Pybooru

client = Pybooru('Konachan')

posts = client.posts_list('blue_eyes', 10)

for post in posts:
    print("URL imagen: {0}".format(post['file_url']))
Beispiel #7
0
# encoding: utf-8
from pybooru import Pybooru

# client = Pybooru(site_url='konachan.com')
client = Pybooru(site_url="http://www.konachan.com")

tags = client.tags_list(None, None, 100, 0, 'date')
Beispiel #8
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from pybooru import Pybooru

client = Pybooru('Konachan',
                 username='******',
                 password='******')

client.comments_create(post_id=id, comment_body='Comment content')
Beispiel #9
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from pybooru import Pybooru

client = Pybooru("Konachan")

posts = client.posts_list("blue_eyes", 10)

for post in posts:
    print("URL imagen: {0}".format(post["file_url"]))
Beispiel #10
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from pybooru import Pybooru

client = Pybooru(siteName='Konachan')

#notes = client.notes_list()

#print(notes)

#wiki = client.wiki_list('nice', 'date', 2, 1)

#for msg in wiki:
#    print("Mensaje: {0}".format(msg['body']))

#posts = client.posts_list('blue_eyes', 2, 0)

#for post in posts:
#    print("URL imagen: {0}".format(post['file_url']))

#tags = client.tags_list(None, None, 100, 0, 'date')

#print tags
#for tag in tags:
#    print("Nombre: {0} ----- {1}".format(tag['name'], tag['type']))
Beispiel #11
0
from pybooru import Pybooru

client = Pybooru('yandere')

wiki = client.wiki('nice', 'date', 2, 1)

for msg in wiki:
	print 'Mensaje: %s' % (msg['body']),
Beispiel #12
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from pybooru import Pybooru

client = Pybooru('yandere')

wiki = client.wiki_list('nice', 'date', 2, 1)

for msg in wiki:
    print("Mensaje: {0}".format(msg['body']))
Beispiel #13
0
from __future__ import unicode_literals
from pybooru import Pybooru
import discord
import asyncio
import random
# -*- coding: utf-8 -*-

bclient = Pybooru('Konachan')

client = discord.Client()


###############
#-Random Loli_#
###############
@client.async_event
def on_message(message):

    if message.content.startswith('!loli'):

        num = random.randint(0, 100)
        posts = bclient.posts_list('loli', num)
        for post in posts:
            print("URL: {0}".format(post['file_url']))
            myfile = open("url.txt", "w")
            myfile.write(post['file_url'])
            myfile.close()
            myfile = open("url.txt", "r")
            Pic = myfile.readline()
        yield from client.send_message(message.channel, Pic)
Beispiel #14
0
from pybooru import Pybooru

client = Pybooru(name='Konachan')

#notes = client.notes()

#print notes

#wiki = client.wiki('nice', 'date', 2, 1)

#for msg in wiki:
#	print 'Mensaje: %s' % (msg['body']),

#posts = client.posts('blue_eyes', 2, 0)

#for post in posts:
#	print 'URL imagen: %s' % (post['file_url'])

#tags = client.tags(None, None, 100, 0, 'date')

#print tags
#for tag in tags:
#	print "Nombre: %s ----- %i" % (tag['name'], tag['type'])
Beispiel #15
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from pybooru import Pybooru

client = Pybooru('Konachan', username='******', password='******')

client.comments_create(post_id=id, comment_body='Comment content')
Beispiel #16
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from pybooru import Pybooru

client = Pybooru('Konachan')

tags = client.tags_list(None, None, 100, 0, 'date')

for tag in tags:
    print("Nombre: {0} ----- {1}".format(tag['name'], tag['type']))