This API provides a command line interface for managing a bot in simple way. Using this API you can manage you bot easily with distributive system. API get details of registered user save it to own database and it is capable to send msg at any time.
This API is capable of doing following things:
-
Registering a user
-
Sending a time dependent SMS (Alerm SMS)
-
Searching in a database and responding.
Following are the example task with code:
it may be possible that there may be slow internet connection or no internet connection or server may busy in that condition it is good to test the connection before using it, by code below
b = Bot()
b.open()
b.close()
del b
"""
output
Initilizing... Bot
Database Connecting...
Connection closed!
"""
To get the user information we have to make an instance of user class the following code shows how to get user data. getAllUser() returns the list of all user available at database.
u = User()
print(u.getAllUser())
Insert is refers to insert the data in SQL database which is Handel by bot. Bot takes user information either from Telegram Network or manually by calling save() . save() takes seven argument telegram user/group id, first name, user-name, active state, date or starting, date of ending and chat type as argument. and return true on success otherwise false.
u = User()
u.save(1, "first_name", "user", "Y", "25-12-2018", "No", "group")
remove() is used to remove a user from database. it takes one argument user id and return true if success otherwise false.
u = User()
u.remove('1')
getAllPrivate() returns all user details with there user ID as matrix and getAllPrivateID() returns all private chat id only as array.
c = Chat()
print(c.getAllPrivate())
print(c.getAllPrivateID())
To get all group information we have to call getAllGroup() this takes none argument and return matrix of all group details.
c = Chat()
print(c.getAllGroup())
Time Dependent Message/Auto-Mail acts as a alarm. These message is send by Bot in specific time period. To get list of current auto-mail we have to call getAllMailler() which return all auto-mail as table.
a = AutoMailer()
print(a.getAllMailler())
newMailler() used to set a new automail. It takes time and message and return true if successfully add.
a = AutoMailer()
print(a.newMailler(time_hh_mm, 'This is sample Text genrated by AutoMailer'))
deleteMailler() deleted the automatic mail. It takes time and message and return true if successfully remove.
a = AutoMailer()
print(a.deleteMailler(ti, 'This is sample Text genrated by AutoMailer'))
Automailer send message in every 24hr interal i.e it's repeat its cycle in every day. but we have to invoke a method run() to activate.
a = AutoMailer()
a.run()
In this chat bot manager you can add new user for specific time to start registration you have to invoke the run() method of Registration. and exiting the app can close the registration.
r = Regestration()
r.run()
Search Key is a search item which can be search by user using search() command in telegram app. Following code can insert a search item.
r = Regestration()
print(r.insertSerch("key2", "This is key2.", "12:30", "23:30"))
deleteSearch() is used to delete a search item. It takes two parameter key and meassage and return if success.
r = Regestration()
print(r.deleteSearch("key2", "This is key2."))
Like other chat-bot this manager also listen to user and response as per input command currently chat-bot respond on start, help and search command. to start listening call the polling() method
r = Regestration()
r.polling()
Command : Description
start : Start the bot
help : get all command list
search key : Search the given key