Ejemplo n.º 1
0
    def __init__(self, chat_id, bot, cells):
        self.__bot = bot
        self.__bot_helper = BotUtil(bot)
        self.__n = config.n
        self.__id = chat_id
        self.__world = dict()
        self.__size = '99'
        self.__speed = 1.2
        self.__msg = None
        self.__last = dict()
        self.__count = 0
        self.__xod = 0
        self.__del = 0
        self.__cells = cells

        print("Life class created, generating world...")
        self.__generate_world()
Ejemplo n.º 2
0
import random
import threading

from modules.funcs import BotUtil
from .. import config
from ..config import environ
from ..mongohelper import MongoHelper

bot = BotUtil(environ['lena'])
db = MongoHelper()


class Lena:
    def __init__(self):
        self.bot = bot
        self.id = self.bot.get_me().id
        self.name = 'Lena'
        self.prefix = 'len'
        self.chat_id = config.chat_id
        self.cache = {}
        self.common_help_text = '{}, привет. Ты можешь мне помочь?'
        self.respective_help_text = '{}, привет! Ты мне часто помогаешь, поэтому хотелось бы попросить тебя о помощи ' \
                                    'еще раз... Не откажешь?'

        self.help_texts = ['Спасибо! Тогда пошли, мне нужно отсортировать лекарства в медпункте.',
                           'Спасибо! Пойдём, надо разобрать склад и принести несколько'
                           ' комплектов пионерской формы для Слави.']
        self.help_timer = None

    def help_request(self):
        pioner = random.choice(db.get_pioners())
Ejemplo n.º 3
0
from modules.coach import Coach
coach = Coach()

import re
from subprocess import Popen, PIPE

import config
from modules.funcs import BotUtil

bot = BotUtil(config.environ['sedbot'], config.creator)


def sed(pattern, text):
    regular = pattern.split("/", 2)[1]
    replacement = pattern.split("/", 2)[2]
    if regular and replacement:
        output = f"{text.replace(regular, replacement)}"
        return output


def newsed(pattern, text):
    cmd = ['/bin/sed', '-e', pattern, '-e', 'tx', '-e', 'd', '-e', ':x']
    p = Popen(cmd, stdout=PIPE, stdin=PIPE, stderr=PIPE, shell=False)
    p.stdin.write(text.encode())
    out, err = p.communicate()
    out = out.decode()
    err = err.decode()
    if err:
        return err
    if out:
        return out
Ejemplo n.º 4
0
import random
import threading

from modules.funcs import BotUtil
from .. import config
from ..config import environ
from ..mongohelper import MongoHelper

bot = BotUtil(environ['uliana'])
db = MongoHelper()


class Uliana:
    def __init__(self):
        self.bot = bot
        self.id = self.bot.get_me().id
        self.name = 'Uliana'
        self.prefix = 'uli'
        self.chat_id = config.chat_id
        self.cache = {}
        self.common_help_text = 'Эй, {}! Поможешь мне с одним делом?'
        self.respective_help_text = 'Привет, {}! Мне не помешала бы помощь в одном деле... Я знаю, что ты согласишься!'
        self.help_texts = [
            'Я тут хочу заняться одним безобидным делом,'
            ' и в этом мне потребуются спички... Если что, тебя не сдам!',
            'О, круто! Мне тут нужно раздобыть немного глицерина...'
        ]
        self.help_timer = None

    def help_request(self):
        pioner = random.choice(db.get_pioners())
