Create Bot first#5
Open
Pharmaceutical0 wants to merge 1 commit into
Open
Conversation
from telegram.ext import Updater, CommandHandler
# Replace '7358499762:AAHFK0ltQmy7eCa_I--RATqalruJ3h0TxGI' with your actual bot token updater = Updater('7358499762:AAHFK0ltQmy7eCa_I--RATqalruJ3h0TxGI', use_context=True) def start(update, context): chat_id = update.message.chat_id first_name = update.message.chat.first_name last_name = update.message.chat.last_name username = update.message.chat.username # Print chat details print(f"chat_id: {chat_id}, firstname: {Zaza}, lastname: {Garden}, username: {@weed1xbot}") # Send message based on the username if username == 'Zaza' or username == '@weed1xbot': context.bot.send_message(chat_id, f"Hello {@weed1xbot}! Welcome to the bot.") else: context.bot.send_message(chat_id, "Hello! You are not one of the specified users.") # Create CommandHandler and add it to the dispatcher start_command = CommandHandler('start', start) updater.dispatcher.add_handler(start_command) # Start polling for updates updater.start_polling() # Block until you press Ctrl+C updater.idle()
Global Viarable
global_var = 100
Def demo ()
print ("this is function")
global_var = 100
Def my_function()
print ("inside the function", global_var)
my_function()
print("outside the function", glabal_var)
#"Global" keywords......
n = 1
def inc_n():
global n
n += 1 # this one
print (n)
inc_n()
print(n)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
from telegram.ext import Updater, CommandHandler
Replace '7358499762:AAHFK0ltQmy7eCa_I--RATqalruJ3h0TxGI' with your actual bot token updater = Updater('7358499762:AAHFK0ltQmy7eCa_I--RATqalruJ3h0TxGI', use_context=True) def start(update, context): chat_id = update.message.chat_id first_name = update.message.chat.first_name last_name = update.message.chat.last_name username = update.message.chat.username # Print chat details print(f"chat_id: {chat_id}, firstname: {Zaza}, lastname: {Garden}, username: {@weed1xbot}") # Send message based on the username if username == 'Zaza' or username == '@weed1xbot': context.bot.send_message(chat_id, f"Hello {@weed1xbot}! Welcome to the bot.") else: context.bot.send_message(chat_id, "Hello! You are not one of the specified users.") # Create CommandHandler and add it to the dispatcher start_command = CommandHandler('start', start) updater.dispatcher.add_handler(start_command) # Start polling for updates updater.start_polling() # Block until you press Ctrl+C updater.idle()
Global Viarable
global_var = 100
Def demo ()
print ("this is function")
global_var = 100
Def my_function()
print ("inside the function", global_var)
my_function()
print("outside the function", glabal_var)
#"Global" keywords......
n = 1
def inc_n():
global n
n += 1 # this one
print (n)
inc_n()
print(n)