示例#1
0
文件: aop.py 项目: joodicator/PageBot
from collections import defaultdict
import re
import random
import traceback
import os.path

from untwisted.magic import sign

import util
import runtime
import channel
import identity

link, install, uninstall = util.LinkSet().triple()
install, uninstall = util.depend(install, uninstall, "channel", "identity")

CONF_PATH = "conf/aop.txt"
DELAY_BASE_S = 6
DELAY_RAND_S = 3


def read_conf():
    conf = defaultdict(list)
    chans = None
    if os.path.exists(CONF_PATH):
        try:
            with open(CONF_PATH) as file:
                for line in file:
                    line = re.sub(r"--.*", r"", line).strip().lower()
                    if not line:
                        continue
示例#2
0
import re
import util
import time
import identity
import inspect
import os.path

from untwisted.mode import Mode
from untwisted.usual import apply
from untwisted.magic import hold, sign

from util import ID, just, msign, LinkSet
from message import reply

link, install, uninstall = LinkSet().triple()
install, uninstall = util.depend(install, uninstall,
    'identity')

ADMINS_FILE = 'conf/admins.txt'
PASSWORD_FILE = 'conf/auth_password.txt'
IDENTIFY_DURATION_S = 60*60

passed = set()
identified = dict()

def reload(prev):
    if hasattr(prev, 'passed') and isinstance(prev.passed, set):
        passed.update(prev.passed)
    if hasattr(prev, 'identified') and isinstance(prev.identified, dict):
        identified.update(prev.identified)

# Decorates an untwisted event handler which takes arguments 'bot' and 'id',
示例#3
0
from message import reply
from runtime import later
from util import same_user as same_sender
from util import multi, wc_to_re
from auth import admin
import runtime
import channel
import util
import auth
import identity


#==============================================================================#
link, install, uninstall = util.LinkSet().triple()
install, uninstall = util.depend(install, uninstall,
    'auth')

#==============================================================================#
# Memory-cached plugin state.
current_state = None


# File where the plugin state is stored.
STATE_FILE = 'state/tell.pickle'

# After this many days, dismissed messages may be deleted.
DISMISS_DAYS = 30

# Date format used by !tell? and !tell+.
DATE_FORMAT_SHORT = '%Y-%m-%d %H:%M'
示例#4
0
import calendar
import datetime
import time
import json
import re
import os.path

from util import LinkSet
from message import reply
import channel
import identity
import util
import auth

link, install, uninstall = LinkSet().triple()
install, uninstall = util.depend(install, uninstall,
    'channel', 'identity')

STATE_FILE = 'state/seen.json'
MAX_RECORDS = 100000
PRUNE_THRESHOLD = 100

EVENT_TYPES = 'message', 'action', 'exit'

#===============================================================================
# global_state[chan.lower()]['nick!user@host'.lower()] = {
#    'exit':    { time: T, params: PE },
#    'action':  { time: T, params: PA },
#    'message': { time: T, params: PM },
#    'id_case': 'nick!user@host'
# } where
#     T = time.time()
示例#5
0
link = util.LinkSet()
installed = False

identity.add_credentials('tell.father',
    ('access', 'Bruce'),
    ('prev_hosts', 3))

def install(bot):
    global installed
    if installed: raise util.AlreadyInstalled
    util.event_sub(bot, 'TELL_SENT', 'tell_fto.TELL_SENT')
    link.install(bot)
    installed = True

def uninstall(bot):
    global installed
    if not installed: raise util.NotInstalled
    link.uninstall(bot)
    util.event_sub(bot, 'tell_fto.TELL_SENT', 'TELL_SENT')
    installed = False

install, uninstall = util.depend(install, uninstall,
    'identity', 'tell')

@link('TELL_SENT')
def h_tell_sent(bot, id, target, sent_msgs, reply_msg=None):
    father = yield identity.check_access(bot, id, 'tell.father')
    if father: reply_msg = 'Yes, father'
    yield sign('tell_fto.TELL_SENT', bot, id, target, sent_msgs, reply_msg)
示例#6
0
# upoopia.py - an IRC implementation of http://www.unicorn7.org/games/game/553

import re

from untwisted.magic import sign

from upoopia_lib import *
from message import reply
import util
import modal
import channel
import chan_link
import runtime

link, install, uninstall = util.LinkSet().triple()
install, uninstall = util.depend(install, uninstall,
    'chan_link')

# challenges[ch1.lower()] = (ch2, WHITE or BLACK or None)
challenges = dict()

# games[ch1.lower()] == games[ch2.lower()] == game
# where isinstance(game, UpoopiaText)
#   and game.players[BLACK].lower() == ch1.lower()
#   and game.players[WHITE].lower() == ch2.lower()
games = dict()

#-------------------------------------------------------------------------------
def reload(prev):
    if hasattr(prev, 'challenges') and isinstance(prev.challenges, dict):
        for chan, challenge in prev.challenges.iteritems():
            challenges[chan] = challenge
示例#7
0
import os.path

from untwisted.magic import sign, hold

import nickserv
import runtime
import channel
import util

RPL_WHOISUSER = '******'

CREDENTIALS_FILE = 'conf/identity.py'
PREV_HOSTS_FILE  = 'state/identity_hosts.json'

link, install, uninstall = util.LinkSet().triple()
install, uninstall = util.depend(install, uninstall,
    'nickserv')

prev_track_id = None
def reload(prev):
    global prev_track_id
    if hasattr(prev, 'track_id') and type(prev.track_id) is dict:
        prev_track_id = prev.track_id

@link('POST_RELOAD')
def h_post_reload(bot):
    global prev_track_id
    all_nicks = set()
    for chan, nicks in channel.track_channels.iteritems():
        all_nicks.update(nick.lower() for nick in nicks)
    if prev_track_id is not None:
        for nick in all_nicks: