Skip to content

Commit

Permalink
fix for default name while /rclone command
Browse files Browse the repository at this point in the history
  • Loading branch information
sobuj53 authored Jun 9, 2021
1 parent a7717e7 commit 8bc3653
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tobrot/plugins/choose_rclone_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,23 @@
# -*- coding: utf-8 -*-
# (c) xiaoqi-beta | gautamajay52

import configparser # buildin package
import logging
import os
import re
from configparser import ConfigParser

import pyrogram.types as pyrogram
from pyrogram.types import CallbackQuery
from tobrot import LOGGER, OWNER_ID

config = configparser.ConfigParser()


async def rclone_command_f(client, message):
"""/rclone command"""
LOGGER.info(
f"rclone command from chatid:{message.chat.id}, userid:{message.from_user.id}"
)
if message.from_user.id == OWNER_ID and message.chat.type == "private":
config = ConfigParser()
config.read("rclone_bak.conf")
sections = list(config.sections())
inline_keyboard = []
Expand All @@ -31,6 +30,7 @@ async def rclone_command_f(client, message):
)
]
inline_keyboard.append(ikeyboard)
config = ConfigParser()
config.read("rclone.conf")
section = config.sections()[0]
msg_text = f"""Default section of rclone config is: **{section}**\n\n
Expand All @@ -54,6 +54,7 @@ async def rclone_command_f(client, message):
async def rclone_button_callback(bot, update: CallbackQuery):
"""rclone button callback"""
if update.data == "rcloneCancel":
config = ConfigParser()
config.read("rclone.conf")
section = config.sections()[0]
await update.message.edit_text(
Expand All @@ -65,8 +66,9 @@ async def rclone_button_callback(bot, update: CallbackQuery):
else:
section = update.data.split("_", maxsplit=1)[1]
with open("rclone.conf", "w", newline="\n", encoding="utf-8") as f:
config = ConfigParser()
config.read("rclone_bak.conf")
temp = configparser.ConfigParser()
temp = ConfigParser()
temp[section] = config[section]
temp.write(f)
await update.message.edit_text(
Expand Down

0 comments on commit 8bc3653

Please sign in to comment.