mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2025-04-05 11:22:30 -04:00
Switched to new method for sending Direct messages #215
This commit is contained in:
parent
931cadfffa
commit
28b6d554e2
@ -570,14 +570,28 @@ class baseBufferController(bufferController):
|
|||||||
users = utils.get_all_users(tweet, self.session.db)
|
users = utils.get_all_users(tweet, self.session.db)
|
||||||
dm = messages.dm(self.session, _(u"Direct message to %s") % (screen_name,), _(u"New direct message"), users)
|
dm = messages.dm(self.session, _(u"Direct message to %s") % (screen_name,), _(u"New direct message"), users)
|
||||||
if dm.message.get_response() == widgetUtils.OK:
|
if dm.message.get_response() == widgetUtils.OK:
|
||||||
val = self.session.api_call(call_name="send_direct_message", text=dm.message.get_text(), screen_name=dm.message.get("cb"))
|
screen_name = dm.message.get("cb")
|
||||||
# let's avoid this for now as sent dm's are quite different to new dm objects.
|
user = self.session.get_user_by_screen_name(screen_name)
|
||||||
# if val != None:
|
event_data = {
|
||||||
# if self.session.settings["general"]["reverse_timelines"] == False:
|
'event': {
|
||||||
# self.session.db["sent_direct_messages"].append(val)
|
'type': 'message_create',
|
||||||
# else:
|
'message_create': {
|
||||||
# self.session.db["sent_direct_messages"].insert(0, val)
|
'target': {
|
||||||
# pub.sendMessage("sent-dm", data=val, user=self.session.db["user_name"])
|
'recipient_id': user,
|
||||||
|
},
|
||||||
|
'message_data': {
|
||||||
|
'text': dm.message.get_text(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val = self.session.api_call(call_name="send_direct_message", **event_data)
|
||||||
|
if val != None:
|
||||||
|
if self.session.settings["general"]["reverse_timelines"] == False:
|
||||||
|
self.session.db["direct_messages"]["items"].append(val["event"])
|
||||||
|
else:
|
||||||
|
self.session.db["direct_messages"]["items"].insert(0, val["event"])
|
||||||
|
pub.sendMessage("sent-dm", data=val["event"], user=self.session.db["user_name"])
|
||||||
if hasattr(dm.message, "destroy"): dm.message.destroy()
|
if hasattr(dm.message, "destroy"): dm.message.destroy()
|
||||||
|
|
||||||
@_tweets_exist
|
@_tweets_exist
|
||||||
|
@ -1313,10 +1313,10 @@ class Controller(object):
|
|||||||
buffer.add_new_item(data)
|
buffer.add_new_item(data)
|
||||||
|
|
||||||
def manage_sent_dm(self, data, user):
|
def manage_sent_dm(self, data, user):
|
||||||
buffer = self.search_buffer("sent_direct_messages", user)
|
buffer = self.search_buffer("direct_messages", user)
|
||||||
if buffer == None: return
|
if buffer == None: return
|
||||||
play_sound = "dm_sent.ogg"
|
play_sound = "dm_sent.ogg"
|
||||||
if "sent_direct_messages" not in buffer.session.settings["other_buffers"]["muted_buffers"]:
|
if "direct_messages" not in buffer.session.settings["other_buffers"]["muted_buffers"]:
|
||||||
self.notify(buffer.session, play_sound=play_sound)
|
self.notify(buffer.session, play_sound=play_sound)
|
||||||
buffer.add_new_item(data)
|
buffer.add_new_item(data)
|
||||||
|
|
||||||
|
@ -547,3 +547,16 @@ class Session(object):
|
|||||||
return user
|
return user
|
||||||
else:
|
else:
|
||||||
return self.db["users"][id]
|
return self.db["users"][id]
|
||||||
|
|
||||||
|
def get_user_by_screen_name(self, screen_name):
|
||||||
|
if self.db.has_key("users") == False:
|
||||||
|
user = utils.if_user_exists(self.twitter.twitter, screen_name)
|
||||||
|
self.db["users"][user["id_str"]] = user
|
||||||
|
return user["id_str"]
|
||||||
|
else:
|
||||||
|
for i in self.db["users"].keys():
|
||||||
|
if self.db["users"][i]["screen_name"] == screen_name:
|
||||||
|
return self.db["users"][i]["id_str"]
|
||||||
|
user = utils.if_user_exists(self.twitter.twitter, screen_name)
|
||||||
|
self.db["users"][user["id_str"]] = user
|
||||||
|
return user["id_str"]
|
Loading…
x
Reference in New Issue
Block a user