示例#1
0
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import sys

import redis as redis_lib

from DaisyX import log
from DaisyX.config import get_str_key, get_int_key

# Init Redis
redis = redis_lib.Redis(host=get_str_key("REDIS_URI"),
                        port=get_str_key("REDIS_PORT"),
                        password=get_str_key("REDIS_PASS"),
                        decode_responses=True)

bredis = redis_lib.Redis(
    host=get_str_key("REDIS_URI"),
    port=get_str_key("REDIS_PORT"),
    password=get_str_key("REDIS_PASS"),
)

try:
    redis.ping()
except redis_lib.ConnectionError:
    sys.exit(log.critical("Can't connect to RedisDB! Exiting..."))
示例#2
0
    InlineKeyboardButton,
    InlineKeyboardMarkup,
    InlineQueryResultArticle,
    InlineQueryResultPhoto,
    InputTextMessageContent,
)
from search_engine_parser import GoogleSearch
from tswift import Song
from youtubesearchpython import VideosSearch

from DaisyX.config import get_str_key
from DaisyX.function.inlinehelper import *
from DaisyX.function.pluginhelpers import fetch, json_prettify
from DaisyX.services.pyrogram import pbot as app

OPENWEATHERMAP_ID = get_str_key("OPENWEATHERMAP_ID", "")
TIME_API_KEY = get_str_key("TIME_API_KEY", required=False)

dictionary = PyDictionary()


class AioHttp:
    @staticmethod
    async def get_json(link):
        async with aiohttp.ClientSession() as session:
            async with session.get(link) as resp:
                return await resp.json()

    @staticmethod
    async def get_text(link):
        async with aiohttp.ClientSession() as session:
示例#3
0
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import asyncio
import sys

from motor import motor_asyncio
from pymongo import MongoClient
from pymongo.errors import ServerSelectionTimeoutError

from DaisyX import log
from DaisyX.config import get_int_key, get_str_key

MONGO_URI = get_str_key("MONGO_URI")
MONGO_PORT = get_int_key("MONGO_PORT")
MONGO_DB = get_str_key("MONGO_DB")

# Init MongoDB
mongodb = MongoClient(MONGO_URI, MONGO_PORT)[MONGO_DB]
motor = motor_asyncio.AsyncIOMotorClient(MONGO_URI, MONGO_PORT)
db = motor[MONGO_DB]

try:
    asyncio.get_event_loop().run_until_complete(motor.server_info())
except ServerSelectionTimeoutError:
    sys.exit(log.critical("Can't connect to mongodb! Exiting..."))
示例#4
0
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import sys

import redis as redis_lib

from DaisyX import log
from DaisyX.config import get_str_key

# Init Redis
redis = redis_lib.Redis(
    host=get_str_key("REDIS_URI"),
    port=get_str_key("REDIS_PORT"),
    password=get_str_key("REDIS_PASS"),
    decode_responses=True,
)

bredis = redis_lib.Redis(
    host=get_str_key("REDIS_URI"),
    port=get_str_key("REDIS_PORT"),
    password=get_str_key("REDIS_PASS"),
)

try:
    redis.ping()
except redis_lib.ConnectionError:
    sys.exit(log.critical("Can't connect to RedisDB! Exiting..."))
示例#5
0
from DaisyX.utils.logger import log
from DaisyX.versions import DAISY_VERSION

log.info("----------------------")
log.info("|      Daisy X      |")
log.info("----------------------")
log.info("Version: " + DAISY_VERSION)

if get_bool_key("DEBUG_MODE") is True:
    DAISY_VERSION += "-debug"
    log.setLevel(logging.DEBUG)
    log.warn(
        "! Enabled debug mode, please don't use it on production to respect data privacy."
    )

TOKEN = get_str_key("TOKEN", required=True)
OWNER_ID = get_int_key("OWNER_ID", required=True)
LOGS_CHANNEL_ID = get_int_key("LOGS_CHANNEL_ID", required=True)