Ejemplo n.º 5
0
class LifeGame:
    def __init__(self, chat_id, bot, cells):
        self.__bot = bot
        self.__bot_helper = BotUtil(bot)
        self.__n = config.n
        self.__id = chat_id
        self.__world = dict()
        self.__size = '99'
        self.__speed = 1.2
        self.__msg = None
        self.__last = dict()
        self.__count = 0
        self.__xod = 0
        self.__del = 0
        self.__cells = cells

        print("Life class created, generating world...")
        self.__generate_world()

    def __generate_world(self):
        x = 0
        y = 0
        while x < int(self.__size[0]):
            y = 0
            self.__world.update({str(x) + str(y): 'dead'})
            while y < int(self.__size[1]):
                self.__world.update({str(x) + str(y): 'dead'})
                y += 1
            x += 1
        if self.__cells:
            for coordinate in self.__cells.split():
                self.__world.update({coordinate: 'alive'})

        print("World generated, starting game...")
        print("NOTE: Next steps are playing game. You should not print it.")
        self.__map_edit()

    def __map_edit(self):
        alive = []
        dead = []
        for cell in self.__world:
            if len(cell) == 1:
                cell += "0"
            x = int(cell[0])
            y = int(cell[1])
            near_alive = 0
            i1 = -1
            i2 = -1
            while i1 <= 1:
                i2 = -1
                while i2 <= 1:
                    point = str(x + i1) + str(y + i2)
                    try:
                        if self.__world[point] == 'alive' and point != cell:
                            near_alive += 1
                    except:
                        pass
                    i2 += 1
                i1 += 1
            if self.__world[cell] == 'alive':
                if 2 <= near_alive <= 3:
                    alive.append(cell)
                else:
                    dead.append(cell)

            elif self.__world[cell] == 'dead':
                if near_alive == 3:
                    alive.append(cell)
                else:
                    dead.append(cell)
        for cell in dead:
            self.__world[cell] = 'dead'
        for cell in alive:
            self.__world[cell] = 'alive'

        time.sleep(self.__speed)
        self.__start_game()

    def __start_game(self):
        text = ''
        x = 0
        y = 0
        em_alive = '⬜️'
        em_dead = '⬛️'
        while y < int(self.__size[0]):
            x = 0
            while x < int(self.__size[1]):
                c_point = str(x) + str(y)
                if self.__world[c_point] == 'alive':
                    text += em_alive
                else:
                    text += em_dead
                x += 1
            y += 1
            text += '\n'
        if not self.__msg:
            self.__msg = self.__bot.send_message(self.__id, text).message_id
        else:
            try:
                self.__bot_helper.edit_message(text, self.__id, self.__msg)
            except:
                print("HALTING LIFE GAME")
                return

        self.__map_edit()
Ejemplo n.º 6
0
import random
import threading
import time

from modules.funcs import BotUtil
from .. import config
from ..config import environ
from ..mongohelper import MongoHelper

altzone = -10800
bot = BotUtil(environ['TELEGRAM_TOKEN'])
db = MongoHelper()


class OlgaDmitrievna:
    def __init__(self):
        self.bot = bot
        self.name = 'OlgaDmitrievna'
        self.prefix = 'olg'
        self.chache = {}
        self.id = self.bot.get_me().id
        self.hello_texts = [
            'Ну что, пионер, скучаешь? Ничего, сейчас найду для тебя подходящее занятие! Подожди немного.',
            'Бездельничаешь? Сейчас я это исправлю! Подожди пару минут, найду тебе занятие.',
            'Здравствуй, пионер! Сейчас найду, чем тебя занять.']
        self.avaliable_works = []

    def call_linear(self):
        self.chache.update({'linear': []})
        bot.send_message(config.chat_id, 'Доброе утро, пионеры! В 7:30 жду всех на линейке!')
Ejemplo n.º 7
0
from modules.funcs import BotUtil
from .. import config
from ..config import environ
from ..mongohelper import MongoHelper

bot = BotUtil(environ['tolik'])
db = MongoHelper()


class Tolik:
    def __init__(self):
        self.bot = bot
        self.id = self.bot.get_me().id
        self.name = 'Tolik'
        self.prefix = 'tol'
        self.chat_id = config.chat_id
        self.cache = {}


tolik = Tolik()


@bot.message_handler(commands=['control'])
def start_control(m):
    if m.from_user.id not in db.get_bot_admins(tolik.prefix):
        return
    if tolik.cache.get('controller'):
        bot.reply_to(m, 'Мной уже управляют!')
        return
    tolik.cache.update({'controller': m.from_user.id})
    bot.reply_to(m, 'Ты теперь управляешь мной!')
Ejemplo n.º 8
0
import random
import threading

