টেলিগ্রাম মেসেজিং ইন্টারফেস V2.0.0 পাইথন

লেখক:ফক্সপ্যান, তারিখ: ২০১৮-০৯-১২ ২ঃ২৯ঃ৩৩
ট্যাগঃPushMessage

টেলিগ্রাম API ইন্টারফেস (FMZ.com)

এই লাইব্রেরিটি বর্তমানে শুধুমাত্র টেলিগ্রাম মেসেজিং এর জন্য।

প্রাথমিকীকরণ

# key 为 Bot key
## 获取 Bot key 可以参考 https://www.ccino.org/create-a-telegram-bot.html
# chat_id 为收信用户Telegram ID
## Telegram ID 可以通过 @dwx_aibot 机器人获取, 连接至此机器人后发送 /getid 即可获得 ChatID
Telegram = ext.Telegram(key=string, chat_id=integer)    # 创建一个新的接口对象

পাঠানো

# chat_id 为可选项 默认会使用初始化时设置的ChatID
# message 即为信息内容
Telegram.Send(message=string, chat_id=integer)

সতর্কতা

আপনার নিজের কাছে বার্তা পাঠানোর আগে, আপনাকে প্রথমে টেলিগ্রামে আপনার বটকে একটি /start বার্তা পাঠাতে হবে, অন্যথায় বট আপনাকে বার্তা পাঠাতে পারবে না।

যোগাযোগ করুন

মেইলবক্সi@fawkex.meটেলিগ্রামফক্সপ্যান

কৌশলগত কাস্টমাইজেশন গ্রহণ করুন

এই লাইব্রেরি সম্পর্কে

টেলিগ্রাম এপিআই নথি

WTFPL-এর সাহায্যে Do What the Fuck You Want to Public License ব্যবহার করুন


#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# encoding: utf-8
# 
# Telegram Interface for FMZ.com
#
# Copyright 2018 FawkesPan
# Contact : i@fawkex.me / Telegram@FawkesPan
#
# Do What the Fuck You Want To Public License
#

try:
    import requests
except:
    print('Requests not installed. Try: pip install requests')
    Log('Requests not installed. Try: pip install requests')
    
    raise Exception('Requests not installed. Try: pip install requests')

class Telegram:
    def __init__(self):
        self.key = KEY
        self.chat_id = CHATID
        self.url = 'https://api.telegram.org/bot%s' % self.key
        
    def Send(self, message='', chat_id=None):
        if chat_id is None:
            chat_id = self.chat_id
        PARAM = {}
        PARAM['chat_id'] = chat_id
        PARAM['text'] = message
        PARAM['parse_mode'] = 'markdown'
        URL = self.url + '/sendMessage'
        try:
            res = requests.post(URL, data = PARAM)
            return True
        except IOError as e:
            print(e)
            return False
        

ext.Telegram = Telegram

# 模块功能测试
def main():
    if DEBUG == 1:
        msger = ext.Telegram(KEY, CHATID)
        msger.Send("Hello World!")
    
    return True

সম্পর্কিত

আরো

ঘাসd প্রশংসা