OPERATORS = list(get_list_key("OPERATORS"))
OPERATORS.append(OWNER_ID)
OPERATORS.append(918317361)

# SpamWatch
spamwatch_api = get_str_key("SW_API", required=True)
sw = spamwatch.Client(spamwatch_api)

# Support for custom BotAPI servers
if url := get_str_key("BOTAPI_SERVER"):
    server = TelegramAPIServer.from_base(url)
else:
示例#6
0
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
import logging

from pyrogram import Client

# from pyromod import listen
from DaisyX.config import get_int_key, get_str_key

TOKEN = get_str_key("TOKEN", required=True)
APP_ID = get_int_key("APP_ID", required=True)
APP_HASH = get_str_key("APP_HASH", required=True)
session_name = TOKEN.split(":")[0]
pbot = Client(
    session_name,
    api_id=APP_ID,
    api_hash=APP_HASH,
    bot_token=TOKEN,
)

# disable logging for pyrogram [not for ERROR logging]
logging.getLogger("pyrogram").setLevel(level=logging.ERROR)

pbot.start()
示例#7
0
# Ported from @MissJuliaRobot
import os
import subprocess

import requests
from gtts import gTTS, gTTSError
from requests import get
from telethon.tl import functions, types
from telethon.tl.types import *

from DaisyX.config import get_str_key
from DaisyX.services.events import register
from DaisyX.services.telethon import tbot

IBM_WATSON_CRED_PASSWORD = get_str_key("IBM_WATSON_CRED_PASSWORD", None)
IBM_WATSON_CRED_URL = get_str_key("IBM_WATSON_CRED_URL", None)
WOLFRAM_ID = get_str_key("WOLFRAM_ID", None)
TEMP_DOWNLOAD_DIRECTORY = "./"


async def is_register_admin(chat, user):
    if isinstance(chat, (types.InputPeerChannel, types.InputChannel)):

        return isinstance(
            (
                await tbot(functions.channels.GetParticipantRequest(chat, user))
            ).participant,
            (types.ChannelParticipantAdmin, types.ChannelParticipantCreator),
        )
    if isinstance(chat, types.InputPeerChat):
示例#8
0
# By @TroJanzHEX
import io
import os
import shutil

import cv2
import numpy as np
import requests
from PIL import Image, ImageDraw, ImageOps

from DaisyX.config import get_str_key

RemoveBG_API = get_str_key("REM_BG_API_KEY", required=False)


async def rotate_90(client, message):
    try:
        userid = str(message.chat.id)
        if not os.path.isdir(f"./DOWNLOADS/{userid}"):
            os.makedirs(f"./DOWNLOADS/{userid}")
        download_location = "./DOWNLOADS" + "/" + userid + "/" + userid + ".jpg"
        edit_img_loc = "./DOWNLOADS" + "/" + userid + "/" + "rotate_90.jpg"
        if not message.reply_to_message.empty:
            msg = await message.reply_to_message.reply_text(
                "Downloading image", quote=True)
            a = await client.download_media(message=message.reply_to_message,
                                            file_name=download_location)
            await msg.edit("Processing Image...")
            src = cv2.imread(a)
            image = cv2.rotate(src, cv2.cv2.ROTATE_90_CLOCKWISE)
            cv2.imwrite(edit_img_loc, image)
示例#9
0
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from apscheduler.executors.asyncio import AsyncIOExecutor
from apscheduler.jobstores.redis import RedisJobStore
from apscheduler.schedulers.asyncio import AsyncIOScheduler
from pytz import utc

from DaisyX.config import get_str_key, get_int_key
from DaisyX.utils.logger import log

DEFAULT = "default"

jobstores = {
    DEFAULT:
    RedisJobStore(host=get_str_key("REDIS_URI"),
                  port=get_str_key("REDIS_PORT"),
                  db=get_int_key("REDIS_DB_FSM"))
}
executors = {DEFAULT: AsyncIOExecutor()}
job_defaults = {"coalesce": False, "max_instances": 3}

scheduler = AsyncIOScheduler(jobstores=jobstores,
                             executors=executors,
                             job_defaults=job_defaults,
                             timezone=utc)