from modules.funcs import BotUtil
from .. import config
from ..config import environ
from ..mongohelper import MongoHelper

bot = BotUtil(environ['slavya'])
db = MongoHelper()


class Slavya:
    def __init__(self):
        self.bot = bot
        self.id = self.bot.get_me().id
        self.name = 'Slavya'
        self.prefix = 'sla'
        self.chat_id = config.chat_id
        self.cache = {}
        self.common_help_text = 'Привет, {}! Поможешь мне с одним важным заданием?'
        self.respective_help_text = '{}! Ты не раз выручал меня, поэтому я знаю, что тебе можно довериться. ' \
                                    'Поможешь мне с одним важным заданием?'
        self.help_texts = [
            'Отлично! А теперь само задание: надо развесить на деревьях гирлянды, а то завтра вечером '
            'будут танцы! Нужна соответствующая атмосфера.',
            'Спасибо! Тогда наполни вот это ведро водой и принеси сюда, мне надо помыть памятник.'
        ]
        self.help_timer = None

    def help_request(self):
Ejemplo n.º 9
0
import random

import config
from modules.funcs import BotUtil
from . import constants

bot = BotUtil(config.environ['magic_wars'], config.creator)


class Mob:
    def __init__(self, game, mob_id):
        self.game = game
        self.name = 'Моб'
        self.id = mob_id
        self.damage = 10
        self.wobble = 5
        self.max_xp = 99999999999999
        self.heart = '🖤️'
        self.attack_descs = ['ударил']
        self.kill_descs = ['убил']
        self.states = {
            'defence': {element: False
                        for element in constants.elements}
        }

    def attack(self):
        magicians = self.game.magicians
        if not magicians:
            return
        target = random.choice(magicians)
        desc = random.choice(self.attack_descs)
Ejemplo n.º 10
0
import random
import threading

from bots.everlastingsummer.pioner import Pioner
from modules.funcs import BotUtil
from .. import config
from ..config import environ
from ..mongohelper import MongoHelper

bot = BotUtil(environ['electronic'])
db = MongoHelper()


