本文整理汇总了Python中twitter.Twitter.sendTweet方法的典型用法代码示例。如果您正苦于以下问题:Python Twitter.sendTweet方法的具体用法?Python Twitter.sendTweet怎么用?Python Twitter.sendTweet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twitter.Twitter
的用法示例。
在下文中一共展示了Twitter.sendTweet方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Funlink
# 需要导入模块: from twitter import Twitter [as 别名]
# 或者: from twitter.Twitter import sendTweet [as 别名]
class Funlink():
regexpattern = r':(.+) (?:PRIVMSG) ([\S]+) :.addurl(?: (.+))'
def __init__(self):
self.Twitter = Twitter("","")
self.YouTube = YouTube()
def handleInput(self,Matchlist):
Source = Matchlist[0]
Target = Matchlist[1]
Text = Matchlist[2].split()
try:
URL = tinyurl.create_one(Text[0])
except Exception:
PrivMsg(Target,"4Error in 'TINYURL.Modul' >> '" + str(Exception) + "'")
return
Nick = re.match("(.+?)!", Source).group(1)
if (len(Text) >= 2) or (re.search("(?:.+)youtube.com/(?:.+)v=(\w+)",Text[0]) and len(Text) == 1): #Beschreibung mit angegeben
x = "[" + Nick + "] "
#Zusatzinformation ermitteln, wie [YouTube] [PNG] [TIF]
if (re.search("(?:.+)youtube.com/(?:.+)v=(\w+)",Text[0])):
x += "[YouTube] "
elif (re.search("(\w+).rofl.to",Text[0])):
r = re.search("(\w+).rofl.to",Text[0]).group(1)
x += "[rofl.to] (" + str(r) +") "
elif (re.search("collegehumor.com/(\w+)",Text[0])):
r = re.search("collegehumor.com/(\w+)",Text[0]).group(1)
x += "[CollegeHumor] (" + str(r) + ")"
elif (re.search("newgrounds.com/",Text[0])):
x += "[Newsground] "
else:
try:
Tag = re.search("\.(bmp|jpg|gif|img|jp2|jpeg|png|psd|tga|tif|txt)$",Text[0]).group(1)
x += "[" + Tag.upper() + "] "
except:
pass
if (len(Text) > 1):
x += URL + " " + " ".join(Text[1:])
else:
r = re.search("(?:.+)youtube.com/(?:.+)v=([-_\w]+)",Text[0]).group(1)
t = self.YouTube.getInfo(r)
x += URL + " " + t
#Twitter Tweets dürfen nicht länger als 140 Zeichen sein
if (len(x) <= 140):
self.Twitter.sendTweet(x)
PrivMsg(Target,"hinzugefügt! - http://twitter.com/fptlnk","15Funlink:07 ")
else:
PrivMsg(Target,"Beschreibung zu lang. Max 140 Zeichen. Dein Add war " \
+ str(len(x)) + " Zeichen lang.","15Funlink:07 ")
else: #Keine Beschreibung
PrivMsg(Target,"Die Beschreibung fehlt!","15Funlink:07 ")