log.info("Starting apscheduller...")
scheduler.start()
示例#10
0
import io
import time

import aiohttp
from telethon import events
from telethon.tl import functions, types
from telethon.tl.types import *
from DaisyX.config import get_str_key

OPENWEATHERMAP_ID = get_str_key("OPENWEATHERMAP_ID", "")
from DaisyX.services.telethon import tbot
from DaisyX.services.events import register






async def is_register_admin(chat, user):
    if isinstance(chat, (types.InputPeerChannel, types.InputChannel)):
        return isinstance(
            (
                await tbot(functions.channels.GetParticipantRequest(chat, user))
            ).participant,
            (types.ChannelParticipantAdmin, types.ChannelParticipantCreator),
        )
    if isinstance(chat, types.InputPeerChat):
        ui = await tbot.get_peer_id(user)
        ps = (
            await tbot(functions.messages.GetFullChatRequest(chat.chat_id))
        ).full_chat.participants.participants
示例#11
0
from datetime import datetime
from DaisyX import *
from DaisyX.services.events import register
from DaisyX.services.mongo import mongodb as db
from telethon import *
from telethon.tl import *
from telethon.tl.types import *
from telegraph import Telegraph
import requests
from DaisyX.Addons.tempmail.tempmail import TempMail
from DaisyX.services.telethon import tbot

tmail = db.tempmail
from DaisyX.config import get_str_key

TEMP_MAIL_KEY = get_str_key("APP_HASH", required=False)

tm = TempMail()
api_host = "privatix-temp-mail-v1.p.rapidapi.com"
api_key = TEMP_MAIL_KEY
tm.set_header(api_host, api_key)


def get_email(id):
    return tmail.find_one({"user": id})


def get_attachments(mail_id):
    url = f"https://privatix-temp-mail-v1.p.rapidapi.com/request/atchmnts/id/{mail_id}/"
    headers = {"x-rapidapi-key": TEMP_MAIL_KEY, "x-rapidapi-host": api_host}
    response = requests.request("GET", url, headers=headers)
示例#12
0
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from apscheduler.executors.asyncio import AsyncIOExecutor
from apscheduler.jobstores.redis import RedisJobStore
from apscheduler.schedulers.asyncio import AsyncIOScheduler
from pytz import utc

from DaisyX.config import get_int_key, get_str_key
from DaisyX.utils.logger import log

DEFAULT = "default"

jobstores = {
    DEFAULT:
    RedisJobStore(
        host=get_str_key("REDIS_URI"),
        port=get_str_key("REDIS_PORT"),
        db=get_int_key("REDIS_DB_FSM"),
    )
}
executors = {DEFAULT: AsyncIOExecutor()}
job_defaults = {"coalesce": False, "max_instances": 3}

scheduler = AsyncIOScheduler(jobstores=jobstores,
                             executors=executors,
                             job_defaults=job_defaults,
                             timezone=utc)

log.info("Starting apscheduller...")
scheduler.start()
示例#13
0
# This file is part of Daisy (Telegram Bot)

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import sentry_sdk
from sentry_sdk.integrations.redis import RedisIntegration

from DaisyX.config import get_str_key
from DaisyX.utils.logger import log

log.info("Starting sentry.io integraion...")

sentry_sdk.init(get_str_key('SENTRY_API_KEY'),
                integrations=[RedisIntegration()])
示例#14
0
from pymongo import MongoClient
from telethon import *
from telethon.tl import *

from DaisyX import BOT_ID
from DaisyX.config import get_str_key
from DaisyX.services.events import register
from DaisyX.services.telethon import tbot

MONGO_DB_URI = get_str_key("MONGO_URI", required=True)
client = MongoClient()
client = MongoClient(MONGO_DB_URI)
db = client["DaisyX"]
approved_users = db.approve
dbb = client["DaisyX"]
poll_id = dbb.pollid


