示例#1
0
文件: imdb.py 项目: CakeWizard/lpbot
# -*- coding: utf-8 -*-

# Original code copyright:
# Copyright © 2012-2013, Elad Alfassa, <*****@*****.**>
# Copyright 2014, Nikola Kovacevic, <*****@*****.**>
# Licensed under the Eiffel Forum License 2.

from __future__ import unicode_literals
import requests

import lpbot.module
from lpbot.logger import get_logger


LOGGER = get_logger(__name__)


@lpbot.module.commands('imdb')
@lpbot.module.example('.imbd ThisTitleDoesNotExist', '[IMDb] Movie not found!')
@lpbot.module.example('.imdb Citizen Kane',
                      '[IMDb] Title: Citizen Kane | Year: 1941 | Rating: 8.4 | Genre: Drama, Mystery | IMDB Link: http://imdb.com/title/tt0033467')
def imdb(bot, trigger):
    """
    Returns some information about a movie, like Title, Year, Rating, Genre and IMDB Link.
    """
    if not trigger.group(2):
        return
    word = trigger.group(2).rstrip()
    uri = "http://www.imdbapi.com/?t=" + word
    r = requests.get(uri)
示例#2
0
文件: reload.py 项目: Nikola-K/lpbot
# Copyright 2008, Sean B. Palmer, inamidst.com
# Copyright 2014, Nikola Kovacevic, <*****@*****.**>
# Licensed under the Eiffel Forum License 2.

import sys
import os.path
import time
import imp
import subprocess

from lpbot.tools import owner_only
import lpbot.module
from lpbot import logger

log = logger.get_logger()


@lpbot.module.nickname_commands("reload")
@lpbot.module.priority("low")
@lpbot.module.thread(False)
@owner_only
def f_reload(bot, trigger):
    """Reloads a module, for use by admins only."""
    if not trigger.admin:
        return

    name = trigger.group(2)
    if name == bot.config.owner:
        return bot.reply('What?')
示例#3
0
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import re

import requests

from lpbot.module import commands, example, NOLIMIT
from lpbot.logger import get_logger

log = get_logger()

regex = re.compile(r'''
    (\d+(?:\.\d+)?)        # Decimal number
    \s*([a-zA-Z]{3})       # 3-letter currency code
    \s+(?:in|as|to)\s+  # preposition
    ([a-zA-Z]{3})          # 3-letter currency code
    ''', re.VERBOSE)


def get_rate(amount, base, symbol):
    API = "https://api.fixer.io/latest?base={base}&symbols={symbol}".format(
        base=base,
        symbol=symbol
    )
示例#4
0
# -*- coding: utf-8 -*-

# Copyright 2013 Edward Powell - embolalia.net
# Licensed under the Eiffel Forum License 2.

import re

import requests

from lpbot.module import NOLIMIT, commands, example, rule
from lpbot import tools, logger

log = logger.get_logger("wikipedia")

REDIRECT = re.compile(r'^REDIRECT (.*)')

wiki_article = r'https?://(\w+).wikipedia.org/wiki/(\S+)'
article_regex = re.compile(wiki_article)


def setup(bot):
    if not bot.memory.contains('url_callbacks'):
        bot.memory['url_callbacks'] = tools.lpbotMemory()

    bot.memory['url_callbacks'][wiki_article] = wiki_info


def shutdown(bot):
    del bot.memory['url_callbacks'][wiki_article]

示例#5
0
# Copyright © 2012, Elad Alfassa <*****@*****.**>
# Copyright 2012, Edward Powell (embolalia.net)
# Licensed under the Eiffel Forum License 2.

from __future__ import unicode_literals

import re
import time
import base64

import lpbot
from lpbot.tools import Identifier, iteritems
from lpbot.logger import get_logger
from lpbot.module import event, rule, thread, unblockable, event, priority

LOGGER = get_logger(__name__)


@event('001', '251')
@rule('.*')
@thread(False)
@unblockable
def startup(bot, trigger):
    """Do tasks related to connecting to the network.

    001 RPL_WELCOME is from RFC2812 and is the first message that is sent after
    the connection has been registered on the network.

    251 RPL_LUSERCLIENT is a mandatory message that is sent after client
    connects to the server in rfc1459. RFC2812 does not require it and all
    networks might not send it. We support both.
示例#6
0
# -*- coding: utf-8 -*-

# Copyright 2013 Edward Powell - embolalia.net
# Licensed under the Eiffel Forum License 2.

import re

import requests

from lpbot.module import NOLIMIT, commands, example, rule
from lpbot import tools, logger

log = logger.get_logger("wikipedia")

REDIRECT = re.compile(r'^REDIRECT (.*)')

wiki_article = r'https?://(\w+).wikipedia.org/wiki/(\S+)'
article_regex = re.compile(wiki_article)


def setup(bot):
    if not bot.memory.contains('url_callbacks'):
        bot.memory['url_callbacks'] = tools.lpbotMemory()

    bot.memory['url_callbacks'][wiki_article] = wiki_info


def shutdown(bot):
    del bot.memory['url_callbacks'][wiki_article]

示例#7
0
文件: currency.py 项目: nikolak/lpbot
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import re

import requests

from lpbot.module import commands, example, NOLIMIT
from lpbot.logger import get_logger

log = get_logger()

regex = re.compile(
    r'''
    (\d+(?:\.\d+)?)        # Decimal number
    \s*([a-zA-Z]{3})       # 3-letter currency code
    \s+(?:in|as|to)\s+  # preposition
    ([a-zA-Z]{3})          # 3-letter currency code
    ''', re.VERBOSE)


def get_rate(amount, base, symbol):
    API = "https://api.fixer.io/latest?base={base}&symbols={symbol}".format(
        base=base, symbol=symbol)

    r = requests.get(API, timeout=5)
示例#8
0
# Copyright 2008, Sean B. Palmer, inamidst.com
# Copyright 2014, Nikola Kovacevic, <*****@*****.**>
# Licensed under the Eiffel Forum License 2.

import sys
import os.path
import time
import imp
import subprocess

from lpbot.tools import owner_only
import lpbot.module
from lpbot import logger

log = logger.get_logger()


@lpbot.module.nickname_commands("reload")
@lpbot.module.priority("low")
@lpbot.module.thread(False)
@owner_only
def f_reload(bot, trigger):
    """Reloads a module, for use by admins only."""
    if not trigger.admin:
        return

    name = trigger.group(2)
    if name == bot.config.owner:
        return bot.reply('What?')