userbotindo / anjani Goto Github PK
View Code? Open in Web Editor NEW🤖 Telegram group management and spam protection bot
Home Page: https://userbotindo.com/anjani
License: GNU General Public License v3.0
🤖 Telegram group management and spam protection bot
Home Page: https://userbotindo.com/anjani
License: GNU General Public License v3.0
welcome
Bot can't handle button only welcome message
/setwelcome [test](buttonurl:https://google.com)
/welcome
)Bot should reject button only welcome message
No response
/fstats
Bot not responding when user user input is invalid
/fedstats
Gives a feedback message that the input is invalid
Traceback (most recent call last):
File "anjani/core/command_dispatcher.py", line 204, in on_command
ret = await cmd.func(ctx, *args, **kwargs)
File "anjani/plugins/federation.py", line 937, in cmd_fbanstats
user_id = int(ctx.args[0])
CommandInvokeError: raised from ValueError: invalid literal for int() with base 10: '<userinput>'
Can you add please android module again
automatic periodic backups
automatic backups at regular intervals, such as 1 day, 2 days, and so on...
thanks before :)
/restore
When try to /restore
the backup file, the bot gave success message, but it's not.
run /backup
command then /restore
the result.
gracefully restored the backuped file.
(most recent call last):
File "/anjani/anjani/core/event_dispatcher.py", line 188, in dispatch_event
result = await lst.func(*args, **kwargs)
File "/anjani/anjani/plugins/welcome.py", line 99, in on_chat_action
return await self._member_join(message, reply_to, thread_id)
File "/anjani/anjani/plugins/welcome.py", line 167, in _member_join
msg = await self.SEND[msg_type](
File "/usr/local/lib/python3.9/site-packages/pyrogram/sync.py", line 53, in async_to_sync_wrap
coroutine = function(*args, **kwargs)
anjani.error.EventDispatchError: raised from TypeError: send_message() got an unexpected keyword argument 'thread_id'
[ 11:21:56: ERROR ] bot - Error dispatching event 'plugin_restore' on Filters.on_plugin_restore with data
-1001360529005, {'chat_id': -1001360529005, 'Filters': {'chat_id': -1001360529005, 'trigger': {'asdasd': 'test', 'tomi': 'Asu nih org', 'a': 'a'}}, 'Language': {'chat_id': -1001360529005.0, '__v': 0, 'language': 'en'}, 'Notes': {'chat_id': -1001360529005, 'chat_name': 'Userbot Indo DEV', 'notes': {'note1': {'text': 'test', 'type': 1, 'content': None, 'button': [['button1', 'google.com', False]]}, 'Test': {'text': 'asdsadasd', 'type': 1, 'content': None, 'button': [['asd', 'https://google.com', False]]}, 'test2': {'text': 'asdadsadsadsads', 'type': 1, 'content': None, 'button': [['sadsa', 'https://google.com', False]]}, 'note3': {'text': '', 'type': 1, 'content': None, 'button': [['button1', 'google.com', False]]}, 'note2': {'text': 'test', 'type': 1, 'content': None, 'button': [['button1', 'google.com', False], ['button2', 'google.com', True]]}}}, 'Rules': {'chat_id': -1001360529005.0, '__v': 0, 'rules': 'tomi asuk banget'}, 'SpamPredict': {'chat_id': -1001360529005, 'setting': False}, 'Greetings': {'chat_id': -1001360529005, 'button': [], 'file_id': None, 'text': 'adsadsads', 'type': 0}}
Traceback (most recent call last):
File "/anjani/anjani/core/event_dispatcher.py", line 188, in dispatch_event
result = await lst.func(*args, **kwargs)
File "/anjani/anjani/plugins/filters.py", line 69, in on_plugin_restore
await self.db.update_one({"chat_id": chat_id}, {"$set": {data[self.name]}}, upsert=True)
anjani.error.EventDispatchError: raised from TypeError: unhashable type: 'dict'
/filter
Hello, i want to report some bugs,
I am trying to save filter to my group using anjani.
When giving command to save filter, she did well,
But after that i am trying to call this filter, for e.g : my filter is eggs, and i am trying to call this from post , i post eggs, but there's no response from anjani, also i am trying to find out why this happened from my logs, but sadly there's no error in my logs.
It's very useful, we save many filter for our groups, please can anyone fix this?
Thanks in advance and sorry for my bad English.
Fixing filter bugs
No response
/mute [reply_user | @username] {reason}
Command doesn't work if there is a reason.
Bots should work with reason.
Give an explanation
e.g
User has muted
Reason: None
No response
I've noticed that chat_action
event handles user joins and left events but seems like chat_member_update
already does the join and left events in a more efficient way since the chat_member_update
event gives access to the ChatMember class that holds information that the Message object lacks.
No, I am afraid I can't contribute this feature
/paste
Paste doesn't work, only shows successful caption. But, not giving the desired result
run /paste
Must show the result.
No response
/rules
Bot failed to fetch rule on chat that bans the bot.
Step to Reproduce
Bot gives warning that the chat is not accesible
Data:
• Chat -> XXXX (xxxxxxxxxx)
• Invoker -> XXXXXX (xxxxxxxxxx)
• Input -> rules_-xxxxxxxxxx
Traceback (most recent call last):
File "/anjani/anjani/core/command_dispatcher.py", line 189, in on_command
ret = await cmd.func(ctx, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/anjani/anjani/plugins/main.py", line 223, in cmd_start
return await plug.start_rules(ctx)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/anjani/anjani/plugins/rules.py", line 99, in start_rules
content, chat = await asyncio.gather(
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pyrogram/methods/chats/get_chat.py", line 81, in get_chat
r = await self.invoke(raw.functions.channels.GetFullChannel(channel=peer))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pyrogram/methods/advanced/invoke.py", line 79, in invoke
r = await self.session.invoke(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pyrogram/session/session.py", line 361, in invoke
return await self.send(query, timeout=timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pyrogram/session/session.py", line 331, in send
RPCError.raise_it(result, type(data))
File "/usr/local/lib/python3.11/site-packages/pyrogram/errors/rpc_error.py", line 91, in raise_it
raise getattr(
anjani.error.CommandInvokeError: raised from ChannelPrivate: Telegram says: [400 CHANNEL_PRIVATE] - The channel/supergroup is not accessible (caused by "channels.GetFullChannel")
-
When a user have telegram collectible username, bot not able to find the username.
-
Bot handle all the usernames
No response
Bot faces issues with handling closed topics encountering the [400 TOPIC_CLOSED] - The topic was closed
error. This error occurs when a group general topic is closed, and the bot simply drops the event. This proposal aims to enhance the bot's functionality by implementing a robust mechanism to address this issue.
message_thread_id
)Because the project name Anjani on pypi does not exist (yet), can we upload this project to pypi,
python -m anjani_bot
we can just use anjani-bot
)Example project that might help https://github.com/python-telegram-bot/python-telegram-bot
/filter or /note
When a user save a notes or filters that contains '.' (dot) or '$' (dollar), the insert query will fails as mongo doesn't support those character to be a document key field
The data should be saved normally to database
https://www.mongodb.com/docs/manual/core/dot-dollar-considerations/#std-label-crud-concepts-dot-dollar-considerations
[ 12:26:13: ERROR ] filters - Error in command 'filter'
Data:
• Chat -> XXXX (-XXXXXXXXXX)
• Invoker -> XXXX (XXXXX)
• Input -> .test
Traceback (most recent call last):
File "/anjani/anjani/core/command_dispatcher.py", line 189, in on_command
ret = await cmd.func(ctx, *args, **kwargs)
File "/anjani/anjani/plugins/filters.py", line 179, in cmd_filter
_, ret = await asyncio.gather(
File "/anjani/anjani/util/db/collection.py", line 477, in update_one
return await util.run_sync(
File "/anjani/anjani/util/async_helper.py", line 28, in run_sync
return await loop.run_in_executor(None, functools.partial(func, *args, **kwargs))
File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.9/site-packages/pymongo/collection.py", line 1041, in update_one
self._update_retryable(
File "/usr/local/lib/python3.9/site-packages/pymongo/collection.py", line 836, in _update_retryable
return self.__database.client._retryable_write(
File "/usr/local/lib/python3.9/site-packages/pymongo/mongo_client.py", line 1476, in _retryable_write
return self._retry_with_session(retryable, func, s, None)
File "/usr/local/lib/python3.9/site-packages/pymongo/mongo_client.py", line 1349, in _retry_with_session
return self._retry_internal(retryable, func, session, bulk)
File "/usr/local/lib/python3.9/site-packages/pymongo/_csot.py", line 105, in csot_wrapper
return func(self, *args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/pymongo/mongo_client.py", line 1390, in _retry_internal
return func(session, sock_info, retryable)
File "/usr/local/lib/python3.9/site-packages/pymongo/collection.py", line 817, in _update
return self._update(
File "/usr/local/lib/python3.9/site-packages/pymongo/collection.py", line 782, in _update
_check_write_command_response(result)
File "/usr/local/lib/python3.9/site-packages/pymongo/helpers.py", line 217, in _check_write_command_response
_raise_last_write_error(write_errors)
File "/usr/local/lib/python3.9/site-packages/pymongo/helpers.py", line 190, in _raise_last_write_error
raise WriteError(error.get("errmsg"), error.get("code"), error)
anjani.error.CommandInvokeError: raised from WriteError: The update path 'trigger..test' contains an empty field name, which is not allowed., full error: {'index': 0, 'code': 56, 'errmsg': "The update path 'trigger..test' contains an empty field name, which is not allowed."}
FEATURE REQUEST
Hello Sir, please Add Database Saved User's Broadcast Feautures on Anjani this repo...... Kindly Feauture request.
I'm reopening this issue as the previous issue was accidentally deleted with the repo lol.
The command filter regex won't accept commands like /cmd @username
even there is a space between the actual command and the arguments.
Anjani/anjani_bot/core/cust_filter.py
Lines 47 to 54 in 9fbbbc3
Anjani/anjani_bot/plugins/language.py
Line 44 in c350a6a
Traceback (most recent call last):
File "/home/mrmiss/.local/lib/python3.9/site-packages/pyrogram/dispatcher.py", line 194, in handler_worker
if await handler.check(self.client, parsed_update):
File "/home/mrmiss/.local/lib/python3.9/site-packages/pyrogram/handlers/handler.py", line 35, in check
return await self.filters(client, update)
File "/mnt/d/git/AnjaniBot/anjani_bot/core/cust_filter.py", line 49, in func
if matches.group(1) is None and matches.group(2).startswith("@"):
AttributeError: 'NoneType' object has no attribute 'startswith'
/mute [reply_user | @username] {reason}
Command doesn't work if there is a reason.
Bots should work with reason.
Give an explanation
e.g
User has muted
Reason: None
No response
/lock
Not responding when not have enough chat admin permission
don't give the bot full admin permission
Gives feedback that the bot have no permission
Traceback (most recent call last):
File "anjani/core/command_dispatcher.py", line 204, in on_command
ret = await cmd.func(ctx, *args, **kwargs)
File "anjani/plugins/lockings.py", line 315, in cmd_lock
await self.bot.client.set_chat_permissions(
File "../root/.cache/pypoetry/virtualenvs/anjani-3mAZpKo--py3.10/lib/python3.10/site-packages/pyrogram/methods/chats/set_chat_permissions.py", line 67, in set_chat_permissions
r = await self.invoke(
File "../root/.cache/pypoetry/virtualenvs/anjani-3mAZpKo--py3.10/lib/python3.10/site-packages/pyrogram/methods/advanced/invoke.py", line 79, in invoke
r = await self.session.invoke(
File "../root/.cache/pypoetry/virtualenvs/anjani-3mAZpKo--py3.10/lib/python3.10/site-packages/pyrogram/session/session.py", line 361, in invoke
return await self.send(query, timeout=timeout)
File "../root/.cache/pypoetry/virtualenvs/anjani-3mAZpKo--py3.10/lib/python3.10/site-packages/pyrogram/session/session.py", line 331, in send
RPCError.raise_it(result, type(data))
File "../root/.cache/pypoetry/virtualenvs/anjani-3mAZpKo--py3.10/lib/python3.10/site-packages/pyrogram/errors/rpc_error.py", line 91, in raise_it
raise getattr(
CommandInvokeError: raised from ChatAdminRequired: Telegram says: [400 CHAT_ADMIN_REQUIRED] - The method requires chat admin privileges (caused by "messages.EditChatDefaultBannedRights")
The current event dispatcher only runs with the priority sets sequentially. There is no way to tell the event dispatcher to stop the execution of an event for all other registered handlers that have lower priority.
Example usage:
class A(...):
@listener.priority(90)
async def on_message(self, message):
await message.delete()
# No other event handler will have a chance to handle this event
raise StopPropagation
class B(...):
async def on_message(self, message):
# will never be reached, because it has lower priority (since default is 100)
pass
/setwelcome or /setgoodbye
Raised ValueError when user input invalid welcome / goodbye text
greetings - Error in command 'setwelcome'
Data:
• Chat -> Xxxxxxx (-xxxxxxxxx)
• Invoker -> Xxxxxx (xxxxxxxxx)
• Input -> } xxxxxx xxxxxxxxxxx xxxxxxxx xxxxxxxxxx
Traceback (most recent call last):
File "/anjani/anjani/core/command_dispatcher.py", line 189, in on_command
ret = await cmd.func(ctx, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/anjani/anjani/plugins/welcome.py", line 279, in cmd_setwelcome
await self._build_text(welc_text or "", ctx.author, chat, self.bot.client)
File "/anjani/anjani/plugins/welcome.py", line 169, in _build_text
return text.format(
^^^^^^^^^^^^
anjani.error.CommandInvokeError: raised from ValueError: Single '}' encountered in format string
/setwelcome
When doing inline /setwelcome, Anjani don't respect newline character resulting the welcome message have a different line format (only single line).
I guess this apply to on goodbye message
the message saved should have the exact format from the invoking message.
No response
I tried to deploy the bot on my VPS using docker and I'm getting the sqlite3.IntegrityError: UNIQUE constraint failed: peers.id
error.
git clone https://github.com/userbotindo/Anjani
cd Anjani
sudo docker build . -t anjani
sudo docker run --restart unless-stopped --name anjaniBot anjani
The bot was supposed to be running normally.
❯ sudo docker run --restart unless-stopped --name anjaniBot anjani
Skipping virtualenv creation, as specified in config file.
INFO | launch | Running on Python 3.9.16
INFO | launch | Loading code
INFO | launch | Using uvloop event loop
INFO | launch | Initializing bot
INFO | bot | Starting
INFO | bot | Loading session from database
INFO | bot | Loading plugins
INFO | bot | Loading plugin 'Admins' (Admins) from 'anjani/plugins/admins.py'
INFO | bot | Loading plugin 'Backups' (Backups) from 'anjani/plugins/backups.py'
INFO | bot | Loading plugin 'Debug' (Debug) from 'anjani/plugins/debug.py'
INFO | bot | Loading plugin 'Federations' (Federation) from 'anjani/plugins/federation.py'
INFO | bot | Loading plugin 'Filters' (Filters) from 'anjani/plugins/filters.py'
INFO | bot | Loading plugin 'Language' (Language) from 'anjani/plugins/language.py'
INFO | bot | Loading plugin 'Lockings' (Lockings) from 'anjani/plugins/lockings.py'
INFO | bot | Loading plugin 'Main' (Main) from 'anjani/plugins/main.py'
INFO | bot | Loading plugin 'Miscs' (Misc) from 'anjani/plugins/misc.py'
INFO | bot | Loading plugin 'Muting' (Muting) from 'anjani/plugins/muting.py'
INFO | bot | Loading plugin 'Notes' (Notes) from 'anjani/plugins/notes.py'
INFO | bot | Loading plugin 'Purges' (Purges) from 'anjani/plugins/purge.py'
INFO | bot | Loading plugin 'Reporting' (Reporting) from 'anjani/plugins/reporting.py'
INFO | bot | Loading plugin 'Restriction' (Restrictions) from 'anjani/plugins/restriction.py'
INFO | bot | Loading plugin 'Rules' (Rules) from 'anjani/plugins/rules.py'
INFO | bot | Loading plugin 'SpamShield' (SpamShield) from 'anjani/plugins/spam_shield.py'
INFO | bot | Loading plugin 'Staff Tools' (Staff) from 'anjani/plugins/staff_tools.py'
INFO | bot | Loading plugin 'Stats' (PluginStats) from 'anjani/plugins/stats.py'
INFO | bot | Loading plugin 'Users' (Users) from 'anjani/plugins/users.py'
INFO | bot | Loading plugin 'Greetings' (Greeting) from 'anjani/plugins/welcome.py'
INFO | bot | All plugins loaded.
INFO | bot | Stopping
ERROR | bot | Error dispatching event 'stop' on Main.on_stop with data
Traceback (most recent call last):
File "/anjani/anjani/core/event_dispatcher.py", line 188, in dispatch_event
result = await lst.func(*args, **kwargs)
File "/anjani/anjani/plugins/main.py", line 102, in on_stop
data = await self.bot.client.invoke(GetState())
File "/usr/local/lib/python3.9/site-packages/pyrogram/methods/advanced/invoke.py", line 71, in invoke
raise ConnectionError("Client has not been started yet")
anjani.error.EventDispatchError: raised from ConnectionError: Client has not been started yet
INFO | bot | Running post-stop hooks
ERROR | asyncio | Task exception was never retrieved
future: <Task finished name='Task-1' coro=<run.<locals>.new_coro() done, defined at /usr/local/lib/python3.9/site-packages/aiorun.py:227> exception=IntegrityError('UNIQUE constraint failed: peers.id')>
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/aiorun.py", line 237, in new_coro
await coro
File "/anjani/anjani/core/anjani_bot.py", line 65, in init_and_run
await anjani.run()
File "/anjani/anjani/core/telegram_bot.py", line 248, in run
await self.start()
File "/anjani/anjani/core/telegram_bot.py", line 139, in start
await self.client.start()
File "/usr/local/lib/python3.9/site-packages/pyrogram/methods/utilities/start.py", line 58, in start
is_authorized = await self.connect()
File "/usr/local/lib/python3.9/site-packages/pyrogram/methods/auth/connect.py", line 40, in connect
await self.load_session()
File "/usr/local/lib/python3.9/site-packages/pyrogram/client.py", line 616, in load_session
await self.storage.open()
File "/usr/local/lib/python3.9/site-packages/pyrogram/storage/file_storage.py", line 66, in open
self.conn.execute("VACUUM")
sqlite3.IntegrityError: UNIQUE constraint failed: peers.id
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.