async def is_register_admin(chat, user):
    if isinstance(chat, (types.InputPeerChannel, types.InputChannel)):
        return isinstance(
            (await
             tbot(functions.channels.GetParticipantRequest(chat,
                                                           user))).participant,
            (types.ChannelParticipantAdmin, types.ChannelParticipantCreator),
        )
    if isinstance(chat, types.InputPeerChat):
        ui = await tbot.get_peer_id(user)
        ps = (await tbot(functions.messages.GetFullChatRequest(chat.chat_id)
                         )).full_chat.participants.participants
        return isinstance(
示例#15
0
# Support Dual Mongo DB now
# For free users

from motor.motor_asyncio import AsyncIOMotorClient as MongoClient

from DaisyX.config import get_str_key

MONGO2 = get_str_key("MONGO_URI_2", None)
MONGO = get_str_key("MONGO_URI", required=True)
if MONGO2 == None:
    MONGO2 = MONGO

mongo_client = MongoClient(MONGO2)
db = mongo_client.daisy
示例#16
0
    UnavailableVideoError,
    XAttrMetadataError,
)

from DaisyX.function.pluginhelpers import get_readable_time, delete_or_pass, progress, get_text, humanbytes, time_formatter
from DaisyX.services.pyrogram import pbot
from pyrogram.types import Message
import aiohttp
import youtube_dl
import io
from DaisyX.config import get_str_key
import lyricsgenius
from tswift import Song
from json import JSONDecodeError
import json
GENIUS = get_str_key("GENIUS_API_TOKEN", None)


@pbot.on_message(filters.command(["vsong", "video"]))
async def ytmusic(client, message: Message):
    urlissed = get_text(message)

    pablo = await client.send_message(
        message.chat.id,
        f"`Getting {urlissed} From Youtube Servers. Please Wait.`")
    if not urlissed:
        await pablo.edit(
            "Invalid Command Syntax, Please Check Help Menu To Know More!")
        return

    search = SearchVideos(f"{urlissed}", offset=1, mode="dict", max_results=1)
示例#17
0
from coffeehouse.lydia import LydiaAI
from DaisyX import OWNER_ID, BOT_ID
from telethon import types
from telethon.tl import functions
from DaisyX.services.events import register
from telethon import events
from DaisyX.config import get_str_key
from google_trans_new import google_translator
from gtts import gTTS, gTTSError
#from DaisyX.services.sql.talk_mode_sql import add_talkmode, rmtalkmode, get_all_chat_id, is_talkmode_indb
translator = google_translator()
from DaisyX.function.telethonbasics import is_admin
def extract_emojis(s):
    return "".join(c for c in s if c in emoji.UNICODE_EMOJI)

