diff --git a/README.md b/README.md
index c6ff30e..3a41254 100644
--- a/README.md
+++ b/README.md
@@ -29,16 +29,33 @@ This library provides complete Bot API 1.0 interface and compatible with Python
# Installing
Install using pip:
```bash
-pip install --upgrade mailru-im-bot
+pip install --upgrade mailru-im-bot-updated
```
Install from sources:
```bash
-git clone https://github.com/mail-ru-im/bot-python.git
-cd bot-python
+git clone https://github.com/Lunatik-cyber/bot-python-icq.git
+cd icq_bot-python-icq
python setup.py install
```
+# New features
+* Added ***file_name*** argument to **send_file** function. Now you can send files with custom names.
+* Now you can receive sent data in ***send_text, send_file, send_voice, edit_text functions,
+answer_callback_query***.
+
+### Example file_name argument
+```python
+bot.send_file(chat_id=chat_id, file_name="test.txt", file=open("test.txt", "rb"))
+```
+
+### Example sent data
+```python
+msg = bot.send_text(chat_id=chat_id, text="test")
+bot.edit_text(chat_id=chat_id, msg_id=msg["msgId"], text="test2")
+```
+
+
# API description
- icq.com/botapi/
diff --git a/example/decorators_bot.py b/example/decorators_bot.py
index b393f6d..6e951a9 100644
--- a/example/decorators_bot.py
+++ b/example/decorators_bot.py
@@ -1,4 +1,4 @@
-from bot.bot import Bot
+from icq_bot.bot import Bot
TOKEN = "" # your token here
diff --git a/example/echo_bot.py b/example/echo_bot.py
index 7fc12f9..57986ba 100644
--- a/example/echo_bot.py
+++ b/example/echo_bot.py
@@ -1,5 +1,5 @@
-from bot.bot import Bot
-from bot.handler import MessageHandler
+from icq_bot.bot import Bot
+from icq_bot.handler import MessageHandler
TOKEN = "" #your token here
diff --git a/example/format_bot.py b/example/format_bot.py
index e837693..55845ec 100644
--- a/example/format_bot.py
+++ b/example/format_bot.py
@@ -1,7 +1,7 @@
-from bot.bot import Bot
-from bot.handler import MessageHandler
-from bot.constant import ParseMode
-from bot.types import Format
+from icq_bot.bot import Bot
+from icq_bot.handler import MessageHandler
+from icq_bot.constant import ParseMode
+from icq_bot.types import Format
import logging.config
diff --git a/example/myteam_bot.py b/example/myteam_bot.py
index 1e166a7..224db54 100644
--- a/example/myteam_bot.py
+++ b/example/myteam_bot.py
@@ -1,5 +1,5 @@
-from bot.bot import Bot
-from bot.handler import MessageHandler
+from icq_bot.bot import Bot
+from icq_bot.handler import MessageHandler
import logging.config
diff --git a/example/scheduled_bot.py b/example/scheduled_bot.py
index 169e493..358a7f9 100644
--- a/example/scheduled_bot.py
+++ b/example/scheduled_bot.py
@@ -1,6 +1,6 @@
import schedule
import time
-from bot.bot import Bot
+from icq_bot.bot import Bot
TOKEN = "" #your toke here
bot = Bot(token=TOKEN)
diff --git a/example/test_bot.py b/example/test_bot.py
index bf0512a..ce4b075 100644
--- a/example/test_bot.py
+++ b/example/test_bot.py
@@ -4,9 +4,9 @@
from os import path
from time import sleep
import sys
-from bot.bot import Bot
-from bot.filter import Filter
-from bot.handler import HelpCommandHandler, UnknownCommandHandler, MessageHandler, FeedbackCommandHandler, \
+from icq_bot.bot import Bot
+from icq_bot.filter import Filter
+from icq_bot.handler import HelpCommandHandler, UnknownCommandHandler, MessageHandler, FeedbackCommandHandler, \
CommandHandler, NewChatMembersHandler, LeftChatMembersHandler, PinnedMessageHandler, UnPinnedMessageHandler, \
EditedMessageHandler, DeletedMessageHandler, StartCommandHandler, BotButtonCommandHandler
@@ -88,7 +88,7 @@ def deleted_message_cb(bot, event):
def message_with_bot_mention_cb(bot, event):
- bot.send_text(chat_id=event.data['chat']['chatId'], text="Message with bot mention was received")
+ bot.send_text(chat_id=event.data['chat']['chatId'], text="Message with icq_bot mention was received")
def mention_cb(bot, event):
@@ -198,7 +198,7 @@ def buttons_answer_cb(bot, event):
def main():
- # Creating a new bot instance.
+ # Creating a new icq_bot instance.
bot = Bot(token=TOKEN, name=NAME, version=VERSION, api_url_base=API_URL)
# Registering handlers #
@@ -243,7 +243,7 @@ def main():
# Handler for deleted message
bot.dispatcher.add_handler(DeletedMessageHandler(callback=deleted_message_cb))
- # Handler for message with bot mention
+ # Handler for message with icq_bot mention
bot.dispatcher.add_handler(MessageHandler(
filters=Filter.message & Filter.mention(user_id=bot.uin),
callback=message_with_bot_mention_cb
@@ -295,9 +295,9 @@ def main():
# ---------------------------------------------------------------------------------------- #
bot.start_polling()
- # Call bot methods
+ # Call icq_bot methods
# -------------- #
- # Get info about bot
+ # Get info about icq_bot
bot.self_get()
# Send message
@@ -389,7 +389,7 @@ def main():
# Set chat title
bot.set_chat_rules(chat_id=TEST_CHAT, rules="TEST RULES")
- # Send bot buttons
+ # Send icq_bot buttons
bot.send_text(chat_id=OWNER,
text="Hello with buttons.",
inline_keyboard_markup="[{}]".format(json.dumps([
@@ -398,7 +398,7 @@ def main():
{"text": "Action 3", "callbackData": "call_back_id_3"}
])))
- # Handler for bot buttons reply.
+ # Handler for icq_bot buttons reply.
bot.dispatcher.add_handler(BotButtonCommandHandler(callback=buttons_answer_cb))
bot.idle()
diff --git a/bot/__init__.py b/icq_bot/__init__.py
similarity index 82%
rename from bot/__init__.py
rename to icq_bot/__init__.py
index dd21f2e..88dc48f 100644
--- a/bot/__init__.py
+++ b/icq_bot/__init__.py
@@ -1,6 +1,6 @@
import logging
-__version__ = "0.0.21"
+__version__ = "0.0.25"
-# Set default logging handler to avoid "No handler found" warnings.
+# Set default logging handler to avoid "No handler found" warnings.№
logging.getLogger(__name__).addHandler(logging.NullHandler())
diff --git a/bot/bot.py b/icq_bot/bot.py
similarity index 98%
rename from bot/bot.py
rename to icq_bot/bot.py
index f76610e..79eb7d3 100644
--- a/bot/bot.py
+++ b/icq_bot/bot.py
@@ -32,6 +32,7 @@ def keyboard_to_json(keyboard_markup):
else:
return keyboard_markup
+
def format_to_json(format_):
if isinstance(format_, Format):
return format_.to_json()
@@ -40,6 +41,7 @@ def format_to_json(format_):
else:
return format_
+
class Bot(object):
def __init__(self, token: str, api_url_base: str = None, name: str = None, version: str = None,
timeout_s: int = 20, poll_time_s: int = 60, is_myteam: bool = False):
@@ -293,9 +295,10 @@ def send_text(self, chat_id: str, text: str, reply_msg_id=None, forward_chat_id=
"format": format_to_json(format_)
},
timeout=self.timeout_s
- )
+ ).json()
- def send_file(self, chat_id, file_id=None, file=None, caption=None, reply_msg_id=None, forward_chat_id=None,
+ def send_file(self, chat_id, file_id=None, file=None, file_name=None, caption=None, reply_msg_id=None,
+ forward_chat_id=None,
forward_msg_id=None, inline_keyboard_markup=None, parse_mode=None, format_=None):
if parse_mode and format_:
raise Exception("Cannot use format and parseMode fields at one time")
@@ -319,9 +322,12 @@ def send_file(self, chat_id, file_id=None, file=None, caption=None, reply_msg_id
)
if file:
request.method = "POST"
- request.files = {"file": file}
+ if file_name:
+ request.files = {"file": (file_name, file)}
+ else:
+ request.files = {"file": file}
- return self.http_session.send(request.prepare(), timeout=self.timeout_s)
+ return self.http_session.send(request.prepare(), timeout=self.timeout_s).json()
def send_voice(self, chat_id, file_id=None, file=None, reply_msg_id=None, forward_chat_id=None,
forward_msg_id=None, inline_keyboard_markup=None):
@@ -343,7 +349,7 @@ def send_voice(self, chat_id, file_id=None, file=None, reply_msg_id=None, forwar
request.method = "POST"
request.files = {"file": file}
- return self.http_session.send(request.prepare(), timeout=self.timeout_s)
+ return self.http_session.send(request.prepare(), timeout=self.timeout_s).json()
def edit_text(self, chat_id, msg_id, text, inline_keyboard_markup=None, parse_mode=None, format_=None):
if parse_mode and format_:
@@ -362,7 +368,7 @@ def edit_text(self, chat_id, msg_id, text, inline_keyboard_markup=None, parse_mo
"format": format_to_json(format_)
},
timeout=self.timeout_s
- )
+ ).json()
def delete_messages(self, chat_id, msg_id):
return self.http_session.get(
@@ -385,7 +391,7 @@ def answer_callback_query(self, query_id, text, show_alert=False, url=None):
"showAlert": 'true' if show_alert else 'false',
"url": url
}
- )
+ ).json()
def send_actions(self, chat_id, actions):
return self.http_session.get(
diff --git a/bot/constant.py b/icq_bot/constant.py
similarity index 100%
rename from bot/constant.py
rename to icq_bot/constant.py
diff --git a/bot/dispatcher.py b/icq_bot/dispatcher.py
similarity index 100%
rename from bot/dispatcher.py
rename to icq_bot/dispatcher.py
diff --git a/bot/event.py b/icq_bot/event.py
similarity index 100%
rename from bot/event.py
rename to icq_bot/event.py
diff --git a/bot/filter.py b/icq_bot/filter.py
similarity index 100%
rename from bot/filter.py
rename to icq_bot/filter.py
diff --git a/bot/handler.py b/icq_bot/handler.py
similarity index 100%
rename from bot/handler.py
rename to icq_bot/handler.py
diff --git a/bot/myteam.py b/icq_bot/myteam.py
similarity index 100%
rename from bot/myteam.py
rename to icq_bot/myteam.py
diff --git a/bot/types.py b/icq_bot/types.py
similarity index 100%
rename from bot/types.py
rename to icq_bot/types.py
diff --git a/bot/util.py b/icq_bot/util.py
similarity index 100%
rename from bot/util.py
rename to icq_bot/util.py
diff --git a/setup.py b/setup.py
index c78590d..cb61224 100644
--- a/setup.py
+++ b/setup.py
@@ -3,7 +3,7 @@
from setuptools import setup, find_packages
-import bot
+import icq_bot
here = path.abspath(path.dirname(__file__))
@@ -19,12 +19,12 @@ def requirements():
setup(
- name="mailru-im-bot",
- version=bot.__version__,
+ name="mailru-im-bot-updated",
+ version=icq_bot.__version__,
description="Pure Python interface for Bot API. Bot cookbook for Humans.",
long_description=long_description(),
long_description_content_type="text/markdown",
- url="https://github.com/mail-ru-im/bot-python",
+ url="https://github.com/Lunatik-cyber/bot-python-icq",
author="ICQ LLC (Mail.Ru Group)",
author_email="support@icq.com",
license="MIT",
@@ -45,7 +45,7 @@ def requirements():
"Programming Language :: Python :: 3.10",
"Operating System :: OS Independent"
],
- keywords="mailru im bot api",
+ keywords="mailru im icq_bot api",
packages=find_packages(exclude=["example"]),
install_requires=requirements(),
python_requires=">= 2.7, != 3.0.*, != 3.1.*, != 3.2.*, != 3.3.*",