class Electronic:
    def __init__(self):
        self.bot = bot
        self.id = self.bot.get_me().id
        self.name = 'Electronic'
        self.prefix = 'ele'
        self.chat_id = config.chat_id
        self.cache = {}

    def game(self, players=None):
        new_players = []
        if players is None:
            players = self.cache['players']
            new_players = ['Ульяна', 'Алиса', 'Лена', 'Мику', 'Славя', 'Женя']
        self.cache['game'] = False
        if not players:
            self.bot.send_message(
                self.chat_id, 'Недостаточно игроков для начала турнира! '
Ejemplo n.º 11
0
import time

import config
from modules.funcs import BotUtil

bot = BotUtil(config.environ['attorney'], config.creator)

from pymongo import MongoClient

db = MongoClient(config.environ['database'])
rooms = db.attorney.rooms
users = db.attorney.users

from telebot import types

jobs = ['attorney', 'prosecutor', 'judge', 'witness', 'attorney helper', 'prosecutor helper']


@bot.message_handler(commands=['start'])
def start_handler(m):
    get_user(m.from_user.id)
    bot.reply_to(m, 'Привет. Выбери себе имя командой /name и иди в суд командой /rooms.')


@bot.message_handler(commands=['name'])
def name_handler(m):
    if not m.text.count(' '):
        return
    name = m.text.split(' ', 1)[1]
    if not name.isalpha():
        bot.reply_to(m, 'Имя должно состоять из букв!')
Ejemplo n.º 12
0
import random
import threading

from modules.funcs import BotUtil
from .. import config
from ..config import environ
from ..mongohelper import MongoHelper

bot = BotUtil(environ['miku'])
db = MongoHelper()


class Miku:
    def __init__(self):
        self.bot = bot
        self.id = self.bot.get_me().id
        self.name = 'Miku'
        self.prefix = 'mik'
        self.chat_id = config.chat_id
        self.cache = {}
        self.common_help_text = '{}, привет. Ты можешь мне помочь? '
        self.respective_help_text = '{}, привет! Ты мне часто помогаешь, поэтому хотелось бы попросить тебя о помощи ' \
                                    'еще раз... Не откажешь?'

        self.help_texts = [
            'У меня просто писька болит, можешь пососа...'
            ' Ой, извини, загооврилась немного. Поможешь с гитарой? Она просто растроилась '
            'а сама починить ее не могу. Я конечно могла попроси...'
        ]
        self.help_timer = None
Ejemplo n.º 13
0
import random
import threading

from modules.funcs import BotUtil
from .. import config
from ..config import environ
from ..mongohelper import MongoHelper

bot = BotUtil(environ['alisa'])
db = MongoHelper()


class Alisa:
    def __init__(self):
        self.bot = bot
        self.id = self.bot.get_me().id
        self.name = 'Alisa'
        self.prefix = 'ali'
        self.chat_id = config.chat_id
        self.cache = {}
        self.common_help_text = '{}, смотри, куда идёшь! Должен будешь, и долг отработаешь прямо сейчас.' \
                                ' Мне тут помощь нужна в одном деле...'
        self.respective_help_text = '{}, привет, я же знаю, что ты любишь повеселиться! Готов на этот раз?'
        self.help_texts = ['Отлично! Значит так, нам с Ульяной нужен отвлекающий на кухню...',
                           'Ну пошли, там нужно один прикол с Электроником намутить...']
        self.help_timer = None

    def help_request(self):
        pioner = random.choice(db.get_pioners())
        user_link = bot.get_link(pioner.name, pioner.id)
        tts = self.common_help_text.format(user_link)
Ejemplo n.º 14
0
import config
from config import environ, creator
from modules.coach import Coach

coach = Coach()
from modules.eatable import Cooker
from modules.funcs import BotUtil

bot = BotUtil(environ['cooker'])
cooker = Cooker(bot)


@bot.message_handler(commands=['help'])
def help_handler(m):
    bot.reply_to(m, '/tea - завари чай.\n/cook - приготовь еды.')


@bot.message_handler(commands=['cook'])
def cook_handler(m):
    if not m.text.count(' '):
        bot.send_message(
            m.chat.id, 'Вы забыли указать, что именно вы хотите приготовить!')
        return
    meal = m.text.lower().split(' ', 1)[1]
    if m.reply_to_message:
        cooker.cook(m.reply_to_message.message_id, m.from_user,
                    m.reply_to_message.from_user, m.chat, meal)
    else:
        bot.send_message(m.chat.id,
                         m.from_user.first_name + ' сьел(а) ' + meal + '!')
Ejemplo n.º 15
0
import random
import threading

from modules.funcs import BotUtil
from .. import config
from ..config import environ
from ..mongohelper import MongoHelper

bot = BotUtil(environ['zhenya'])
db = MongoHelper()


class Zhenya:
    def __init__(self):
        self.bot = bot
        self.id = self.bot.get_me().id
        self.name = 'Zhenya'
        self.prefix = 'zhe'
        self.chat_id = config.chat_id
        self.cache = {}
        self.common_help_text = '{}, привет. Помоги.'
        self.respective_help_text = '{}, привет. Помоги пожалуйста.'

        self.help_texts = ['Книги протри пойди.']
        self.help_timer = None

    def help_request(self):
        pioner = random.choice(db.get_pioners())
        user_link = bot.get_link(pioner.name, pioner.id)
        tts = self.common_help_text.format(user_link)
        if pioner.respects[self.name] > 85:
Ejemplo n.º 16
0
from threading import Timer

import requests

import config
from modules.funcs import BotUtil

bot = BotUtil(config.environ['mainbot'], config.creator)
if 'DYNO' in config.environ:
    heroku = True
    bot.report('Heroku initialization...')
else:
    heroku = False
    bot.report('Local initialization....')

from modules.coach import Coach

coach = Coach()

from modules.heroku import Heroku

app = Heroku().app

from modules.manybotslib import BotsRunner

if True:
    from bots import cooker
    from bots import penis_meter

    from bots import triggers
    from bots.simple_bplist import bot as bpl