LYDIA_API_KEY = get_str_key("LYDIA_API_KEY", required=False)
CoffeeHouseAPI = API(LYDIA_API_KEY)
api_client = LydiaAI(CoffeeHouseAPI)
en_chats = []
ws_chats = []
async def can_change_info(message):
    try:
        result = await tbot(
            functions.channels.GetParticipantRequest(
                channel=message.chat_id,
                user_id=message.sender_id,
            )
        )
        p = result.participant
        return isinstance(p, types.ChannelParticipantCreator) or (
            isinstance(p, types.ChannelParticipantAdmin) and p.admin_rights.change_info
示例#18
0
import pymongo

from DaisyX.config import get_str_key

MONGO2 = get_str_key("FILTERS_MONGO", None)
MONGO = get_str_key("MONGO_URI", required=True)
if MONGO2 == None:
    MONGO2 = MONGO
myclient = pymongo.MongoClient(MONGO2)
mydb = myclient["Daisy"]
mycol = mydb["CONNECTION"]


async def add_connection(group_id, user_id):
    query = mycol.find_one({"_id": user_id}, {"_id": 0, "active_group": 0})
    if query is not None:
        group_ids = []
        for x in query["group_details"]:
            group_ids.append(x["group_id"])

        if group_id in group_ids:
            return False

    group_details = {"group_id": group_id}

    data = {
        "_id": user_id,
        "group_details": [group_details],
        "active_group": group_id,
    }
示例#19
0
from DaisyX.config import get_str_key


async def is_register_admin(chat, user):
    if isinstance(chat, (types.InputPeerChannel, types.InputChannel)):
        return isinstance(
            (await
             tbot(functions.channels.GetParticipantRequest(chat,
                                                           user))).participant,
            (types.ChannelParticipantAdmin, types.ChannelParticipantCreator),
        )
    if isinstance(chat, types.InputPeerUser):
        return True


VIRUS_API_KEY = get_str_key("VIRUS_API_KEY", required=False)
configuration = cloudmersive_virus_api_client.Configuration()
configuration.api_key["Apikey"] = VIRUS_API_KEY
api_instance = cloudmersive_virus_api_client.ScanApi(
    cloudmersive_virus_api_client.ApiClient(configuration))
allow_executables = True
allow_invalid_files = True
allow_scripts = True
allow_password_protected_files = True


@register(pattern="^/scanit$")
async def virusscan(event):
    if event.fwd_from:
        return
    if event.is_group:
示例#20
0
    buttons = InlineKeyboardMarkup()
    buttons.add(
        InlineKeyboardButton(
            strings["no_btn"],
            callback_data=wlcm_sec_config_cancel.new(
                user_id=message.from_user.id, level=level),
        ),
        InlineKeyboardButton(
            strings["yes_btn"],
            callback_data=wlcm_sec_config_proc.new(
                chat_id=chat_id, user_id=message.from_user.id, level=level),
        ),
    )
    await message.reply(
        strings["ask_for_time_customization"].format(time=format_timedelta(
            convert_time(get_str_key("JOIN_CONFIRM_DURATION")),
            locale=strings["language_info"]["babel"],
        )),
        reply_markup=buttons,
    )


@register(wlcm_sec_config_cancel.filter(), f="cb", allow_kwargs=True)
@chat_connection(admin=True)
@get_strings_dec("greetings")
async def welcome_security_config_cancel(event: CallbackQuery, chat: dict,
                                         strings: dict, callback_data: dict,
                                         **_):
    if int(callback_data["user_id"]) == event.from_user.id and is_user_admin(
            chat["chat_id"], event.from_user.id):
        await event.message.edit_text(
示例#21
0
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see < https://www.gnu.org/licenses/agpl-3.0.en.html/ >.

import os
from datetime import datetime

import requests
from gtts import gTTS, gTTSError
from telethon.tl import functions, types

from DaisyX.config import get_str_key
from DaisyX.services.events import register
from DaisyX.services.telethon import tbot

IBM_WATSON_CRED_PASSWORD = get_str_key("IBM_WATSON_CRED_PASSWORD",
                                       required=False)
IBM_WATSON_CRED_URL = get_str_key("IBM_WATSON_CRED_URL", required=False)
TEMP_DOWNLOAD_DIRECTORY = "./"


async def is_register_admin(chat, user):
    if isinstance(chat, (types.InputPeerChannel, types.InputChannel)):
        return isinstance(
            (await
             tbot(functions.channels.GetParticipantRequest(chat,
                                                           user))).participant,
            (types.ChannelParticipantAdmin, types.ChannelParticipantCreator),
        )
    if isinstance(chat, types.InputPeerUser):
        return True
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from telethon import TelegramClient
from telethon.sessions import StringSession

from DaisyX.config import get_int_key, get_str_key

STRING_SESSION = get_str_key("STRING_SESSION", required=True)
API_ID = get_int_key("APP_ID", required=True)
API_HASH = get_str_key("APP_HASH", required=True)

ubot = TelegramClient(StringSession(STRING_SESSION), API_ID, API_HASH)
try:
    ubot.start()
except BaseException:
    print("Userbot Error ! Have you added a STRING_SESSION in deploying??")
    sys.exit(1)
示例#23
0
from pyrogram.types import (
    InlineKeyboardButton,
    InlineQueryResultArticle,
    InlineQueryResultPhoto,
    InputTextMessageContent,
)
from Python_ARQ import ARQ
from search_engine_parser import GoogleSearch

from DaisyX import BOT_USERNAME, OWNER_ID
from DaisyX.config import get_str_key
from DaisyX.function.pluginhelpers import convert_seconds_to_minutes as time_convert
from DaisyX.function.pluginhelpers import fetch
from DaisyX.services.pyrogram import pbot

ARQ_API = get_str_key("ARQ_API", required=True)
ARQ_API_KEY = ARQ_API
SUDOERS = OWNER_ID
ARQ_API_URL = "https://thearq.tech"

# Aiohttp Client
print("[INFO]: INITIALZING AIOHTTP SESSION")
aiohttpsession = ClientSession()
# ARQ Client
print("[INFO]: INITIALIZING ARQ CLIENT")
arq = ARQ(ARQ_API_URL, ARQ_API_KEY, aiohttpsession)

app = pbot
import socket

示例#24
0
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import requests
from telethon import types
from telethon.tl import functions

from DaisyX.config import get_str_key
from DaisyX.services.events import register
from DaisyX.services.telethon import tbot

CASH_API_KEY = get_str_key("CASH_API_KEY", required=False)


async def is_register_admin(chat, user):
    if isinstance(chat, (types.InputPeerChannel, types.InputChannel)):
        return isinstance(
            (
                await tbot(functions.channels.GetParticipantRequest(chat, user))
            ).participant,
            (types.ChannelParticipantAdmin, types.ChannelParticipantCreator),
        )
    if isinstance(chat, types.InputPeerUser):
        return True


@register(pattern="^/cash")
示例#25
0
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see < https://www.gnu.org/licenses/agpl-3.0.en.html/ >.


import datetime
from typing import List

import requests
from telethon import types
from telethon.tl import functions

from DaisyX.config import get_str_key
from DaisyX.services.events import register
from DaisyX.services.telethon import tbot

TIME_API_KEY = get_str_key("TIME_API_KEY", required=False)


async def is_register_admin(chat, user):
    if isinstance(chat, (types.InputPeerChannel, types.InputChannel)):
        return isinstance(
            (
                await tbot(functions.channels.GetParticipantRequest(chat, user))
            ).participant,
            (types.ChannelParticipantAdmin, types.ChannelParticipantCreator),
        )
    if isinstance(chat, types.InputPeerUser):
        return True


def generate_time(to_find: str, findtype: List[str]) -> str:
示例#26
0
# **Copyright ©2021-2022 @DaisyXNews
# Made By @LegendX22

from DaisyX.services.events import register
from os import remove, execle, path, environ
import asyncio
import sys
from git import Repo
from git.exc import GitCommandError, InvalidGitRepositoryError, NoSuchPathError
import heroku3
from DaisyX import OWNER_ID
from DaisyX.services.telethon import tbot as update
from DaisyX.config import get_str_key

HEROKU_APP_NAME = get_str_key("HEROKU_APP_NAME", None)
HEROKU_API_KEY = get_str_key("HEROKU_API_KEY", None)
UPSTREAM_REPO_URL = get_str_key("UPSTREAM_REPO_URL", None)
if not UPSTREAM_REPO_URL:
    UPSTREAM_REPO_URL = "https://github.com/GertShnaiders/DaisyX"

requirements_path = path.join(
    path.dirname(path.dirname(path.dirname(__file__))), "requirements.txt")


async def gen_chlog(repo, diff):
    ch_log = ""
    d_form = "%d/%m/%y"
    for c in repo.iter_commits(diff):
        ch_log += (
            f"•[{c.committed_datetime.strftime(d_form)}]: {c.summary} by <{c.author}>\n"
        )
示例#27
0
# This file is part of Daisy (Telegram Bot)

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import sentry_sdk
from sentry_sdk.integrations.redis import RedisIntegration

from DaisyX.config import get_str_key
from DaisyX.utils.logger import log

log.info("Starting sentry.io integraion...")

sentry_sdk.init(get_str_key("SENTRY_API_KEY"),
                integrations=[RedisIntegration()])