Ejemplo n.º 1
0
def setName(update, context):
    text = update.message.text
    name = text.replace("/rename ", "")
    BOT.setName(name)
    with open('resource/name.txt', 'w') as file:
        file.write(str(name))
    update.message.reply_text(f"Set bot name '{BOT.name()}'")
Ejemplo n.º 2
0
if (not TOKEN) or (TOKEN == ''):
    logger.info('No Token. Program exit.')
    sys.exit(0)
else:
    # token 유효성 확인
    try:
        BOT.setToken(TOKEN)
    except Exception as e:
        logger.info(f'Error: {e}')
        sys.exit(0)

# name 획득, 없으면 기본 이름
NAME = load('resource/name.txt')
if (not NAME) or (NAME == ''):
    logger.info('No name. Set default name')
    BOT.setName('준식')
else:
    BOT.setName(NAME)

# user_chat_id 획득, 없으면 메세지를 받아 획득
CHAT_ID = load('resource/user_chat_id.txt')
if CHAT_ID:
    BOT.setChatID(CHAT_ID)
else:
    logger.info('No resource/user_chat_id.txt')
    BOT.hello()
    id = BOT.chat_id()
    save('resource/user_chat_id.txt', id)

# channel_id 획득, 없으면 무시
CHANNEL_ID = load('resource/channel_id.txt')